On Wed, May 26, 2010 at 5:32 PM, VictorMiller <[email protected]> wrote:
> It's possible.  Probably a better test would be to write a loop in
> Magma which would modify the matrix in each iteration (say by adding
> something to one location).
> This came about because one of my colleagues had a large search
> program written in Magma in which almost all the computation was done
> in calls to IsConsistent in the inner loop.  Each call was with a
> different matrix A.  I rewrote the program in Sage, and found, much to
> my chagrin, that it was about a factor of 30 slower.  So in that
> program no caching could have helped.
>
> Victor

Remark:  For your problem you can reduce checking inclusion to doing a
single matrix vector multiplication, and looking at the last entry of
the product.

sage: A = Matrix([[1,0,1,0],[1,1,0,1],[0,1,0,1],[1,1,0,0],[1,0,0,0]])
sage: b=vector([13,1,7,5,14])
sage: timeit('A.solve_right(b,check=False)')
125 loops, best of 3: 1.72 ms per loop
sage: At = A.transpose(); At
[1 1 0 1 1]
[0 1 1 1 0]
[1 0 0 0 0]
[0 1 1 0 0]
sage: E = At.echelon_form(); E
[ 1  0  0  0  0]
[ 0  1  0  0  1]
[ 0  0  1  0 -1]
[ 0  0  0  1  0]
sage: v = vector([13,1,7,5])
sage: v*E
(13, 1, 7, 5, -6)
sage: timeit('v*E')
625 loops, best of 3: 47 µs per loop


Rewriting your code to use that trick would speed it up by a factor of
36 in Sage (at least on my laptop).  Maybe Magma uses an algorithm
like that internally?

William

-- 
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