Creating Matrices
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
new 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
setelt.
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
matrix.
If the matrix is diagonal, use
diagonalMatrix
Use setRow! and
setColumn!
to change a row or column of a matrix.
Use copy 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 subMatrix(dm,2,3,2,4) to extract
part of an existing matrix. The syntax is
subMatrix(m,firstrow,lastrow,firstcol,lastcol)
To change a submatrix, use
setsubMatrix!.
If e is too big to fit where you specify, an error message is displayed. Use
subMatrix.
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 horizConcat to append them side to
side. The two matrices must have the same number of rows.
Use vertConcat to stack one upon the
other. The two matrices must have the same number of columns.
The operation transpose is used to create
a new matrix by reflection across the main diagonal.