]>
Book Contents Previous Section 9.73 SparseTable Next Section 9.75 SquareFreeRegularTriangularSet Book Index

## 9.74 SquareMatrix

The top level matrix type in Axiom is Matrix (see MatrixXmpPage ), which provides basic arithmetic and linear algebra functions. However, since the matrices can be of any size it is not true that any pair can be added or multiplied. Thus Matrix has little algebraic structure. Sometimes you want to use matrices as coefficients for polynomials or in other algebraic contexts. In this case, SquareMatrix should be used. The domain SquareMatrix(n,R) gives the ring of n by n square matrices over R. Since SquareMatrix is not normally exposed at the top level, you must expose it before it can be used.

)set expose add constructor SquareMatrix
SquareMatrix is now explicitly exposed in frame G82322

Once SQMATRIX has been exposed, values can be created using the squareMatrix squareMatrix SquareMatrix function.

m := squareMatrix [ [1,-%i],[%i,4] ]

[1-i i 4]

Type: SquareMatrix(2,Complex Integer)

The usual arithmetic operations are available.

m*m - m

[1-4 i 4 i 13]

Type: SquareMatrix(2,Complex Integer)

Square matrices can be used where ring elements are required. For example, here is a matrix with matrix entries.

mm := squareMatrix [ [m, 1], [1-m, m**2] ]

[[1-i i 4][1 0 0 1][0 i-i-3][2-5 i 5 i 17]]

Type: SquareMatrix(2,SquareMatrix(2,Complex Integer))

Or you can construct a polynomial with square matrix coefficients.

p := (x + m)**2

x 2+[2-2 i 2 i 8]x+[2-5 i 5 i 17]

Type: Polynomial SquareMatrix(2,Complex Integer)

This value can be converted to a square matrix with polynomial coefficients.

p::SquareMatrix(2, ?)

[x 2+2 x+2-2 i x-5 i 2 i x+5 i x 2+8 x+17]

Type: SquareMatrix(2,Polynomial Complex Integer)

For more information on related topics, see ugTypesWritingModesPage in Section ugTypesWritingModesNumber , ugTypesExposePage in Section ugTypesExposeNumber , and MatrixXmpPage .

Book Contents Previous Section 9.73 SparseTable Next Section 9.75 SquareFreeRegularTriangularSet Book Index