08.02.2015 Views

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Matrices</strong> <strong>and</strong> <strong>Spaces</strong> <strong>of</strong> <strong>Matrices</strong>, Release 6.1.1<br />

Note that the __init__ function must construct the all zero matrix if ‘‘entries == None‘‘.<br />

*********** LEVEL 2 **********<br />

IMPORTANT (<strong>and</strong> *highly* recommended):<br />

After getting the special class with all level 1 functionality to<br />

work, implement all <strong>of</strong> the following (they should not change<br />

functionality, except speed (always faster!) in any way):<br />

* def _pickle(self):<br />

return data, version<br />

* def _unpickle(self, data, int version)<br />

reconstruct matrix from given data <strong>and</strong> version; may assume _parent, _nrows, <strong>and</strong> _ncols are<br />

Use version numbers >= 0 so if you change the pickle strategy then<br />

old objects still unpickle.<br />

* cdef _list -- list <strong>of</strong> underlying elements (need not be a copy)<br />

* cdef _dict -- sparse dictionary <strong>of</strong> underlying elements<br />

* cdef _add_ -- add two matrices with identical parents<br />

* _matrix_times_matrix_c_impl -- multiply two matrices with compatible dimensions <strong>and</strong><br />

identical base rings (both sparse or both dense)<br />

* cdef _cmp_c_impl -- compare two matrices with identical parents<br />

* cdef _lmul_c_impl -- multiply this matrix on the right by a scalar, i.e., self * scalar<br />

* cdef _rmul_c_impl -- multiply this matrix on the left by a scalar, i.e., scalar * self<br />

* __copy__<br />

* __neg__<br />

The list <strong>and</strong> dict returned by _list <strong>and</strong> _dict will *not* be changed<br />

by any internal algorithms <strong>and</strong> are not accessible to the user.<br />

*********** LEVEL 3 **********<br />

OPTIONAL:<br />

* cdef _sub_<br />

* __invert__<br />

* _multiply_classical<br />

* __deepcopy__<br />

Further special support:<br />

* Matrix windows -- to support Strassen multiplication for a given base ring.<br />

* Other functions, e.g., transpose, for which knowing the<br />

specific representation can be helpful.<br />

.. note::<br />

- For caching, use self.fetch <strong>and</strong> self.cache.<br />

- Any method that can change the matrix should call<br />

‘‘check_mutability()‘‘ first. There are also many fast cdef’d bounds checking methods.<br />

- Kernels <strong>of</strong> matrices<br />

Implement only a left_kernel() or right_kernel() method, whichever requires<br />

the least overhead (usually meaning little or no transposing). Let the<br />

methods in the matrix2 class h<strong>and</strong>le left, right, generic kernel distinctions.<br />

3.1. Indexing 65

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!