|
Description
|
|
•
|
There are four ways to construct a Matrix in Maple. Which method you use depends on your data and needs. The following are some guidelines on when to use which method.
|
1.
|
Use the Matrix construction shortcuts to quickly construct a Matrix with a small number of elements.
|
2.
|
Use the Matrix palette to specify the initial type and shape for the Matrix as well as its data type.
|
3.
|
Use the Matrix function to access more initialization options (for example, using a procedure or lists as initializers) and options that maximize the efficiency of reading from the Matrix, storing the Matrix, or both.
|
4.
|
Use the ImportMatrix function to import data stored in a file into a Matrix.
|
|
|
Using the Matrix construction shortcuts
|
|
•
|
Use a pair of matching angle brackets (< >) to enclose the comma-separated values of the Matrix elements.
|
•
|
To have sequences of comma-separated values define the rows of your Matrix, separate the rows with a semicolon (;).
|
>
|
Matrix1 := <a , b , c ; d , e , f>;
|
•
|
To have sequences of comma-separated values define the columns of your Matrix, separate the columns with a vertical bar (|).
|
>
|
Matrix2 := <a , b , c | d , e , f>;
|
•
|
Vectors and Matrices can be used for the elements of a Matrix. The type of Vector (that is, row or column) determines whether the Vectors are interpreted as rows or columns in the Matrix.
|
•
|
Use either a comma or a semicolon to separate the rows of the Matrix when the elements are row Vectors.
|
>
|
RowVector1 := <1 | 2 | 3>;
|
>
|
RowVector2 := <4 | 5 | 6>;
|
>
|
Matrix3 := <RowVector1; RowVector2>;
|
•
|
Use the vertical bar (|) to separate the columns of the Matrix when the elements are column Vectors.
|
>
|
ColumnVector1 := <7, 8, 9>;
|
>
|
ColumnVector2 := <10, 11, 12>;
|
>
|
Matrix4 := <ColumnVector1 | ColumnVector2>;
|
•
|
You can also concatenate a Matrix with Vectors and other Matrices to create a new Matrix. The same separators apply (vertical bar to append columns and either a comma or semicolon to append rows).
|
>
|
Matrix5 := <Matrix4 | <13, 14, 15>>;
|
| (9) |
>
|
Matrix6 := <Matrix3, <7 | 8 | 9>>;
|
| (11) |
|
|
Using the Matrix palette
|
|
•
|
If you are using the standard worksheet interface, the Matrix palette can be used to specify additional properties for a Matrix.
|
•
|
The following are the additional properties that you can specify with the Matrix palette.
|
Type: Specify the initial Matrix type. Select from Custom Values, Zero-filled, One-filled, Identity, or Random.
Shape: Specify the initial shape of the Matrix (for example, Diagonal, Hermitian, or Symmetric). See shape for more information on these choices.
Data type: Specify the type of data stored in the Matrix. The available choices are: Any, float[8], integer[1], integer[2], integer[4], integer[8], and complex[8].
|
|
Using the Matrix function
|
|
•
|
The Matrix function gives you access to a wider variety of initializer options. These options include using a procedure to define the Matrix elements
|
>
|
f:= (i,j) -> z^(i+j-1):
|
as well as other objects like lists and Arrays.
>
|
M := Matrix([[1, -1, 0], [1, 1, 0], [0, 0, 1]]);
|
>
|
A := Array(0..2, 0..1, {(0, 0) = 1, (0, 1) = 2, (1, 0) = 3, (1, 1) = 4, (2, 0) = 5, (2, 1) = 6 } );
|
The storage and shape options can be used to save memory when not all of the elements of a Matrix need to be stored. For example, not all of the elements of a symmetric Matrix need to be stored in memory. Using the storage=triangular[lower] and shape=symmetric options in the following command is more efficient because only six elements are needed to define the Matrix.
>
|
sym := Matrix([[1], [2, 3], [4, 5, 6]], storage=triangular[lower], shape=symmetric );
|
For more information on these and other options, see the Matrix command page.
|
|
Using the ImportMatrix function
|
|
The ImportMatrix function reads data from a file to construct and initialize a Matrix.
You can import Matrices from numerous formats, including:
•
|
Comma-Separated Values (CSV)
|
For more information, see ImportMatrix.
|
|
|