[sage-support] Re: 64bit and rank-nullity [Was: Strange interaction between sage and numpy]
I made a ticket here: http://trac.sagemath.org/sage_trac/ticket/12280 Hopefully we can fix this at the bug days 35.5 ;-) -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Strange interaction between sage and numpy
Just noticed the following: sage: import numpy as np sage: r=10 sage: c=76 sage: A = 2*np.random.randint(2, size=(r,c))-np.ones((r,c),dtype=np.int) sage: A = matrix(QQ,A) sage: A 10 x 76 dense matrix over Integer Ring (type 'print A.str()' to see all of the entries) So matrix(QQ,) actually constructs a matrix over ZZ. Thats somewhat unexpected. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: 64bit and rank-nullity [Was: Strange interaction between sage and numpy]
On Jan 8, 8:31 am, Vegard Lima wrote: > sage: C = random_matrix(ZZ, 10, 80, distribution='uniform') > sage: C.ncols() - (C.right_kernel().dimension() + C.rank()) More specifically: sage: C.right_kernel() Free module of degree 80 and rank 80 over Integer Ring Echelon basis matrix: 80 x 80 dense matrix over Rational Field sage: C.right_kernel_matrix() 80 x 80 dense matrix over Integer Ring sage: C.right_kernel_matrix().rank() 70 sage: C._right_kernel_matrix_over_domain() ('computed-smith-form', 70 x 80 dense matrix over Integer Ring) Note a few things: - The right kernel is a Z-module with a basis matrix over Q. - The right kernel matrix has extra rows - the last routine does compute the right thing. A cursory reading of the code makes me believe that right_kernel would ultimately rely on _right_kernel_matrix_over_domain, but evidently it doesn't. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] 64bit and rank-nullity [Was: Strange interaction between sage and numpy]
This looks like a very serious bug to me. I can confirm that the bug occurs with 4.8.alpha6 and 5.0.prealpha. John On 8 January 2012 13:31, Vegard Lima wrote: > Sorry for replying to myself but after a bit of further digging > it appears that numpy didn't have anything to do with this. > It was just the route by which I came across the following problem: > > sage: C = random_matrix(ZZ, 10, 80, distribution='uniform') > sage: C.ncols() - (C.right_kernel().dimension() + C.rank()) > -10 > > On 32bit sage 4.7 on osx the answer is the correct 0. > Switching ZZ to QQ or RDF also restores the rank-nullity theorem. > > > Thanks, > -- > Vegard Lima > > -- > To post to this group, send email to sage-support@googlegroups.com > To unsubscribe from this group, send email to > sage-support+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-support > URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Strange interaction between sage and numpy
I looked into it a bit and it seems to be an IML bug. Presumably 75 is some cutoff inside IML, though I haven't verified this. You get the right answer if you use a different backend to compute the kernel: sage: matrix(QQ,A).right_kernel(algorithm='generic').dimension()+A.rank() 76 -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] 64bit and rank-nullity [Was: Strange interaction between sage and numpy]
Sorry for replying to myself but after a bit of further digging it appears that numpy didn't have anything to do with this. It was just the route by which I came across the following problem: sage: C = random_matrix(ZZ, 10, 80, distribution='uniform') sage: C.ncols() - (C.right_kernel().dimension() + C.rank()) -10 On 32bit sage 4.7 on osx the answer is the correct 0. Switching ZZ to QQ or RDF also restores the rank-nullity theorem. Thanks, -- Vegard Lima -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
Re: [sage-support] Re: Strange interaction between sage and numpy
On Sun, Jan 8, 2012 at 9:12 AM, Dima Pasechnik wrote: > It's hard to say whether it's a linear algebra bug, or matrix creation bug. > Could you check that the result of A = matrix(QQ,A) actually makes sense? It looks ok to me: sage: A = matrix(QQ,A) sage: A 10 x 76 dense matrix over Integer Ring (type 'print A.str()' to see all of the entries) sage: A.str() '[ 1 -1 1 1 1 1 -1 -1 1 -1 1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 etc etc... The thing is that the A.right_kernel_matrix() is padded with zeros. It has "rank - (dim null space)" extra zero columns. The first "dim null space" columns are correctly computed. Thanks, -- Vegard Lima -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: Strange interaction between sage and numpy
It's hard to say whether it's a linear algebra bug, or matrix creation bug. Could you check that the result of A = matrix(QQ,A) actually makes sense? -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org