9.74 SquareMatrix

The top level matrix type in FriCAS 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 squareMatrixsquareMatrixSquareMatrix function.

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

Type: SquareMatrix(2,Complex Integer)

The usual arithmetic operations are available.

m*m - m

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] ]

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

Or you can construct a polynomial with square matrix coefficients.

p := (x + m)^2

Type: Polynomial SquareMatrix(2,Complex Integer)

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

p::SquareMatrix(2, ?)

Type: SquareMatrix(2,Polynomial Complex Integer)

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