MatrixRing(S, n) : Rng, RngIntElt -> AlgMat
Given a positive integer n and a ring S, create the complete matrix algebra
Mn(S), consisting of all n x n matrices with coefficients in the
ring S.
Given a matrix algebra defined as a subalgebra of Mn(S), create the
element of R defined by the list L of n2 elements from S.
Given a matrix algebra R defined as a subalgebra of Mn(S) and a
sequence Q=[a11, ..., a1n, a21, ..., a2n, ...,
an1, ..., ann] of n2 elements of S,
return the matrix
[ a_11 a_12 ... a_1n ]
[ a_21 a_22 ... a_2n ]
[ ... ]
[ a_n1 a_n2 ... a_nn ]
as an element of R. Note that the algebra R must exist before an attempt is
made to create matrices.
This function creates a n by n matrix over the finite field K of
cardinality q specified in a "Cambridge" format in the general matrix
algebra of degree n over K. The parameter t specifies the type of
the format. If t is 1, then q is assumed to be less than 10 and the
sequence Q must consist of n strings which give the n rows---each string
must have length n and contain the entries of that row (each entry is a
digit in the range [0, q - 1]).
If t is 3 then Q must consist of n2 integers in the range [0, q - 1]
which give the entries in row-major order. In either format, if q=pe,
where p is prime and e>1, then an entry x is written as a vector
using the base-p representation of length e of x and the corresponding
element in K is used (see the Finite Fields chapter for details).
This function is principally provided for the reading in of large matrices.
Given a monic polynomial p of degree n over a ring R,
create the companion matrix C for p as an element of Mn(R).
The minimal and characteristic polynomial of C is then p.
If R is a subalgebra of Mn(S) and Q is a sequence of n elements
of S, create the diagonal matrix diag( Q[1], Q[2], ..., Q[n] ).
Create the matrix unit E(i, j) in the matrix algebra R, i.e. the matrix
having the one of the coefficient ring of R in position (i, j) and
zeros elsewhere.
Create a random matrix of the matrix algebra R.
If R is a subalgebra of Mn(S) and t is an element of the ring S,
create the scalar matrix t * I in R.
Create the identity matrix In of the matrix algebra R.
Create the zero matrix of the matrix algebra R.
Create the scalar matrix t * I of the matrix algebra R.
MatrixRing<S, n | L> : Rng, RngIntElt, List -> AlgMat
Given a commutative ring S and a positive integer n, create the S-algebra
R consisting of the n x n matrices over the ring S generated by the
elements defined in the list L. Let F denote the algebra Mn(S).
Each term Li of the list L must be an expression defining an object of
one of the following types:
- (a)
- A sequence of n2 elements of S defining an element of F.
- (b)
- A set or sequence whose terms are sequences of type (a).
- (c)
- An element of F.
- (d)
- A set or sequence whose terms are elements of F.
- (e)
- The null list.
The generators stored for R consist of the elements specified by terms
Li together with the stored generators for subalgebras specified by terms
of Li. Repetitions of an element and occurrences of scalar matrices
are removed.
We demonstrate the use of the matrix algebra constructor by creating
an algebra of 3 x 3 lower-triangular matrices over the rational field.
> Q := RationalField();
> A := MatrixAlgebra< Q, 3 | [ 1/3,0,0, 3/2,3,0, -1/2,4,3],
> [ 3,0,0, 1/2,-5,0, 8,-1/2,4] >;
> A:Maximal;
Matrix Algebra of degree 3 with 2 generators over Rational Field
Generators:
[ 1/3 0 0]
[ 3/2 3 0]
[-1/2 4 3]
[ 3 0 0]
[ 1/2 -5 0]
[ 8 -1/2 4]
> Dimension(A);
6
We construct a 4 by 4 matrix over the finite field with 5 elements using the
CambridgeMatrix function.
> K := FiniteField(5);
> x := CambridgeMatrix(1, K, 4, [ "1234", "0111", "4321", "1211" ]);
> x;
[1 2 3 4]
[0 1 1 1]
[4 3 2 1]
[1 2 1 1]
Given a matrix algebra R, construct a structure-constant algebra C
isomorphic to R together with the isomorphism from R onto C.
The i-th defining generator for the matrix algebra R.
CoefficientRing(R) : AlgMatV -> Rng
The coefficient ring S for the matrix algebra R.
Given a matrix algebra R, return the degree n of R.
The set consisting of the defining generators for the matrix algebra R.
The complete matrix algebra Mn(S) in which the matrix algebra R is naturally embedded.
If R is a subring of the matrix algebra Mn(S), then R is considered
to act on the free S-module of rank n, consisting of n-tuples over
S. The function BaseModule returns this S-module.
Ngens(R) : AlgMat -> { AlgMatElt }
The number of defining generators for the matrix algebra R.
Given an element a belonging to the matrix algebra R, return R,
i.e. the parent structure for a.
We illustrate the use of these functions by applying them
to the algebra of 3 x 3 lower-triangular matrices over the rational
field constructed above.
> Q := RationalField();
> A := MatrixAlgebra< Q, 3 | [ 1/3,0,0, 3/2,3,0, -1/2,4,3],
> [ 3,0,0, 1/2,-5,0, 8,-1/2,4] >;
> CoefficientRing(A);
Rational Field
> Degree(A);
3
> Ngens(A);
2
> Generators(A);
{
[ 1/3 0 0]
[ 3/2 3 0]
[-1/2 4 3],
[ 3 0 0]
[ 1/2 -5 0]
[ 8 -1/2 4]
}
> Generic(A);
Full Matrix Algebra of degree 3 over Rational Field
> Dimension(A);
6
V2.29, 21 October 2025