Square MatrixΒΆ

The top level matrix type in FriCAS is Matrix, 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

Once SQMATRIX has been exposed, values can be created using the 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+      +1  0+   +
  ||        |      |    |   |
  |+%i   4  +      +0  1+   |
  |                         |
  |+ 0    %i +  + 2   - 5%i+|
  ||         |  |          ||
  ++- %i  - 3+  +5%i   17  ++
                      Type: SquareMatrix(2,SquareMatrix(2,Complex Integer))

Or you can construct a polynomial with square matrix coefficients.

p := (x + m)**2
   2   + 2   - 2%i+    + 2   - 5%i+
  x  + |          |x + |          |
       +2%i    8  +    +5%i   17  +
                      Type: Polynomial SquareMatrix(2,Complex Integer)

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

p::SquareMatrix(2, ?)
  + 2                        +
  |x  + 2x + 2  - 2%i x - 5%i|
  |                          |
  |              2           |
  +2%i x + 5%i  x  + 8x + 17 +
                      Type: SquareMatrix(2,Polynomial Complex Integer)

See Also:

  • )help Matrix
  • )show SquareMatrix

Table Of Contents

This Page