A matrix is a special data type that contains between one and sixteen components. Every component of a matrix must be of the same type.
TypeRxC VariableName
where:
TypeRxC | Identifies the data types, and number of components in each row and column. The type is one of the basic types. The number of rows and columns is a positive integer between 1 and 4. |
VariableName | An ASCII string that uniquely identifies the variable name. |
Here are some examples:
int1x1 iMatrix; // integer matrix with 1 row, 1 column int4x1 iMatrix; // integer matrix with 4 rows, 1 column int1x4 iMatrix; // integer matrix with 1 row, 4 columns double3x3 dMatrix; // double matrix with 3 rows, 3 columns float2x2 fMatrix = { 0.0f, 0.1, // row 1 2.1f, 2.2f // row 2 };
A matrix can be declared using this syntax also:
matrix &<Type, Number> VariableName
The matrix type uses the angle brackets to specify the type, the number of rows, and the number of columns. This example creates a floating-point matrix, with two rows and two columns. Any of the scalar data types can be used.
Here is an example:
matrix &<float, 2, 2> fMatrix = { 0.0f, 0.1, // row 1 2.1f, 2.2f // row 2 };