Prints matrix contents to the Experts log.
void matrix::Print(
|
Parameters
flags
[in] Flags for controlling matrix output to the log.
format_string
[in] String for formatting numbers if the MATRIX_PRINT_USE_FORMATSTRING flag is set.
Return Value
The method returns no value. In case of failure (uninitialized matrix, empty format string, invalid format string), an error is raised. The error code can be obtained using GetLastError().
Flags can be combinations of the following values:
Flag |
Value |
Description |
|---|---|---|
MATRIX_PRINT_USE_FORMATSTRING |
0x0001 |
Use a format string when outputting a matrix element |
MATRIX_PRINT_INFO |
0x0002 |
Print matrix information in the first line: class, type and dimensions |
MATRIX_PRINT_INDEXES |
0x0004 |
Print row and column indexes |
MATRIX_PRINT_FULL |
0x0008 |
Print the entire matrix to the log without any truncation |
MATRIX_PRINT_PARTIAL_LEFT |
0x0010 |
Print the left part of the matrix to the log |
MATRIX_PRINT_PARTIAL_RIGHT |
0x0020 |
Print the right part of the matrix to the log |
MATRIX_PRINT_PARTIAL_TOP |
0x0040 |
Print the upper part of the matrix to the log |
MATRIX_PRINT_PARTIAL_BOTTOM |
0x0080 |
Print the lower part of the matrix to the log |
MATRIX_PRINT_PARTIAL |
(MATRIX_PRINT_PARTIAL_LEFT | MATRIX_PRINT_PARTIAL_RIGHT | MATRIX_PRINT_PARTIAL_TOP | MATRIX_PRINT_PARTIAL_BOTTOM) |
Print the specified parts of the matrix to the log |
Note
Matrices with no more than 50 rows and with columns that fit into a buffer shorter than 512 characters are printed to the log completely, without truncation. For example, a 50 x 21 matrix will be printed without truncation when no formatting is used. A 50 x 56 matrix with elements in the range from 0 to 1 and the "%.5f" format string will also be printed without truncation. To guarantee that the matrix is printed to the log without truncation, use the MATRIX_PRINT_FULL flag.
Examples:
An ill-conditioned matrix with a value range spanning more than 50 orders of magnitude:
matrix matrix_a(5,10);
|
The first Print call with default parameters:
[[ 0.5590638740824219, -0.18868502909054163, 0.5922359152678949, 0.8639735974986045, -0.7719553713155807, -0.815408580893513, 0.7818219973197724, -0.728249088332115, -0.7753896945564518, 0.5773408984712654] |
The second Print call with indexes and formatting:
0 1 2 3 4 5 6 7 8 9
|
Example with matrix information output:
matrix matrix_t=(matrix::Random(5,5)).TriL();
|
Printing a lower triangular matrix:
lower triangular matrix TYPE_MATRIXD rows=5 cols=5
|
Examples with partial output:
matrix matrix_c=matrix::Random(100,56);
|
The upper-left part of the matrix is printed to the log:
general matrix TYPE_MATRIXD rows=100 cols=56
|
Another example:
matrix matrix_c=matrix::Random(100,56);
|
Partial output of the left part of the matrix:
general matrix TYPE_MATRIXD rows=100 cols=56
|
Another example:
matrix matrix_c=matrix::Random(100,56);
|
Partial output of the lower part of the matrix:
general matrix TYPE_MATRIXD rows=100 cols=56
|
The partial output size is 5 rows and 5 columns. This is the default value.
The number of output rows and columns can be controlled using flags. The flags parameter is of the ulong. type. The lower half is reserved for the flags themselves. The upper half (two 16-bit words) can store the number of rows and columns.
matrix matrix_c=matrix::Random(100,56);
|
Partial output of 4 matrix parts with 7 rows and 4 columns:
general matrix TYPE_MATRIXD rows=100 cols=56
|