Errors
@teakit/matrix matches ml-matrix: it throws native Error / TypeError /
RangeError. There are no stable error codes — match on the error type (and
message if needed).
Common cases:
- Construction:
new Matrix(...)throwsTypeErrorfor a non-2D-array / 1D array ("Data must be a 2D array…"), a negative size ("nColumns must be a positive integer"), or non-numeric data;RangeErrorfor inconsistent row lengths ("Inconsistent array dimensions"). - Index access:
get/set/row/columnhelpers throwRangeErrorwhen an index is out of range; row/column index helpers validate the index. - Dimension mismatch: element-wise matrix ops (
add/sub/… with a matrix operand) throwRangeError("Matrices dimensions must be equal");mmulrequiresa.columns === b.rows. - Square-only operations:
determinant,mpow, etc. throw when the matrix is not square;mpowalso requires a non-negative integer exponent. - Decompositions:
CholeskyDecompositionthrows if the input is not symmetric, and itssolvethrows if not positive-definite;LuDecomposition. solvethrows on a singular matrix;QrDecomposition.solvethrows when rank-deficient. - Special matrices:
SymmetricMatrixthrowsTypeErrorfor non-symmetric data;DistanceMatrixthrows if the data is not a valid distance matrix;applyMaskthrowsRangeErroron a mask size mismatch. - Wrappers:
wrapthrows if the argument is not an array;WrapperMatrix1Dthrows if the data length is not divisible byrows.