Rings of square matrices
Dom::SquareMatrix(n
, <R
>)
Dom::SquareMatrix(n, R)(Array
)
Dom::SquareMatrix(n, R)(Matrix
)
Dom::SquareMatrix(n, R)(<n, n
>)
Dom::SquareMatrix(n, R)(<n, n
>,ListOfRows
)
Dom::SquareMatrix(n, R)(<n, n
>,f
)
Dom::SquareMatrix(n, R)(<n, n
>,List
, <Diagonal>)
Dom::SquareMatrix(n, R)(<n, n
>,g
, <Diagonal>)
Dom::SquareMatrix(n, R)(<n, n
>,List
, <Banded>)
Dom::SquareMatrix(n, R)
creates a domain
which represents the ring of n×n matrices
over a component domain R
. The domain R
must
be of category Cat::Rng
(a
ring, possibly without unit).
If the optional parameter R
is not given,
the domain Dom::ExpressionField()
is used as the
component ring for the square matrices.
For matrices of a domain created by Dom::SquareMatrix(n,
R)
, standard matrix arithmetic is implemented by overloading
the standard arithmetical operators +, , *, /
and ^
.
All functions of the linalg
package dealing with
matrices can also be applied.
Dom::SquareMatrix(n, R)
has the domain Dom::Matrix(R)
as
its super domain, i.e., it inherits each method which is defined by Dom::Matrix(R)
and
not reimplemented by Dom::SquareMatrix(n, R)
.
Methods described below are reimplemented by Dom::SquareMatrix
.
The domain Dom::Matrix(R)
represents matrices
over R
of arbitrary size, and it therefore does
not have any algebraic structure (except of being a set of
matrices).
The domain Dom::MatrixGroup(m, n, R)
represents
the Abelian group of m×n matrices
over R.
Dom::SquareMatrix(n, R)(Array)
and Dom::SquareMatrix(n,
R)(Matrix)
create a new matrix formed by the entries of Array
and Matrix
,
respectively.
The components of Array
and Matrix
,
respectively, are converted into elements of the domain R
.
An error message is issued if one of these conversions fails.
The call Dom::SquareMatrix(n, R)( n , n )
returns
the n×n zero
matrix. Note that the n×n zero
matrix is also defined by the entry "zero"
(see
below).
Dom::SquareMatrix(n, R)( n , n ListOfRows)
creates
an n×n matrix
with components taken from the nested list ListOfRows
.
Each inner list corresponds to a row of the matrix.
If an inner list has less than n
entries,
the remaining components in the corresponding row of the matrix are
set to zero. If there are less than n
inner lists,
the remaining lower rows of the matrix are filled with zeroes.
The entries of the inner lists are converted into elements of
the domain R
. An error message is issued if one
of these conversions fails.
It might be a good idea first to create a twodimensional array from that list before calling Dom::SquareMatrix(n,
R)
. This is due to the fact that creating a matrix from
an array is the fastest way one can achieve. However, in this case
the sublists must have the same number of elements.
Dom::SquareMatrix(n, R)( n , n f)
returns
the matrix whose (i, j)th
component is the value of the function call f(i, j)
.
The row and column indices i and j range
from 1 to n
.
The function values are converted into elements of the domain R
.
An error message is issued if one of these conversions fails.
Dom::Matrix
(R)
If R
has Ax::canonicalRep
, then Ax::canonicalRep
.
A lot of examples can be found on the help page of the domain
constructor Dom::Matrix
,
and most of them are also examples for working with domains created
by Dom::SquareMatrix
.
These examples only concentrate on some differences with respect
to working with matrices of the domain Dom::Matrix(R)
.
The following command defines the ring of twodimensional matrices over the rationals:
SqMatQ := Dom::SquareMatrix(2, Dom::Rational)
SqMatQ::hasProp(Cat::Ring)
The unit is defined by the entry "one"
, which
is the 2×2 identity
matrix:
SqMatQ::one
Note that some operations defined by the domain SqMatQ
return
matrices which are no longer square. They return therefore matrices
of the domain Dom::Matrix(Dom::Rational)
, the superdomain
of SqMatQ
. For example, if we delete the first
row of the matrix:
A := SqMatQ([[1, 2], [5, 3]])
we get the matrix:
SqMatQ::delRow(A, 1)
which is of the domain type:
domtype(%)
We can convert a square matrix into or from another matrix domain, as shown next:
SqMatR := Dom::SquareMatrix(3, Dom::Real): MatC := Dom::Matrix(Dom::Complex):
A := SqMatR((i, j) > sin(i*j))
To convert A
into a matrix of the domain MatC
,
enter:
coerce(A, MatC)
domtype(%)
The conversion is done componentwise, as the following examples shows:
B := MatC([[0, 1], [exp(I), 0]])
The matrix B is
square but has one complex component and therefore cannot be converted
into the domain SqMatR
:
coerce(B, SqMatR)

A positive integer 

A ring, i.e., a domain of category 

An n×n array 

An n×n matrix,
i.e., an element of a domain of category 

A list of matrix components 

A list of at most 

A function or a functional expression with two parameters (the row and column index) 

A function or a functional expression with one parameter (the row index) 

Create a diagonal matrix With the option
The entries of
The function values are converted into elements of the domain 

Create a banded Toeplitz matrix
All elements of the main diagonal of the created matrix are
initialized with the middle element of The entries of 
"one"  is the n×n identity
matrix. This entry exists if the component ring 
"randomDimen"  is set to 
"zero"  is the n×n zero matrix. 