32.10 Base class for dense matrices

Module: sage.matrix.matrix_dense

Base class for dense matrices

TESTS:

sage: R.<a,b> = QQ[]
sage: m = matrix(R,2,[0,a,b,b^2])
sage: loads(dumps(m)) == m
True

Class: Matrix_dense

class Matrix_dense

Functions: antitranspose,$ \,$ apply_map,$ \,$ apply_morphism,$ \,$ transpose

antitranspose( )

Returns the anittranspose of self, without changing self.

sage: A = matrix(2,3,range(6)); A
[0 1 2]
[3 4 5]
sage: A.antitranspose()
[5 2]
[4 1]
[3 0]

sage: A.subdivide(1,2); A
[0 1|2]
[---+-]
[3 4|5]
sage: A.antitranspose()
[5|2]
[-+-]
[4|1]
[3|0]

apply_map( )

Apply the given map phi (an arbitrary Python function or callable object) to this dense matrix. If R is not given, automatically determine the base ring of the resulting matrix.

Input:

phi
- arbitrary Python function or callable object
R
- (optional) ring

Output: a matrix over R

sage: m = matrix(ZZ, 3, range(9))
sage: k.<a> = GF(9)
sage: f = lambda x: k(x)
sage: n = m.apply_map(f); n
[0 1 2]
[0 1 2]
[0 1 2]
sage: n.parent()
Full MatrixSpace of 3 by 3 dense matrices over Finite Field in a of size
3^2

In this example, we explicitly specify the codomain.

sage: s = GF(3)
sage: f = lambda x: s(x)
sage: n = m.apply_map(f, k); n
[0 1 2]
[0 1 2]
[0 1 2]
sage: n.parent()
Full MatrixSpace of 3 by 3 dense matrices over Finite Field in a of size
3^2

TESTS:

sage: m = matrix([])
sage: m.apply_map(lambda x: x*x) == m
True

apply_morphism( )

Apply the morphism phi to the coefficients of this dense matrix.

The resulting matrix is over the codomain of phi.

Input:

phi
- a morphism, so phi is callable and phi.domain() and phi.codomain() are defined. The codomain must be a ring.

Output: a matrix over the codomain of phi

sage: m = matrix(ZZ, 3, range(9))
sage: phi = ZZ.hom(GF(5))
sage: m.apply_morphism(phi)
[0 1 2]
[3 4 0]
[1 2 3]
sage: parent(m.apply_morphism(phi))
Full MatrixSpace of 3 by 3 dense matrices over Finite Field of size 5

We apply a morphism to a matrix over a polynomial ring:

sage: R.<x,y> = QQ[]
sage: m = matrix(2, [x,x^2 + y, 2/3*y^2-x, x]); m
[          x     x^2 + y]
[2/3*y^2 - x           x]
sage: phi = R.hom([y,x])
sage: m.apply_morphism(phi)
[          y     y^2 + x]
[2/3*x^2 - y           y]

transpose( )

Returns the transpose of self, without changing self.

We create a matrix, compute its transpose, and note that the original matrix is not changed.

sage: M = MatrixSpace(QQ,  2)
sage: A = M([1,2,3,4])
sage: B = A.transpose()
sage: print B
[1 3]
[2 4]
sage: print A
[1 2]
[3 4]

sage: A.subdivide(None, 1); A
[1|2]
[3|4]
sage: A.transpose()
[1 3]
[---]
[2 4]

Special Functions: __copy__,$ \,$ _multiply_classical,$ \,$ _pickle,$ \,$ _unpickle_generic

__copy__( )

Return a copy of this matrix. Changing the entries of the copy will not change the entries of this matrix.

_multiply_classical( )

Multiply the matrices left and right using the classical $ O(n^3)$ algorithm.

This method assumes that left and right have the same parent and compatable dimensions.

_pickle( )

_unpickle_generic( )

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