Hi,
It would have been nice to sit down in person with Robert and/or William about
this at Clay, but I only fully realized the extent of my questions about 1.5
hours before I wanted to leave :). Anyhow, the matrix multiplication process
is looking a bit inefficient to me.
Here's the situation:
sage: M=MatrixSpace(ZZ,3,3)
sage: m=M([range(9)])
sage: n=M([range(1,10)])
sage: prun m*n
20 function calls in 0.000 CPU seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 <string>:1(<module>)
2 0.000 0.000 0.000 0.000 matrix_space.py:105(MatrixSpace)
1 0.000 0.000 0.000 0.000 matrix_space.py:282(change_ring)
1 0.000 0.000 0.000 0.000 matrix_space.py:306(base_extend)
1 0.000 0.000 0.000 0.000 matrix_space.py:648
(matrix_space)
3 0.000 0.000 0.000 0.000 matrix_space.py:670(ncols)
3 0.000 0.000 0.000 0.000 matrix_space.py:681(nrows)
...
The most alarming thing in that is the "base_extend" call. Both have a base
of ZZ (It also happens if both matrices are in MatrixSpace(QQ)). This
occurs because of a call to base_base_extend_canonical_sym_c around line 2075
in element.pyx. The other thing that alarms me is the calls
to "matrix_space" and "MatrixSpace" to construct a new parent space. These
are square matrices so we should not have to call out to the (python) parent
ring to make a new parent ring.
Now, both of these are easily enough fixed by an appropriate if statement
above the offending lines of code. However, it seems that this could all be
fit into the coercion model a little more seamlessly. It seems that the
Matrix.__mul__ method pretty much takes over and does it's own thing.
Any thoughts (especially from the coercion guru)? Craig suggested that matrix
multiplication could be viewed as an action in the coercion model, but I'm
not sure I agree. Mathematically, if element 'a' acts on element 'b', I
expect the result to have the same parent as 'b', but that isn't the case
with non-square matrices in general. I don't know if that definition
of 'action' is the same as the coercion model's.
--
Joel
--~--~---------~--~----~------------~-------~--~----~
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-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---