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. each may also be used for observation by
returning nothing; use forEach when no transformation is intended.
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.
core!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.
core!UnexpectedDataType If a full-row assignment does not receive a Vector.
core!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.
core!MathError If the row counts differ.
Parameters
| Name | Type | Description |
|---|---|---|
matrix | Matrix | — |
Returns
buildFunction(argsArray?: string[]): (...args: number[]): numberMethodCompiles this value to a native JavaScript-number function when the parsed result
is an Expression.
Structured parser results expose this method so values returned by nerdamer(...)
have one consistent TypeScript surface, but they cannot be compiled as scalar
functions and throw core!UnexpectedDataType when called.
Parameters
| Name | Type | Description |
|---|---|---|
argsArray | string[] | Optional variable names in positional call order. |
Returns
(...args: number[]): number — A JavaScript-number function compiled from the scalar expression.
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.
core!MathError If nonempty rows have different lengths.
core!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.
core!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.
core!DimensionError If a Matrix divisor has different dimensions.
Parameters
| Name | Type | Description |
|---|---|---|
x | NerdamerInput | — |
Returns
e(i: number, j: number): ExpressionMethodReturns a one-based matrix element for compatibility with the legacy accessor.
core!MathError If either index is out of bounds.
Parameters
| Name | Type | Description |
|---|---|---|
i | number | — |
j | number | — |
Returns
each(fn: (e: Expression, i?: string | number, j?: string | number): void | Expression): MatrixMethodVisits or replaces every element in row-major order.
Returning void leaves the current cell unchanged. Callback row and column
indices are zero-based.
Parameters
| Name | Type | Description |
|---|---|---|
fn | (e: Expression, i?: string | number, j?: string | number): void | 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(values?: ParserValuesObject): MatrixMethodEvaluates and returns a copied matrix.
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
forEach(callback: (value: Expression, row: number, col: number): void): voidMethodVisits every cell without changing the matrix.
Parameters
| Name | Type | Description |
|---|---|---|
callback | (value: Expression, row: number, col: number): void | — |
Returns
void
get(row: number, col: number): ExpressionMethodReturns the stored Expression at a zero-based row and column.
core!MathError If either index is out of bounds.
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.
core!UnsupportedOperationError If the matrix is not square.
core!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.
core!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() method.
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.
numeric(precision?: ExpressionInput): MatrixMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
precision | ExpressionInput | — |
Returns
plus(x: NerdamerInput): MatrixMethodAdds corresponding entries, or broadcasts a scalar addend.
core!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.
core!UnsupportedOperationError If the exponent is not an integer, or if a nontrivial power is requested for a rectangular matrix.
core!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
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.
core!MathError If matrix or vector dimensions are incompatible.
core!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.
core!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
zeroMatrix(rows: number, cols: number): MatrixMethodCreates a matrix filled with symbolic zeros.
Parameters
| Name | Type | Description |
|---|---|---|
rows | number | — |
cols | number | — |
