12.07.2015 Views

Sage Reference Manual: Matrices and Spaces of Matrices

Sage Reference Manual: Matrices and Spaces of Matrices

Sage Reference Manual: Matrices and Spaces of Matrices

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.2sage: d[(1,1)] = 2sage: dict_to_list(d, 2, 2)[1, 0, 0, 2]sage: dict_to_list(d, 2, 3)[1, 0, 0, 0, 2, 0]sage.matrix.matrix_space.is_MatrixSpace(x)Returns True if self is an instance <strong>of</strong> MatrixSpace returns false if self is not an instance <strong>of</strong> MatrixSpaceEXAMPLES:sage: from sage.matrix.matrix_space import is_Matrix<strong>Spaces</strong>age: MS = MatrixSpace(QQ,2)sage: A = MS.r<strong>and</strong>om_element()sage: is_MatrixSpace(MS)Truesage: is_MatrixSpace(A)Falsesage: is_MatrixSpace(5)Falsesage.matrix.matrix_space.list_to_dict(entries, nrows, ncols, rows=True)Given a list <strong>of</strong> entries, create a dictionary whose keys are coordinate tuples <strong>and</strong> values are the entries.EXAMPLES:sage: from sage.matrix.matrix_space import list_to_dictsage: d = list_to_dict([1,2,3,4],2,2)sage: d[(0,1)]2sage: d = list_to_dict([1,2,3,4],2,2,rows=False)sage: d[(0,1)]3sage.matrix.matrix_space.test_trivial_matrices_inverse(ring, sparse=True, checkrank=True)Tests inversion, determinant <strong>and</strong> is_invertible for trivial matrices.This function is a helper to check that the inversion <strong>of</strong> trivial matrices (<strong>of</strong> size 0x0, nx0, 0xn or 1x1) is h<strong>and</strong>ledconsistently by the various implementation <strong>of</strong> matrices. The coherency is checked through a bunch <strong>of</strong> assertions.If an inconsistency is found, an AssertionError is raised which should make clear what is the problem.INPUT:•ring - a ring•sparse - a boolean•checkrank - a booleanOUTPUT:•nothing if everything is correct, otherwise raise an AssertionErrorThe methods determinant, is_invertible, rank <strong>and</strong> inverse are checked for• the 0x0 empty identity matrix• the 0x3 <strong>and</strong> 3x0 matrices• the 1x1 null matrix [0]• the 1x1 identity matrix [1]13

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

Saved successfully!

Ooh no, something went wrong!