A matrix is sparse if most of its elements are 0. To specify a sparse matrix, it is easier to define the non-zero elements. This can be done with a table (see Section 6.43). The matrix command (see Section 6.44.4) or the convert command (see Section 6.23.26) can then turn the table into a matrix.
Example.
First, define the non-zero elements.
Input:
or:
purge(A) |
A[0..4,0..4]:=[1,2,3,4,5] |
Output:
|
This table can be converted to a matrix with either the
convert command or the matrix command.
Input:
or:
Output:
⎡ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ |
| ⎤ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ |