]>
The Matrix domain provides arithmetic operations on matrices and standard functions from linear algebra. This domain is similar to the TwoDimensionalArray domain, except that the entries for Matrix must belong to a Ring.
There are many ways to create a matrix from a collection of values or from existing matrices.
If the matrix has almost all items equal to the same value, use newnewMatrix to create a matrix filled with that value and then reset the entries that are different.
To change the entry in the second row, third column to 5, use seteltseteltMatrix.
An alternative syntax is to use assignment.
The matrix was destructively modified.
If you already have the matrix entries as a list of lists, use matrixmatrixMatrix.
If the matrix is diagonal, use diagonalMatrixdiagonalMatrixMatrix.
Use setRowsetRowMatrix and setColumnsetColumnMatrix to change a row or column of a matrix.
Use copycopyMatrix to make a copy of a matrix.
This is useful if you intend to modify a matrix destructively but want a copy of the original.
Use subMatrixsubMatrixMatrix to extract part of an existing matrix. The syntax is subMatrix(m, firstrow, lastrow, firstcol, lastcol).
To change a submatrix, use setsubMatrixsetsubMatrixMatrix.
If e is too big to fit where you specify, an error message is displayed. Use subMatrixsubMatrixMatrix to extract part of e, if necessary.
This changes the submatrix of d whose upper left corner is at the first row and second column and whose size is that of e.
Matrices can be joined either horizontally or vertically to make new matrices.
Use horizConcathorizConcatMatrix to append them side to side. The two matrices must have the same number of rows.
Use vertConcatvertConcatMatrix to stack one upon the other. The two matrices must have the same number of columns.
The operation transposetransposeMatrix is used to create a new matrix by reflection across the main diagonal.
Axiom provides both left and right scalar multiplication.
You can add, subtract, and multiply matrices provided, of course, that the matrices have compatible dimensions. If not, an error message is displayed.
This following product is defined but n * m is not.
The operations nrowsnrowsMatrix and ncolsncolsMatrix return the number of rows and columns of a matrix. You can extract a row or a column of a matrix using the operations rowrowMatrix and columncolumnMatrix. The object returned is a Vector.
Here is the third column of the matrix n.
You can multiply a matrix on the left by a ``row vector'' and on the right by a ``column vector.''
Of course, the dimensions of the vector and the matrix must be compatible or an error message is returned.
The operation inverseinverseMatrix computes the inverse of a matrix if the matrix is invertible, and returns "failed" if not.
This Hilbert matrix is invertible.
This matrix is not invertible.
The operation determinantdeterminantMatrix computes the determinant of a matrix provided that the entries of the matrix belong to a CommutativeRing.
The above matrix mm is not invertible and, hence, must have determinant 0.
The operation tracetraceSquareMatrix computes the trace of a square matrix.
The operation rankrankMatrix computes the rank of a matrix: the maximal number of linearly independent rows or columns.
The operation nullitynullityMatrix computes the nullity of a matrix: the dimension of its null space.
The operation nullSpacenullSpaceMatrix returns a list containing a basis for the null space of a matrix. Note that the nullity is the number of elements in a basis for the null space.
The operation rowEchelonrowEchelonMatrix returns the row echelon form of a matrix. It is easy to see that the rank of this matrix is two and that its nullity is also two.
For more information on related topics, see ugIntroTwoDimPage in Section ugIntroTwoDimNumber , ugProblemEigenPage in Section ugProblemEigenNumber , ugxFloatHilbertPage in Section ugxFloatHilbertNumber , PermanentXmpPage , VectorXmpPage , OneDimensionalArrayXmpPage , and TwoDimensionalArrayXmpPage .