On 7/13/07, Soroosh Yazdani <[EMAIL PROTECTED]> wrote: > Hi, > > I was writing a function to calculate the structure of cuspidal subgroup of > J_0(N) without using modular symbols. I came across the following puzzling > bug. Here is a procedure which produces a matrix > def generate_cond5(l,r): > M=Matrix(QQ,l,r) > for j in range(l): > divpoint=2**j > for i in range(2**(l-1)): > > x=2*divpoint*ZZ(i).div(divpoint)+divpoint+ZZ(i).mod(divpoint) > M[j,x]=1 > return M > > Now running "generate_cond5(3,8)" give the following output: > sage: generate_cond5(3,8) > > [0 1 0 1 0 1 0 1] > [0 0 1 1 0 0 1 1] > [0 0 0 0 1 1 1 1] > > This is the correct output. However, if I change the second to last line in > the procedure to "M[j,x]=1/2", the output matrix is the zero matrix. > Similarly if I change the last line to "return M*(1/2)" I get the zero > matrix. Any ideas what could cause this?
Yes. Python integers have confusing semantics (e.g., 1/2 == 0), and probably the above code isn't being pre-parsed. (Is it in a .py file?) A quick fix is to write ZZ(1)/ZZ(2) or QQ('1/2') instead of 1/2. william --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---