#15104: Special case modn_dense matrix operations to improve performance
-------------------------------------+-------------------------------------
Reporter: nbruin | Owner:
Type: enhancement | Status: needs_work
Priority: major | Milestone: sage-6.2
Component: linear algebra | Resolution:
Keywords: | Merged in:
Authors: Nils Bruin | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/nbruin/ticket/15104 | a908e28159a544ca33f03dcbf0e8def3cfe9a60e
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by nbruin):
I tried a little experiment for matrix creation. Presently, in
`M.__neg__()` the matrix gets created via
{{{
M = self.__class__.__new__(self.__class__,
self._parent,None,None,None)
}}}
leading to
{{{
sage: k=GF(17); M=matrix(20,30,[k.random_element() for i in range(600)])
sage: %timeit M.__neg__()
100000 loops, best of 3: 2.81 us per loop
}}}
If I change that line to
{{{
M = self.new_matrix()
}}}
this becomes
{{{
sage: %timeit M.__neg__()
100000 loops, best of 3: 11.8 us per loop
}}}
so there are much lower overhead ways of creating matrices (if you already
have a hold of the parent).
Of course, in `submatrix` and `stack` you don't have the parent in hand,
and in `transpose` you only do if the matrix happens to be square (which
may be worth special casing!). However, when you're doing frequent matrix
computations, the matrices often end up having similar shapes, so the
parents you're looking for are probably already available. This suggests
that `new_matrix` should have access to a cache of parents (weakly
referenced or rotating), so that it can do really quick (empty) matrix
creation.
--
Ticket URL: <http://trac.sagemath.org/ticket/15104#comment:11>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" 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-trac.
For more options, visit https://groups.google.com/groups/opt_out.