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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

sage: A[0,0] = 5<br />

sage: A.determinant()<br />

1<br />

sage: A.set_immutable()<br />

sage: A[0,0] = 5<br />

Traceback (most recent call last):<br />

...<br />

ValueError: matrix is immutable; please change a copy instead (i.e., use copy(M) to change a copy <strong>of</strong><br />

3.1.1 Implementation <strong>and</strong> Design<br />

Class Diagram (an x means that class is currently supported):<br />

x Matrix<br />

x Matrix_sparse<br />

x Matrix_generic_sparse<br />

x Matrix_integer_sparse<br />

x Matrix_rational_sparse<br />

Matrix_cyclo_sparse<br />

x Matrix_modn_sparse<br />

Matrix_RR_sparse<br />

Matrix_CC_sparse<br />

Matrix_RDF_sparse<br />

Matrix_CDF_sparse<br />

x<br />

x<br />

x<br />

x<br />

x<br />

x<br />

x<br />

Matrix_dense<br />

Matrix_generic_dense<br />

Matrix_integer_dense<br />

Matrix_integer_2x2_dense<br />

Matrix_rational_dense<br />

Matrix_cyclo_dense -- idea: restrict scalars to QQ, compute charpoly there, then factor<br />

Matrix_modn_dense<br />

Matrix_RR_dense<br />

Matrix_CC_dense<br />

Matrix_real_double_dense<br />

Matrix_complex_double_dense<br />

The corresponding files in the sage/matrix library code directory are named<br />

[matrix] [base ring] [dense or sparse].<br />

See the files matrix_template.pxd <strong>and</strong> matrix_template.pyx.<br />

New matrices types can only be implemented in Cython.<br />

*********** LEVEL 1 **********<br />

NON-OPTIONAL<br />

For each base field it is *absolutely* essential to completely<br />

implement the following functionality for that base ring:<br />

* set_unsafe(self, size_t i, size_t j, x) -- doesn’t do bounds or any other checks; assumes x is i<br />

* __cinit__ -- should use sage_malloc from ext/stdsage.pxi (only<br />

needed if allocate memory)<br />

* __init__ -- this signature: ’def __init__(self, parent, entries, copy, coerce)’<br />

* __dealloc__ -- use sage_free (only needed if allocate memory)<br />

* get_unsafe(self, size_t i, size_t j) -- doesn’t do checks<br />

* __richcmp__ -- always the same (I don’t know why its needed -- bug in PYREX).<br />

64 Chapter 3. <strong>Matrices</strong> over an arbitrary ring

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

Saved successfully!

Ooh no, something went wrong!