This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Create Matrices over Particular Rings

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

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: Unable to 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?