I just did a small test comparing Sage with Magma on my workstation
(sort of a generic intel box).  I generated a random 5 x 4 0/1 matrix,
and a random 5-vector v with coefficients in range(0,16).  I ran

timeit('xx= A.solve_right(v,check=False)')

and then passed v and A to magma and had magma eval to a 10000 long
loop of

a,c,d := IsConsistent(A,v)

I found that Magma was faster than sage by a factor of 44.  I haven't
looked at the sage code yet, but I hope that most of the difference
comes from the fact that it's not written in Cython.

Victor

On May 25, 2:48 pm, VictorMiller <[email protected]> wrote:
> I have a sage program which involves a lot of calculations of the
> form:
>
> solve for x, Ax = b, where A is an integral matrix and x and b are
> column vectors.  A is an integer matrix, but the solution (if it
> exists) for x might be rational.  Actually I want more than this:
>
> I want to also determine the kernel of A.  It turns out that magma has
> a function which does this:
>
> IsConsistent(A,b) which returns a boolean (saying if it's solvable), a
> value for x, and the kernel of A.
>
> I know that I can get the same functionality in Sage by doing
> something like:
>
> try:
>    x = A.change_ring(QQ).solve_right(b)
>    K = A.right_kernel()
>    # process x and K
> except:
>    print "no solution"
>
> This appears to be wasteful because, whatever elimination algorithm is
> being used by solve_right, would almost immediately yield the kernel,
> so that it's wasteful to redo the calculation.  So, perhaps
> solve_right could have an optional argument like kernel=True, etc.
>
> By the way, I've tried using hermite_form instead, but that's much
> much slower.
>
> I've found however, that magma's IsConsistent function is MUCH faster
> than this (by over a factor of 30).
>  As usual, it's impossible to figure out what algorithm Magma is
> using, but this indicates that some work should be done on the sage
> functions.  To be specific, the matrices that I'm processing are
> fairly small (say 5 by 4) 0/1 matrices.
>
> Victor

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to