On Fri, Mar 6, 2015 at 6:22 PM, P Purkayastha <ppu...@gmail.com> wrote:
> On 03/07/2015 10:16 AM, William Stein wrote:
>>
>> On Fri, Mar 6, 2015 at 6:10 PM, Michael Orlitzky <mich...@orlitzky.com>
>> wrote:
>> > On 03/06/2015 08:10 PM, P Purkayastha wrote:
>> >>>
>> >>>
>> >> This is a serious bug. Is there a ticket for this?
>> >>
>> >
>> > It sort of falls under this one:
>> >
>> >    http://trac.sagemath.org/ticket/7392
>> >
>> > even though a fix for that ticket might not affect some similar
>> > examples.
>>
>> If you change the definition of rank, make sure to not do the
>> following, like I just thought I should do for a few minutes:
>>
>> sage: n = matrix([ [-0.3, 0.2, 0.1], [0.2, -0.4, 0.4], [0.1, 0.2, -0.5] ])
>> sage: a = n.numpy()
>> sage: import numpy
>> sage: numpy.rank(a)
>> 2
>>
>> It looks right... but it's 2 because it's a 2-dimensional array :-)
>>
>> sage: numpy.rank(numpy.zeros((1,2,4)))
>> 3
>>
>> Anyway, now you see how numerical people use the word "rank"...
>>
>> William
>>
>>
>>
> Well, something is clearly very wrong with either rank() or with ==. Since
> the matrices can be changed from one ring to another and they give True on
> equality it makes no sense for them to give different ranks.

"Equal" in Sage means "have equal images under the canonical parent
object that the both map to".   For example, we have

sage: Mod(3,5) == 3
True

but the number 3 modulo 5 (which is an element of Z/5Z) has many
properties that are different from that of the integer 3.

>
>
>
> I don't think a typical user wants to go deep into mathematics and try to
> figure out what should be the correct way to determine the rank of a matrix.
> It should give the correct answer. Otherwise the method should be removed
> from fields that can give incorrect results.

I tend to agree -- Having rank be removed or raise an error and
suggest that if they want to compute ranks they must use an exact ring
(e.g., QQ) would make a lot of sense to me. There is no sensible
reason to try to compute the rank of a matrix with floating point
entries.  It's slow and completely pointless. If they really are
trying to do numerical analysis, people should learn about QR
decompositions (etc.), and if they are not, they should use an exact
ring.

>
> sage: m.change_ring(RDF)
> [-0.3  0.2  0.1]
> [ 0.2 -0.4  0.4]
> [ 0.1  0.2 -0.5]
> sage: n.change_ring(QQ)
> [-3/10   1/5  1/10]
> [  1/5  -2/5   2/5]
> [ 1/10   1/5  -1/2]
> sage: m.change_ring(RDF).rank()
> 3
> sage: n.change_ring(QQ).rank()
> 2
>



-- 
William (http://wstein.org)

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to