Matrix
A rectangular two-dimensional matrix of scalar Expression elements.
Construction validates that all nonempty rows have the same length and converts every entry to an Expression; nested parser aggregates are not matrix elements. Existing Expression entries are retained, so use copy when independent element objects are required.
`copy`, evaluate, and expand return deep independent matrices. Addition, subtraction, and division remain element-wise. times implements scalar scaling, matrix multiplication, and matrix-vector multiplication, while pow implements integer matrix powers. Scalar and matrix products return new Matrices; a matrix-vector product returns a new Vector. each, set, and parser assignment mutate this matrix. Direct
`get`/
`set`indices are zero-based. The compatibility accessor e and the row/col helpers are one-based. Matrix comparisons are component-wise predicates, not a total or lexicographic ordering; a type or dimension mismatch compares false.
Members
__get__(indices: number[]): ParserEntityMethodReturns a row at the given zero-based index as a Vector. Used by the parser for bracket indexing, e.g. matrix[0] returns the first row. This enables chained indexing: matrix[0][1] returns the element at row 0, col 1.
MathError If either index is out of bounds.
Parameters
| Name | Type | Description |
|---|---|---|
indices | number[] | Zero-based indices (after INDEX_BASE adjustment). Single index [i] returns row i as a Vector. Two indices [i, j] returns the element at row i, col j. |
Returns
ParserEntity — A copied row Vector for one index, or the stored Expression for two.
__set__(indices: string | number[], value: ParserEntity): voidMethodSets a zero-based cell or replaces an entire row. [i, j] sets the element at row i, col j. [i] requires a Vector whose length matches the matrix column count.
UnexpectedDataType If a full-row assignment does not receive a Vector.
MathError If an index is out of bounds or a replacement row has the wrong length.
Parameters
| Name | Type | Description |
|---|---|---|
indices | string | number[] | Zero-based indices |
value | ParserEntity | The value to set |
Returns
void
abs(): MatrixMethodNo description is available yet.
Returns
Returns the horizontal augmentation
`[this | matrix]`without mutating either input.
MathError If the row counts differ.
Parameters
| Name | Type | Description |
|---|---|---|
matrix | Matrix | — |
Returns
canMultiplyFromLeft(M: Matrix): booleanMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
M | Matrix | — |
Returns
boolean
col(n: number): MatrixMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
n | number | — |
Returns
cols(): numberMethodNo description is available yet.
Returns
number
Matrix(...elements: Vector | NerdamerInput[][]): MatrixConstructorCreates a matrix from array or Vector rows.
MathError If nonempty rows have different lengths.
UnexpectedDataType If an entry cannot be converted to an Expression.
Parameters
| Name | Type | Description |
|---|---|---|
elements | Vector | NerdamerInput[][] | Rows containing values convertible to scalar Expressions. |
Returns
copy(): MatrixMethodCopies the matrix and every Expression element.
Returns
dataType: "MAT"PropertyNo description is available yet.
determinant(): ExpressionMethodComputes the determinant by triangular elimination. The determinant of the empty matrix is one.
UnsupportedOperationError If the matrix is not square.
Returns
diff(variable?: ExpressionInput, n?: number | Expression): MatrixMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
variable | ExpressionInput | — |
n | number | Expression | — |
Returns
dimensions(): number[]MethodNo description is available yet.
Returns
number[]
dimensionsMatch(M: StructuredEntityType): MMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
M | StructuredEntityType | — |
Returns
M
div(x: NerdamerInput): MatrixMethodDivides corresponding entries, or broadcasts a scalar divisor.
DimensionError If a Matrix divisor has different dimensions.
Parameters
| Name | Type | Description |
|---|---|---|
x | NerdamerInput | — |
Returns
e(i: number, j: number): ExpressionMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
i | number | — |
j | number | — |
Returns
each(fn: (e: Expression, i?: string | number, j?: string | number): Expression): MatrixMethodReplaces every element with the callback result, mutating this matrix. Callback row and column indices are zero-based.
Parameters
| Name | Type | Description |
|---|---|---|
fn | (e: Expression, i?: string | number, j?: string | number): Expression | — |
Returns
elements: Expression[][]PropertyNo description is available yet.
eq(M: ParserEntity): booleanMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
M | ParserEntity | — |
Returns
boolean
evaluate(): MatrixMethodEvaluates a copied matrix, resolving symbolic cell access when values are supplied.
Parameters
| Name | Type | Description |
|---|---|---|
values | ParserValuesObject | — |
Returns
expand(): MatrixMethodExpands a copied matrix, leaving this one unchanged.
Returns
factor(): MatrixMethodNo description is available yet.
Returns
fill(rows: number, cols: number, value: Expression): MatrixMethodCreates a matrix whose cells are independent copies of
`value`.
Parameters
| Name | Type | Description |
|---|---|---|
rows | number | — |
cols | number | — |
value | Expression | — |
Returns
get(row: number, col: number): ExpressionMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
row | number | — |
col | number | — |
Returns
gt(M: ParserEntity): booleanMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
M | ParserEntity | — |
Returns
boolean
gte(M: ParserEntity): booleanMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
M | ParserEntity | — |
Returns
boolean
identity(n: number): MatrixMethodCreates the
`n`by
`n`identity matrix.
Parameters
| Name | Type | Description |
|---|---|---|
n | number | — |
Returns
inspect(): stringMethodNo description is available yet.
Returns
string
integrate(variable?: ExpressionInput): MatrixMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
variable | ExpressionInput | — |
Returns
inverse(): MatrixMethodComputes an inverse by augmenting with the identity and eliminating rows.
UnsupportedOperationError If the matrix is not square.
MathError If the matrix is singular.
Returns
Matrix — A new inverse matrix; this matrix is unchanged.
isEnumerable: booleanPropertyNo description is available yet.
isMatrix(obj: unknown): objMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
obj | unknown | — |
Returns
obj
isSingular(): booleanMethodNo description is available yet.
Returns
boolean
isSquare(): booleanMethodNo description is available yet.
Returns
boolean
lt(M: ParserEntity): booleanMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
M | ParserEntity | — |
Returns
boolean
lte(M: ParserEntity): booleanMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
M | ParserEntity | — |
Returns
boolean
map(callback: (a: Expression, row?: string | number, col?: string | number): Expression): MatrixMethodReturns a new matrix populated by callback results without mutating this matrix.
Parameters
| Name | Type | Description |
|---|---|---|
callback | (a: Expression, row?: string | number, col?: string | number): Expression | — |
Returns
minus(x: NerdamerInput): MatrixMethodSubtracts corresponding entries, or broadcasts a scalar subtrahend.
DimensionError If a Matrix operand has different dimensions.
Parameters
| Name | Type | Description |
|---|---|---|
x | NerdamerInput | — |
Returns
multiply(x: Expression): MatrixMethodDelegates the public multiplication alias to the Matrix-specific times() contract.
Parameters
| Name | Type | Description |
|---|---|---|
x | Expression | — |
Returns
nullspace(prime?: string | number | Expression): Expression[][]MethodComputes a basis for the nullspace using the same reduced row-echelon form as rref.
Without
`prime`, the basis is computed with exact symbolic Expression arithmetic. When
`prime`is supplied, the existing modular arithmetic path is preserved and basis entries are reduced modulo that value. Each free column contributes one basis vector, ordered by increasing free-column index. A full-column-rank matrix therefore returns an empty basis.
Parameters
| Name | Type | Description |
|---|---|---|
prime | string | number | Expression | Optional modulus for finite-field nullspace arithmetic. |
Returns
Expression[][] — Basis vectors as independent Expression arrays ordered by matrix column.
plus(x: NerdamerInput): MatrixMethodAdds corresponding entries, or broadcasts a scalar addend.
DimensionError If a Matrix operand has different dimensions.
Parameters
| Name | Type | Description |
|---|---|---|
x | NerdamerInput | — |
Returns
pow(x: NerdamerInput): MatrixMethodRaises this matrix to an integer power without mutating it. Positive powers use matrix multiplication, zero returns the identity, and negative powers use the matrix inverse. A rectangular matrix is accepted only for the identity power
`1`; all other matrix powers require a square matrix.
UnsupportedOperationError If the exponent is not an integer, or if a nontrivial power is requested for a rectangular matrix.
MathError If a negative power requires the inverse of a singular matrix.
Parameters
| Name | Type | Description |
|---|---|---|
x | NerdamerInput | — |
Returns
precision: numberPropertyNo description is available yet.
rank(): numberMethodNo description is available yet.
Returns
number
row(n: number): MatrixMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
n | number | — |
Returns
rows(): numberMethodNo description is available yet.
Returns
number
rref(prime?: string | number | Expression): MatrixMethodReturns reduced row-echelon form without mutating this matrix. When
`prime`is supplied, pivot arithmetic is performed modulo that value. Otherwise pivots and zero rows are determined by exact Expression equality.
Parameters
| Name | Type | Description |
|---|---|---|
prime | string | number | Expression | — |
Returns
set(row: number, col: number, value: ParserEntity): thisMethodSets a zero-based cell after converting
`value`to an Expression.
Parameters
| Name | Type | Description |
|---|---|---|
row | number | — |
col | number | — |
value | ParserEntity | — |
Returns
this
simplify(): MatrixMethodNo description is available yet.
Returns
subst(value: ExpressionInput, withValue: ExpressionInput): MatrixMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
value | ExpressionInput | — |
withValue | ExpressionInput | — |
Returns
symbolicAccessor: Expression[]PropertyPublic index expressions retained when bracket access cannot yet be resolved. This state belongs to a copied structured entity, never the stored source value.
symbolicTarget: ExpressionPropertyOriginal symbolic target used to render and later re-evaluate bracket access.
text(): stringMethodNo description is available yet.
Returns
string
times(M: Expression): MatrixMethodReturns scalar multiplication, the matrix product
`this * M`, or the matrix-vector product
`this * v`.
MathError If matrix or vector dimensions are incompatible.
UnsupportedOperationError If the operand is not a supported scalar, Matrix, or Vector.
Parameters
| Name | Type | Description |
|---|---|---|
M | Expression | — |
Returns
toRightTriangular(): MatrixMethodReturns a row-echelon copy produced by forward elimination and row swaps.
Returns
toString(): stringMethodNo description is available yet.
Returns
string
toUpperTriangular(): MatrixMethodNo description is available yet.
Returns
trace(): ExpressionMethodReturns the sum of the main diagonal. The empty matrix has trace zero.
MathError If the matrix is not square.
Returns
transpose(): MatrixMethodReturns a transposed matrix. Existing elements are normalized by the constructor.
Returns
unroll(): VectorMethodReturns elements as a column-major Vector.
Returns
withSymbolicAccessor(target: Expression, indices: Expression[]): MatrixMethodReturns a copied structured entity carrying an unresolved bracket access. Existing accessor state is retained so chained symbolic access can be extended.
Parameters
| Name | Type | Description |
|---|---|---|
target | Expression | — |
indices | Expression[] | — |
Returns
zeroMatrix(rows: number, cols: number): MatrixMethodCreates a matrix filled with symbolic zeros.
Parameters
| Name | Type | Description |
|---|---|---|
rows | number | — |
cols | number | — |
