Morphisms defined by a matrix.

A matrix morphism is a morphism that is defined by multiplication by a matrix. Elements of domain must either have a method vector() that returns a vector that the defining matrix can hit from the left, or be coercible into vector space of appropriate dimension.

EXAMPLES:

sage: from sage.modules.matrix_morphism import MatrixMorphism, is_MatrixMorphism
sage: V = QQ^3
sage: T = End(V)
sage: M = MatrixSpace(QQ,3)
sage: I = M.identity_matrix()
sage: m = MatrixMorphism(T, I); m
Morphism defined by the matrix
[1 0 0]
[0 1 0]
[0 0 1]
sage: is_MatrixMorphism(m)
True
sage: m.charpoly('x')
x^3 - 3*x^2 + 3*x - 1
sage: m.base_ring()
Rational Field
sage: m.det()
1
sage: m.fcp('x')
(x - 1)^3
sage: m.matrix()
[1 0 0]
[0 1 0]
[0 0 1]
sage: m.rank()
3
sage: m.trace()
3

AUTHOR:

  • William Stein: initial versions
  • David Joyner (2005-12-17): added examples
  • William Stein (2005-01-07): added __reduce__
  • Craig Citro (2008-03-18): refactored MatrixMorphism class
class sage.modules.matrix_morphism.MatrixMorphism(parent, A)

Bases: sage.modules.matrix_morphism.MatrixMorphism_abstract

A morphism defined by a matrix.

is_injective()

Tell whether self is injective.

EXAMPLE:

sage: V1 = QQ^2
sage: V2 = QQ^3
sage: phi = V1.hom(Matrix([[1,2],[3,4],[5,6]]),V2)
sage: phi.is_injective()
True
sage: psi = V2.hom(Matrix([[1,2,3],[4,5,6]]),V1)
sage: psi.is_injective()
False

AUTHOR:

– Simon King (2010-05)

is_surjective()

Tell whether self is surjective.

EXAMPLE:

sage: V1 = QQ^2
sage: V2 = QQ^3
sage: phi = V1.hom(Matrix([[1,2],[3,4],[5,6]]),V2)
sage: phi.is_surjective()
False
sage: psi = V2.hom(Matrix([[1,2,3],[4,5,6]]),V1)
sage: psi.is_surjective()
True

AUTHOR:

– Simon King (2010-05)

matrix()

Return matrix that defines this morphism.

EXAMPLES:

sage: V = ZZ^2; phi = V.hom([3*V.0, 2*V.1])
sage: phi.matrix()
[3 0]
[0 2]
class sage.modules.matrix_morphism.MatrixMorphism_abstract(parent)

Bases: sage.categories.morphism.Morphism

base_ring()

Return the base ring of self, that is, the ring over which self is given by a matrix.

EXAMPLES:

sage: sage.modules.matrix_morphism.MatrixMorphism((ZZ**2).endomorphism_ring(), Matrix(ZZ,2,[3..6])).base_ring()
Integer Ring
charpoly(var='x')

Return the characteristic polynomial of this endomorphism.

INPUT:
  • var – variable

EXAMPLES:

sage: V = ZZ^2; phi = V.hom([V.0+V.1, 2*V.1])
sage: phi.charpoly()
x^2 - 3*x + 2
sage: phi.matrix().charpoly()
x^2 - 3*x + 2
sage: phi.charpoly('T')
T^2 - 3*T + 2
decomposition(*args, **kwds)

Return decomposition of this endomorphism, i.e., sequence of subspaces obtained by finding invariant subspaces of self.

See the documentation for self.matrix().decomposition for more details. All inputs to this function are passed onto the matrix one.

EXAMPLES:

sage: V = ZZ^2; phi = V.hom([V.0+V.1, 2*V.1])
sage: phi.decomposition()
[
Free module of degree 2 and rank 1 over Integer Ring
Echelon basis matrix:
[0 1],
Free module of degree 2 and rank 1 over Integer Ring
Echelon basis matrix:
[ 1 -1]
]
det()

Return the determinant of this endomorphism.

EXAMPLES:

sage: V = ZZ^2; phi = V.hom([V.0+V.1, 2*V.1])
sage: phi.det()
2
fcp(var='x')

Return the factorization of the characteristic polynomial.

EXAMPLES:

sage: V = ZZ^2; phi = V.hom([V.0+V.1, 2*V.1])
sage: phi.fcp()
(x - 2) * (x - 1)
sage: phi.fcp('T')
(T - 2) * (T - 1)
image()

Compute the image of this morphism.

EXAMPLES:

sage: V = VectorSpace(QQ,3)
sage: phi = V.Hom(V)(range(9))
sage: phi.image()
Vector space of degree 3 and dimension 2 over Rational Field
Basis matrix:
[ 1  0 -1]
[ 0  1  2]
sage: hom(GF(7)^3, GF(7)^2, 0).image()
Vector space of degree 2 and dimension 0 over Finite Field of size 7
Basis matrix:
[]

Compute the image of the identity map on a ZZ-submodule:

sage: V = (ZZ^2).span([[1,2],[3,4]])
sage: phi = V.Hom(V)(identity_matrix(ZZ,2))
sage: phi(V.0) == V.0
True
sage: phi(V.1) == V.1
True
sage: phi.image()
Free module of degree 2 and rank 2 over Integer Ring
Echelon basis matrix:
[1 0]
[0 2]
sage: phi.image() == V
True
kernel()

Compute the kernel of this morphism.

EXAMPLES:

sage: V = VectorSpace(QQ,3)
sage: id = V.Hom(V)(identity_matrix(QQ,3))
sage: null = V.Hom(V)(0*identity_matrix(QQ,3))
sage: id.kernel()
Vector space of degree 3 and dimension 0 over Rational Field
Basis matrix:
[]
sage: phi = V.Hom(V)(matrix(QQ,3,range(9)))
sage: phi.kernel()
Vector space of degree 3 and dimension 1 over Rational Field
Basis matrix:
[ 1 -2  1]
sage: hom(CC^2, CC^2, 1).kernel()
Vector space of degree 2 and dimension 0 over Complex Field with 53 bits of precision
Basis matrix:
[]
matrix()

EXAMPLES:

sage: V = ZZ^2; phi = V.hom(V.basis())
sage: phi.matrix()
[1 0]
[0 1]
sage: sage.modules.matrix_morphism.MatrixMorphism_abstract.matrix(phi)
...
NotImplementedError: this method must be overridden in the extension class
rank()

EXAMPLES:

sage: V = ZZ^2; phi = V.hom(V.basis())
sage: phi.rank()
2
sage: V = ZZ^2; phi = V.hom([V.0, V.0])
sage: phi.rank()
1
restrict(sub)

Restrict this matrix morphism to a subspace sub of the domain.

The codomain and domain of the resulting matrix are both sub.

EXAMPLES:

sage: V = ZZ^2; phi = V.hom([3*V.0, 2*V.1])
sage: phi.restrict(V.span([V.0]))
Free module morphism defined by the matrix
[3]
Domain: Free module of degree 2 and rank 1 over Integer Ring
Echelon ...
Codomain: Free module of degree 2 and rank 1 over Integer Ring
Echelon ...

sage: V = (QQ^2).span_of_basis([[1,2],[3,4]])
sage: phi = V.hom([V.0+V.1, 2*V.1])
sage: phi(V.1) == 2*V.1
True
sage: W = span([V.1])
sage: phi(W)
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[  1 4/3]
sage: psi = phi.restrict(W); psi
Free module morphism defined by the matrix
[2]
Domain: Vector space of degree 2 and dimension 1 over Rational Field
Basis ...
Codomain: Vector space of degree 2 and dimension 1 over Rational Field
Basis ...
sage: psi.domain() == W
True
sage: psi(W.0) == 2*W.0
True
restrict_codomain(sub)

Restrict this matrix morphism to a subspace sub of the codomain.

The resulting morphism has the same domain as before, but a new codomain.

EXAMPLES:

sage: V = ZZ^2; phi = V.hom([4*(V.0+V.1),0])
sage: W = V.span([2*(V.0+V.1)])
sage: phi
Free module morphism defined by the matrix
[4 4]
[0 0]
Domain: Ambient free module of rank 2 over the principal ideal domain ...
Codomain: Ambient free module of rank 2 over the principal ideal domain ...
sage: psi = phi.restrict_codomain(W); psi
Free module morphism defined by the matrix
[2]
[0]
Domain: Ambient free module of rank 2 over the principal ideal domain ...
Codomain: Free module of degree 2 and rank 1 over Integer Ring
Echelon ...

An example in which the codomain equals the full ambient space, but with a different basis:

sage: V = QQ^2
sage: W = V.span_of_basis([[1,2],[3,4]])
sage: phi = V.hom(matrix(QQ,2,[1,0,2,0]),W)
sage: phi.matrix()
[1 0]
[2 0]
sage: phi(V.0)
(1, 2)
sage: phi(V.1)
(2, 4)
sage: X = V.span([[1,2]]); X
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[1 2]
sage: phi(V.0) in X
True
sage: phi(V.1) in X
True
sage: psi = phi.restrict_codomain(X); psi
Free module morphism defined by the matrix
[1]
[2]
Domain: Vector space of dimension 2 over Rational Field
Codomain: Vector space of degree 2 and dimension 1 over Rational Field
Basis ...
sage: psi(V.0)
(1, 2)
sage: psi(V.1)
(2, 4)
sage: psi(V.0).parent() is X
True
restrict_domain(sub)

Restrict this matrix morphism to a subspace sub of the domain. The subspace sub should have a basis() method and elements of the basis should be coercible into domain.

The resulting morphism has the same codomain as before, but a new domain.

EXAMPLES:

sage: V = ZZ^2; phi = V.hom([3*V.0, 2*V.1])
sage: phi.restrict_domain(V.span([V.0]))
Free module morphism defined by the matrix
[3 0]
Domain: Free module of degree 2 and rank 1 over Integer Ring
Echelon ...
Codomain: Ambient free module of rank 2 over the principal ideal domain ...
sage: phi.restrict_domain(V.span([V.1]))
Free module morphism defined by the matrix
[0 2]...
trace()

EXAMPLES:

sage: V = ZZ^2; phi = V.hom([V.0+V.1, 2*V.1])
sage: phi.trace()
3
sage.modules.matrix_morphism.is_MatrixMorphism(x)

Return True if x is a Matrix morphism of free modules.

EXAMPLES:

sage: V = ZZ^2; phi = V.hom([3*V.0, 2*V.1])
sage: sage.modules.matrix_morphism.is_MatrixMorphism(phi)
True
sage: sage.modules.matrix_morphism.is_MatrixMorphism(3)
False

Previous topic

Morphisms of free modules.

Next topic

Finitely generated modules over a PID.

This Page