print matrix, echo matrix, compose matrix
Utility Library
The function print matrix takes a combination of strings resp. scalar values and matrices embedded in
sets. The output consist of mulitple rows of text where the matrices and text elements are properly aligned.
You can print out 1 or more matrices with text (e.g. variables, mathematical operators, scalrs) inbetween.
The function echo matrix adds an additional 'new line' after printing out the matrix.
The function compose matrix does not print out, but provides the resulting text lines in the return value.
Under normal conditions, the 'Utility Library' is loaded automatically, so no 'include(...)' call is needed.
Min 4
No. | Type | Description |
---|---|---|
1. input |
string | Number format This number format is used to output numerals. See Numeral to String Formatting Parameters. Keep blank for generic output of numbers.
The number format will not be used for other types, e.g. dates and strings. The matrix will appear wider if numbers with many digits are printed out.
|
2. input |
numeral | Element length This is the minimum width of every matrix element. The field with the longest contents will widen the columns so no contents need to be truncated.. |
3. input |
string | Separator line Typically, use a vertical line, or for nicer formatting add one space before and behind the vertical line. Other symbols such as spaces are also useful. |
4,... input |
valid types | Contents Numerals, strings, date, Booleans, etc. are treated as text and scalers which can be used to create formulas consisting
of both matrices and formula elements, for example constants, variables and operators.
|
Type | Description |
---|---|
set | Matrix Every element in the set contains one line of text. |
matrix 1[] = { { 1,20,300 }, {4, 50, 600}, {700, 8, 9} };
matrix 2[] = { 10, 20, 30, 40 };
matrix 3[] = horizontal( { 5, 10, 15, 20 } );
matrix 4[] = vertical( {100,200,300,400} );
echo matrix( "0.00", 6, " | ", "A = ",
matrix 1[], "+", matrix 2[], ", ", matrix 3[], " and ", matrix 4[] );
o[] = compose matrix( "0.00", 6, " | ", "A = ",
matrix 1[], "+", matrix 2[], ", ", matrix 3[], " and ", matrix 4[] );
echo("Alternative way to print the matrix:", new line, join( o[], new line ));
| 10.00 | | 100.00 |
| 1.00 20.00 300.00 | | 20.00 | | 200.00 |
A = | 4.00 50.00 600.00 | + | 30.00 | , | 5.00 10.00 15.00 20.00 | and | 300.00 |
| 700.00 8.00 9.00 | | 40.00 | | 400.00 |
Alternative way to print the matrix:
| 10.00 | | 100.00 |
| 1.00 20.00 300.00 | | 20.00 | | 200.00 |
A = | 4.00 50.00 600.00 | + | 30.00 | , | 5.00 10.00 15.00 20.00 | and | 300.00 |
| 700.00 8.00 9.00 | | 40.00 | | 400.00 |