Create Matrices over Particular Rings

    Note:   Use only in the MuPAD Notebook Interface. This functionality does not run in MATLAB.

The matrix command creates a matrix over Dom::ExpressionField(). The components of such matrices can be arbitrary arithmetical expressions. Alternatively, you can create your own matrix constructor and use it to create matrices with elements in a particular ring. When operating on such matrices, most of the MuPAD® functions perform computations over the specified ring. One exception is the numeric library functions. The call Dom::Matrix(R) creates the constructor for matrices of arbitrary dimensions with the elements in the ring R. To specify the ring R, you can use the predefined rings and fields such as Dom::Integer or Dom::IntegerMod(n) or others from the Dom library. For example, define the constructor that creates matrices over the ring of integer numbers:

constructor := Dom::Matrix(Dom::Integer)

Use that constructor to produce matrices with integer elements:

A := constructor(3, 3, [[1, 2, 3], [2, 3, 1], [3, 1, 2]])

When you use the constructor to create a matrix, you must ensure that all matrix elements belong to the ring or can be converted to the elements in that ring. Otherwise, the constructor issues an error and does not create a matrix:

constructor(3, 3, [[1/3, 2, 3], [2, 3, 1], [3, 1, 2]])
Error: Cannot define a matrix over 'Dom::Integer'. [(Dom::Matrix(Dom::Integer))::new]

If you use a constructor to create a matrix over a particular ring, you cannot use that matrix in operations that create matrices with elements outside of the ring. For example, you cannot compute the inverse of the matrix A because the inverse matrix contains noninteger numbers:


Now, create the matrix containing the same elements as A, but use the constructor for matrices with rational numbers:

constructorRational := Dom::Matrix(Dom::Rational):
B := constructorRational(3, 3, [[1, 2, 3], [2, 3, 1], [3, 1, 2]])

Compute the inverse of the matrix B:


Was this topic helpful?