Reference
Matrices
Guides and navigation are localized. Built-in reference descriptions and code examples are maintained in English.
| Name / Signature | Description | Returns |
|---|---|---|
| alerta.matrix.newmatrix.new(rows, columns, value) | Creates a new matrix table. A negative size, or more than 100,000 elements (Pine's collection limit), stops the script with a runtime error. | Matrix ID (string) |
| alerta.matrix.getmatrix.get(id, row, column) | Gets a value from a matrix cell. | any |
| alerta.matrix.setmatrix.set(id, row, column, value) | Sets a value in a matrix cell. | void |
| alerta.matrix.rowsmatrix.rows(id) | Gets the number of rows in a matrix. | int |
| alerta.matrix.columnsmatrix.columns(id) | Gets the number of columns in a matrix. | int |
| alerta.matrix.copymatrix.copy(id) | Creates a deep copy of a matrix. | Matrix ID (string) |
| alerta.matrix.elements_countmatrix.elements_count(id) | Returns total number of elements (rows * columns). | int |
| alerta.matrix.fillmatrix.fill(id, value, from_row?, to_row?, from_column?, to_column?) | Fills matrix elements with a value — the whole matrix, or only the [from_row,to_row)×[from_column,to_column) block when bounds are given (to_* are exclusive). | void |
| alerta.matrix.rowmatrix.row(id, row) | Returns row values as an array. | Array |
| alerta.matrix.colmatrix.col(id, column) | Returns column values as an array. | Array |
| alerta.matrix.transposematrix.transpose(id) | Returns transposed matrix. | Matrix ID (string) |
| alerta.matrix.summatrix.sum(a, b) | Element-wise sum of two matrices, or of a matrix and a number added to every element. | Matrix ID (string) |
| alerta.matrix.diffmatrix.diff(a, b) | Element-wise subtraction of two matrices, or of a number from every element. | Matrix ID (string) |
| alerta.matrix.multmatrix.mult(a, b) | Returns the matrix product. The right operand can be a matrix, a number, or an array (a column vector: the result is an array). | Matrix ID (string) |
| alerta.matrix.tracematrix.trace(id) | Returns diagonal sum for square matrices. | float |
| alerta.matrix.avgmatrix.avg(id) | Returns the arithmetic mean of all finite numeric matrix elements. | float |
| alerta.matrix.minmatrix.min(id) | Returns the smallest finite numeric matrix element. | float |
| alerta.matrix.maxmatrix.max(id) | Returns the largest finite numeric matrix element. | float |
| alerta.matrix.medianmatrix.median(id) | Returns the median of finite numeric matrix elements. `na` values are ignored. | float |
| alerta.matrix.modematrix.mode(id) | Returns the most frequent finite numeric matrix element. Ties resolve to the smallest value. | float |
| alerta.matrix.is_squarematrix.is_square(id) | Returns true if matrix has equal rows and columns. | bool |
| alerta.matrix.detmatrix.det(id) | Returns determinant for square matrices. | float |
| alerta.matrix.invmatrix.inv(id) | Returns the inverse of a square matrix, or `na` when the matrix at the current bar is singular or not square. A regression's normal-equation matrix is legitimately singular during warm-up and whenever two predictors line up, so guard the result with `if not na(inv)` rather than assuming it exists. | Matrix ID (string), or na when the matrix cannot be inverted |
| alerta.matrix.rankmatrix.rank(id) | Returns matrix rank. | int |
| alerta.matrix.pinvmatrix.pinv(id) | Returns Moore-Penrose pseudo inverse. | Matrix ID (string) |
| alerta.matrix.powmatrix.pow(id, power) | Returns a square matrix multiplied by itself `power` times. | Matrix ID (string) |
| alerta.matrix.concatmatrix.concat(a, b) | Appends the rows of the second matrix to the first (same column count) and returns the first. | Matrix ID (string) |
| alerta.matrix.submatrixmatrix.submatrix(id, fromRow, toRow, fromCol, toCol) | Returns a sliced submatrix using [from,to) ranges. | Matrix ID (string) |
| alerta.matrix.reshapematrix.reshape(id, rows, cols) | Gives the matrix a new shape in place, keeping its elements in order (rows × cols must equal the element count). | void |
| alerta.matrix.reversematrix.reverse(id) | Reverses the order of rows and columns in place: the first element becomes the last. | void |
| alerta.matrix.sortmatrix.sort(id, column?, order?) | Sorts matrix rows in place by a column. Defaults to column `0` and ascending order. | void |
| alerta.matrix.swap_rowsmatrix.swap_rows(id, a, b) | Swaps two rows in place. | void |
| alerta.matrix.swap_columnsmatrix.swap_columns(id, a, b) | Swaps two columns in place. | void |
| alerta.matrix.add_rowmatrix.add_row(id, index, rowArray) | Inserts a row from array values; without them a row of na, at the end by default. | void |
| alerta.matrix.remove_rowmatrix.remove_row(id, index) | Removes the row at index and returns its values as an array. | Array |
| alerta.matrix.add_colmatrix.add_col(id, index, colArray) | Inserts a column from array values; without them a column of na, at the end by default. | void |
| alerta.matrix.remove_colmatrix.remove_col(id, index) | Removes the column at index and returns its values as an array. | Array |
| alerta.matrix.is_identitymatrix.is_identity(id) | Returns true if matrix is identity. | bool |
| alerta.matrix.is_diagonalmatrix.is_diagonal(id) | Returns true if non-diagonal values are zero. | bool |
| alerta.matrix.is_antidiagonalmatrix.is_antidiagonal(id) | Returns true if all values outside the secondary diagonal are zero. | bool |
| alerta.matrix.is_symmetricmatrix.is_symmetric(id) | Returns true if matrix equals its transpose. | bool |
| alerta.matrix.is_zeromatrix.is_zero(id) | Returns true if all elements are zero. | bool |
| alerta.matrix.is_binarymatrix.is_binary(id) | Returns true if all values are 0 or 1. | bool |
| alerta.matrix.is_triangularmatrix.is_triangular(id) | Returns true for upper or lower triangular matrices. | bool |
| alerta.matrix.is_antisymmetricmatrix.is_antisymmetric(id) | Returns true if matrix is antisymmetric. | bool |
| alerta.matrix.is_stochasticmatrix.is_stochastic(id) | Returns true when all rows sum to 1 and elements are non-negative. | bool |
| alerta.matrix.kronmatrix.kron(a, b) | Returns Kronecker product of two matrices. | Matrix |
| alerta.matrix.eigenvaluesmatrix.eigenvalues(id) | Returns an array of eigenvalues for any NxN square matrix, in descending order. Symmetric matrices (covariance/correlation) use the Jacobi method; general matrices use QR iteration (real eigenvalues). | Array<float> (descending) |
| alerta.matrix.eigenvectorsmatrix.eigenvectors(id) | Returns an NxN matrix whose COLUMNS are the eigenvectors, column order matching matrix.eigenvalues' descending eigenvalue order. Works for any square matrix (Jacobi for symmetric, inverse iteration for general). | matrix (columns = eigenvectors) |