Matrix spaces

A matrix space represents the collection of all matrices with a fixed number of rows and columns over a fixed base ring. Matrix spaces are parent objects; their elements are the corresponding algebraic matrices.

Creating matrix spaces

AbstractAlgebra.matrix_spaceMethod
matrix_space(R::NCRing, r::Int, c::Int)

Return the space of $r \times c$ matrices over the ring R.

The returned object is the parent object for matrices with r rows and c columns whose entries belong to R.

Examples

julia> R, t = polynomial_ring(QQ, :t)
(Univariate polynomial ring in t over rationals, t)

julia> S = matrix_space(R, 2, 3)
Matrix space of 2 rows and 3 columns
  over univariate polynomial ring in t over rationals
source

Properties of matrix spaces

AbstractAlgebra.number_of_rowsMethod
number_of_rows(s::MatSpace)

Return the number of rows of the matrices in the matrix space s.

Examples

julia> S = matrix_space(QQ, 2, 3)
Matrix space of 2 rows and 3 columns
  over rationals

julia> number_of_rows(S)
2
source
AbstractAlgebra.number_of_columnsMethod
number_of_columns(s::MatSpace)

Return the number of columns of the matrices in the matrix space s.

Examples

julia> S = matrix_space(QQ, 2, 3)
Matrix space of 2 rows and 3 columns
  over rationals

julia> number_of_columns(S)
3
source

The base ring and the vector space dimension of the matrix space can be queried with base_space and vector_space_dim, respectively.

Creating elements of a matrix space

Calling a matrix space

AbstractAlgebra.MatSpaceType
(S::MatSpace{T})() where {T <: NCRingElement}
(S::MatSpace)(a::NCRingElement)
(S::MatSpace{T})(a::MatrixElem{T}) where {T <: NCRingElement}
(S::MatSpace{T})(a::AbstractVecOrMat) where {T <: NCRingElement}

Construct an element of the matrix space S.

The call S() returns the zero matrix in s.

If a is a ring element coercible into the base ring of S, then S(a) returns the diagonal matrix in S whose diagonal entries are a.

If a is an algebraic matrix whose dimensions and base ring agree with those of S, then S(a) returns the corresponding element of S. If necessary, a new matrix with the appropriate implementation type is constructed.

If a is a Julia vector or matrix, then S(a) constructs an element of S whose entries are obtained by coercing the entries of a into the base ring of S. The entries are interpreted in row-major order and must have length nrows(S) * ncols(S).

Examples

julia> R, t = polynomial_ring(QQ, :t)
(Univariate polynomial ring in t over rationals, t)

julia> S = matrix_space(R, 3, 3)
Matrix space of 3 rows and 3 columns
  over univariate polynomial ring in t over rationals

julia> S()
[0   0   0]
[0   0   0]
[0   0   0]

julia> S(12)
[12    0    0]
[ 0   12    0]
[ 0    0   12]

julia> S(zero_matrix(R, 3, 3))
[0   0   0]
[0   0   0]
[0   0   0]

julia> S(BigInt[2 3 1; 1 0 4; 0 0 1])
[2   3   1]
[1   0   4]
[0   0   1]
source

Special elements

Base.zeroMethod
zero(s::MatSpace)

Return the zero matrix in the matrix space s.

Examples

julia> S = matrix_space(QQ, 2, 3)
Matrix space of 2 rows and 3 columns
  over rationals

julia> zero(S)
[0//1   0//1   0//1]
[0//1   0//1   0//1]
source
Base.oneMethod
one(s::MatSpace)

Return the identity matrix in the matrix space s.

The matrix space s must contain square matrices.

Examples

julia> S = matrix_space(QQ, 3, 3)
Matrix space of 3 rows and 3 columns
  over rationals

julia> one(S)
[1//1   0//1   0//1]
[0//1   1//1   0//1]
[0//1   0//1   1//1]
source

Recovering the parent object

Base.parentMethod
parent(M::MatElem)

Return the matrix space over the base ring of M with the same dimensions as M.

Examples

julia> M = matrix(QQ, [1 2 3; 4 5 6])
[1//1   2//1   3//1]
[4//1   5//1   6//1]

julia> parent(M)
Matrix space of 2 rows and 3 columns
  over rationals
source