5.3.1.1 MatrixSpace Objects

class MatrixSpace
The space of all nrows x ncols matrices over base_ring.
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: from sage.rings.rings import RationalField
sage: from sage.linalg.matrix_space import *
sage: QQ = RationalField()
sage: MS = MatrixSpace(QQ,2,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(QQ,2,3)
sage: B = MS2.matrix([1,2,3,4,5,6])
sage: A*B
[ 9 12 15]
[19 26 33]

Instances of class MatrixSpace have the following methods (in addition to inherited methods and special methods):

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

These methods are defined as follows:

base_ring( )

basis( )

dimension( )

dims( )

gen( n)

identity_matrix( )

is_dense( )

is_sparse( )

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

matrix_space( nrows, ncols, [sparse=False])

ncols( )

ngens( )

nrows( )

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

Returns a random element of self.

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

Returns a random element of self.

Instances of class MatrixSpace also have the following special methods:

__call__( [entries=True], [coerce_entries=True], [copy=0])

__cmp__( other)

__contains__( x)

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