18.1 Space of matrices over a ring

Module: sage.matrix.matrix_space

Module-level Functions

MatrixSpace( base_ring, nrows, [ncols=False], [sparse=None])

Create with the command

MatrixSpace(base_ring , nrows [, ncols] [, sparse])

The default value of the optional argument sparse is False. The default value of the optional argument ncols is nrows.

INPUT:
     base_ring -- a ring
     nrows -- int, the number of rows
     ncols -- (default nrows) int, the number of columns 
     sparse -- (default false) whether or not matrices are given
               a sparse representation
OUTPUT:
    The space of all nrows x ncols matrices over base_ring.

sage: MS = MatrixSpace(RationalField(),2)
sage: MS.base_ring()
Rational Field
sage: MS.dimension()
4
sage: MS.dims()
(2, 2)
sage: B = MS.basis()
sage: B
[[1 0]
[0 0], [0 1]
[0 0], [0 0]
[1 0], [0 0]
[0 1]]
sage: B[0]
[1 0]
[0 0]
sage: B[1]
[0 1]
[0 0]
sage: B[2]
[0 0]
[1 0]
sage: B[3]
[0 0]
[0 1]
sage: A = MS.matrix([1,2,3,4])
sage: A
[1 2]
[3 4]
sage: MS2 = MatrixSpace(RationalField(),2,3)
sage: B = MS2.matrix([1,2,3,4,5,6])
sage: A*B
[ 9 12 15]
[19 26 33]

sage: M = MatrixSpace(Z, 10)
sage: M
Full MatrixSpace of 10 by 10 dense matrices over Integer Ring
sage: loads(M.dumps()) == M
True

is_MatrixSpace( x)

Class: MatrixSpace_domain

class MatrixSpace_domain
The space of all nrows x ncols matrices over base_ring
MatrixSpace_domain( self, base_ring, nrows, [ncols=False], [sparse=None])

Special Functions: _get_matrix_class

Class: MatrixSpace_field

class MatrixSpace_field
The space of all nrows x ncols matrices over base_field
MatrixSpace_field( self, base_field, nrows, [ncols=False], [sparse=None])

Functions: base_field

Special Functions: _get_matrix_class

Class: MatrixSpace_generic

class MatrixSpace_generic
The space of all nrows x ncols matrices over base_ring.

MatrixSpace_generic( self, base_ring, nrows, [ncols=False], [sparse=None])

Functions: base_ring,$  $ basis,$  $ dimension,$  $ dims,$  $ gen,$  $ identity_matrix,$  $ is_dense,$  $ is_sparse,$  $ matrix,$  $ matrix_space,$  $ ncols,$  $ ngens,$  $ nrows,$  $ random_element

matrix( self, [x=True], [coerce_entries=True], [copy=0])

Create a matrix in self. The entries can be specified either as a single list of length nrows*ncols, or as a list of lists.

sage: Z = IntegerRing()
sage: M = MatrixSpace(Z,2)
sage: M([[1,0],[0,-1]])
[ 1  0]
[ 0 -1]
sage: M([1,0,0,-1])
[ 1  0]
[ 0 -1]

random_element( self, [X=True], [prob=1.0], [coerce=[-2, -1, 1, 2]])

Returns a random element of self.

Special Functions: __call__,$  $ __cmp__,$  $ __repr__,$  $ _coerce_,$  $ _get_matrix_class,$  $ _latex_

Class: MatrixSpace_pid

class MatrixSpace_pid
The space of all nrows x ncols matrices over base_ring
MatrixSpace_pid( self, base_ring, nrows, [ncols=False], [sparse=None])

Special Functions: _get_matrix_class

See About this document... for information on suggesting changes.