Type MatrixSpace
Gens
--+
|
object
--+ |
| |
_uniq
--+
|
MatrixSpace
The space of all nrows x ncols matrices over base_ring.
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.
EXAMPLES:
>>> from sage.rings.rings import RationalField
>>> from sage.linalg.matrix_space import *
>>> QQ = RationalField()
>>> MS = MatrixSpace(QQ,2,2)
>>> MS.base_ring()
Rational Field
>>> MS.dimension()
4
>>> MS.dims()
(2, 2)
>>> B = MS.basis()
>>> B
[[1 0]
[0 0], [0 1]
[0 0], [0 0]
[1 0], [0 0]
[0 1]]
>>> B[0]
[1 0]
[0 0]
>>> B[1]
[0 1]
[0 0]
>>> B[2]
[0 0]
[1 0]
>>> B[3]
[0 0]
[0 1]
>>> A = MS.matrix([1,2,3,4])
>>> A
[1 2]
[3 4]
>>> MS2 = MatrixSpace(QQ,2,3)
>>> B = MS2.matrix([1,2,3,4,5,6])
>>> A*B
[ 9 12 15]
[19 26 33]
Method Summary |
|
__init__ (self,
base_ring,
nrows,
ncols,
sparse)
Create the space of all nrows x ncols matrices over base_ring. |
|
__call__(self,
entries,
coerce_entries,
copy)
|
|
__cmp__(self,
other)
|
|
__contains__(self,
x)
|
|
__repr__(self)
|
|
base_ring(self)
|
|
basis(self)
|
|
dimension(self)
|
|
dims(self)
|
|
gen(self,
n)
|
|
identity_matrix(self)
|
|
is_dense(self)
|
|
is_sparse(self)
|
|
matrix(self,
x,
coerce_entries,
copy)
|
|
matrix_space(self,
nrows,
ncols)
|
|
ncols(self)
|
|
ngens(self)
|
|
nrows(self)
|
|
random_element (self,
X,
prob,
coerce)
Returns a random element of self. |
Inherited from object |
|
__delattr__ (...)
x.__delattr__('name') <==> del x.name |
|
__getattribute__ (...)
x.__getattribute__('name') <==> x.name |
|
__hash__ (x)
x.__hash__() <==> hash(x) |
|
__reduce__ (...)
helper for pickle |
|
__reduce_ex__ (...)
helper for pickle |
|
__setattr__ (...)
x.__setattr__('name', value) <==> x.name = value |
|
__str__ (x)
x.__str__() <==> str(x) |
Inherited from Gens |
|
__getattr__ (self,
attrname)
|
|
__getitem__ (self,
n)
|
|
__getslice__ (self,
n,
m)
|
|
gens (self)
|
|
list (self)
|
__init__(self,
base_ring,
nrows,
ncols=None,
sparse=False)
(Constructor)
Create the space of all nrows x ncols matrices over base_ring.
INPUT:
base_ring -- a ring
nrows -- int, the number of rows
ncols -- int, the number of columns (defaults to nrows)
-
- Overrides:
__builtin__.object.__init__
|
random_element(self,
X=[-2, -1, 1, 2],
prob=1.0,
coerce=True)
Returns a random element of self.
-
|