Matrices
FISH supports two-dimensional matrices composed of floating-point values.
Addition and multiplication of appropriately sized matrices are supported.
Matrix components can be accessed using parentheses (), using row-column order. If the matrix has a single row or column, then only one index is necessary.
Four indices can be used to specify a sub-matrix of a larger matrix. In this case the first two are the starting row and column and the last two are the ending row and column. This notation can be used to retrieve a sub-matrix from a larger matrix, or on assignment to update a part of a larger matrix.
The following example illustrates accessing matrix components using parentheses:
Matrix types are created using the matrix
library function. This function can also be used to convert lists, tensors, or arrays to matrices.
Matrices can be converted to a list, tensor, or array using the list
, tensor
, or array
library functions.
A number of additional methods, detailed in the Matrix Utilities section, are available for matrix manipulation.
These include matrix transpose, inversion, matrix determinant calculation and LU decomposition, among other operations.
The math.outer.product
performs the outer product of two vectors, returning a matrix.
Matrices are an iterable type. This means you can use it as the target of a loop foreach statement (see Loop ForEach and can be split (see Splitting). Each entry of the matrix is iterated rows first: so row 1 column 1 (1,1) followed by row 1 column 2 (1,2) followed by row 1 column 3 (1,3) etc.
As with most aggregate types, when the value is listed it will simply indicate that it is of type Matrix and give matrix size. To see the contents of the matrix use the fish list contents
command.
The example below illustrates some simple matrix manipulations.
Was this helpful? ... | Itasca Software © 2024, Itasca | Updated: Oct 31, 2024 |