Hi all,

In http://trac.sagemath.org/ticket/15104, I am finding that by far the most 
expensive part of taking the transpose of a (non-square) matrix is getting 
your hands on the parent (at least for matrices over (smallish) finite 
fields) It would be nice if we can speed this up:

As an example, if you have a square matrix M over GF(17), you can reuse the 
parent of M to create a fresh matrix that you can then fill (at C-speed) 
with the transpose:

sage: M=matrix(GF(5),6,7,range(6*7))
sage: P=M.matrix_space(3,3)
sage: C=M.__class__
sage: %timeit C.__new__(C,P,None,None,None)
100000 loops, best of 3: 2.04 us per loop

If you need a matrix of different dimensions, however, you end up having to 
construct/look up P and that is very slow by comparison:

sage: %timeit v=M.matrix_space(3,2)
100000 loops, best of 3: 6.41 us per loop

We can do a little better if we use the constructor itself:

sage: %timeit v=MatrixSpace(k,3,7)
100000 loops, best of 3: 2.79 us per loop

(a little bit of this is probably that M.matrix_space does an in-line 
import; the rest is probably call overhead)

Using the most obvious way is really quite bad:

sage: %timeit M.new_matrix(2,3)
100000 loops, best of 3: 13 us per loop

Any ideas on how we can make a really fast code-path to constructing 
(uninitialized) matrices of varying dimension?

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to