Great. Now I load the following commands: q = 2 r = 2 s = 2 n = s*(r+1) d = 3 P = matrix(ZZ, r+2, r+2, lambda u, k: *Krawtchouk(r+1, q, ZZ(k), ZZ(u))*)
I got: [ 1 3 3 1] [ 1 1 -1 -1] [ 1 -1 -1 1] [ 1 -3 3 -1] So this is the right one? I'm a little bit confused. 在 2015年11月9日星期一 UTC+2上午9:19:45,Nils Bruin写道: > > On Sunday, November 8, 2015 at 11:13:24 PM UTC-8, Nils Bruin wrote: >> >> >> That's a bug, and one that should be pretty straightforward to solve. >> > Indeed, it's exceedingly silly. In Krawtchouk we execute: > > jth_term *= -q*(l-j+1)*(i-j+1)/((q-1)*j*(n-j+1)) > > If we'de doing that division with Sage Integer then we'll be getting > rational numbers. With python int this amounts to "//", so will likely give > other answers. > > Workaround: make sure you input Sage Integers (i.e., if you absolutely > have to use a ".py" file, write Integer(1) instead of 1. > > Fix: > - for j in range(1,l+1): > + for j in srange(1,l+1): > > > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
