Hi all!

I noticed that doing
A.is_singular()
is the same thing as
A.determinant() == 0

I am not sure this is optimal, as we can know that A.det() != 0
without having to compute it.
I was wondering if it would be quicker to make A.is_singular()
equivalent to

if A.nrows() == A.ncols():
    return A.rank() == A.ncols()
else:
    return False

The rationale is that we only need to know if the determinant is
different from 0, not its precise value.
I have done some tests and the timings suggest that computing the rank
is a bit faster than computing the determinant:

L = range(3000^2)

A = Matrix(ZZ, 3000, L)
time A.det()
0
Time: CPU 4.16 s, Wall: 4.07 s

A = Matrix(ZZ, 3000, L)
time A.rank()
2
Time: CPU 4.00 s, Wall: 3.92 s


Small improvement, but an improvement. Also, I observed that some
matrix functions use hand-made caches. Should we change those to use
@cahced_method instead, or is this done by some design reason?

Cheers
Javier

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to