Only one dimensional arrays are
supported in the Flowgorithm and
limited to the integer, real
(floats), boolean and string types.
However, two
dimensional arrays are natively required in many algorithms.
Vectors and matrices are indexed from "1" not from "0" .
This
page describes, how two dimensional matrices can be defined, used and printed.
It is recommended to understand how the Flowgorithm source files ( *.fprg
files) can be modified directly for additional libraries inclusion.
Please,
see EDITING Flowgorithm Files
(unfortunately, a library handling is not available in the current Flowgorithm version,
perhaps a specialized tool for *.fprg files will be available)
The Flowgorithm uses indexing from ZERO, i.e. the A[0], ... ,
A[N-1], which might cause some problems in mathematical formula use.
The following functionality is available (indexing
[1..N] is to be used
consistently).
In
mathematics, usually the first index is ONE, i.e. A[1] in the vector case, resp.
A[1,1] in the case of matrices
Declaration (N, M can be integer constants or variables)
Indexing
As the Flowgorithm supports one dimensional
arrays indexed from ZERO, each element of two dimensional array has to be re-indexed independently with
checking the bounds of a vector or a matrix,
e.g.
a mathematical formula k
= A[i,j] is to be rewritten as k = A[ Index ( i, j, N, M )] in the case of
matrix with integer elements.
All indexing starts from ONE, i.e. [1..N].
Vector and matrix support (indexing from "1")
The following re-indexing functions can be used for matrices; in the case of
a vector,
elements can be accessed directly by decreasing index by "1",
but without bounds detailed control.
(a vector A has N elements, a matrix
A - has N rows, M columns):
The vector case (indexing from "1")
The matrix case [2D arrays] (indexing from "1")
Printing vectors and matrices with formatting (indexing from
"1", resp. "1,1")
The Flowgorithm supports only
"non-formatted" output of one value only. However, formatted output is required in many
cases.
Also for matrix output formatting is needed to see columns.
Unfortunately, output natively uses proportional font type on the screen.
However if output is stored, a non-proportional font type, e.g. Consolas in the
Notepad, can be used.
For formatted print the following
calls can be used:
Print of a value (it is expected, that d <= length of characters printed)
Print of a vector
Print of a matrix
Operations with vectors and matrices
Solution of a linear equations