Dense, fully-reduced matrix value: a row-major Array[Double], not n² _Number nodes.
The concrete counterpart of the symbolic matrix node (matrix._Matrix), exactly as _Number is the concrete counterpart of a scalar expression. Lives in core so Environment can bind matrix values without core depending on any domain.
Immutability: the public factory (_MatrixValue$.apply) takes a defensive copy and the storage is private — kernels build results on arrays they own, skipping the copy.
multiply parallelises over independent row blocks above a work-volume threshold; writes are disjoint and require no locking.
Value parameters
- cols
-
number of columns; must be positive
- rows
-
number of rows; must be positive
Attributes
- Companion
- object
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Element-wise matrix addition.
Element-wise matrix addition.
Value parameters
- that
-
matrix to add; must have the same
rowsandcols
Attributes
Returns the element at row i, column j (zero-based).
Returns the element at row i, column j (zero-based).
Attributes
Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.
Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.
Attributes
- Definition Classes
Determinant via LU decomposition with partial pivoting, O(n³). None when the matrix is non-square; Some(0.0) when singular (zero pivot). Operates on a defensive clone — the value's storage is untouched.
Determinant via LU decomposition with partial pivoting, O(n³). None when the matrix is non-square; Some(0.0) when singular (zero pivot). Operates on a defensive clone — the value's storage is untouched.
Attributes
- Returns
-
Some(det)for square matrices,Nonefor non-square
Renders this matrix at precision decimal places for REPL display; mirrors _Number.round behaviour.
Renders this matrix at precision decimal places for REPL display; mirrors _Number.round behaviour.
Value parameters
- precision
-
number of decimal places to show
Attributes
Eigenvalue decomposition via QR iteration with Wilkinson shifts. Returns the n eigenvalues as _Number (real) or _Complex (conjugate pairs from 2×2 blocks). None for non-square matrices or non-convergence within 300·n steps.
Eigenvalue decomposition via QR iteration with Wilkinson shifts. Returns the n eigenvalues as _Number (real) or _Complex (conjugate pairs from 2×2 blocks). None for non-square matrices or non-convergence within 300·n steps.
Algorithm: shrinking active sub-matrix; deflation when the sub-diagonal drops below tolerance; Wilkinson shift QR step otherwise; 2×2 blocks solved analytically. A tiny perturbation breaks rank deficiency when the shift hits an exact eigenvalue.
Attributes
- Returns
-
Some(eigenvalues)in deflation order,Nonefor non-square or non-convergent
Compares the receiver object (this) with the argument object (that) for equivalence.
Compares the receiver object (this) with the argument object (that) for equivalence.
Any implementation of this method should be an equivalence relation:
- It is reflexive: for any instance
xof typeAny,x.equals(x)should returntrue. - It is symmetric: for any instances
xandyof typeAny,x.equals(y)should returntrueif and only ify.equals(x)returnstrue. - It is transitive: for any instances
x,y, andzof typeAnyifx.equals(y)returnstrueandy.equals(z)returnstrue, thenx.equals(z)should returntrue.
If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode to ensure that objects which are "equal" (o1.equals(o2) returns true) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)).
Value parameters
- that
-
the object to compare against this object for equality.
Attributes
- Returns
-
trueif the receiver object is equivalent to the argument;falseotherwise. - Definition Classes
-
Any
Returns Right(this) — a concrete matrix needs no further reduction.
Returns Right(this) — a concrete matrix needs no further reduction.
Attributes
- Definition Classes
Matrix exponential e^A = sum(k >= 0) A^k / k!, by scaling and squaring with a degree-13 Padé approximant.
Matrix exponential e^A = sum(k >= 0) A^k / k!, by scaling and squaring with a degree-13 Padé approximant.
Not the eigen route. V·diag(e^λ)·V⁻¹ is tempting because spectralDecompose already exists, but it needs an eigenbasis and a defective matrix has none — and a defective matrix is ordinary in the problems that want this, since a repeated pole produces one. A Jordan block (λ 1; 0 λ) would come back wrong rather than refused. Scaling and squaring is uniform over both cases, which is why it is the standard method.
The identity e^A = (e^(A/2^s))^(2^s) is what makes it work: A is scaled until its norm is inside the Padé approximant's accurate radius, the approximant is evaluated there, and the result is squared back s times.
Note this is matrix Padé — a fixed rational approximant with tabulated coefficients — and is unrelated to the scalar scalar.padeApproximant, which fits a series.
Exactness follows the decomposition precedent rather than matrix/Exact.scala: the exponential is transcendental, so an exact operand demotes to Double exactly as lu/qr/eigen do — "demote an exact operand rather than lose the operation".
Attributes
- Returns
-
Some(e^A)for a square matrix,Nonewhen non-square or non-finite
Lifts this matrix into an Either for use in eval: Right(this) when all elements are finite; Left(orElse) otherwise (non-finite is a domain error — stays symbolic like x / 0). Shared by scalar and matrix packages without requiring cross-imports.
Lifts this matrix into an Either for use in eval: Right(this) when all elements are finite; Left(orElse) otherwise (non-finite is a domain error — stays symbolic like x / 0). Shared by scalar and matrix packages without requiring cross-imports.
Value parameters
- orElse
-
the symbolic fallback expression
Attributes
Inverse via Gauss–Jordan elimination with partial pivoting, O(n³). None when the matrix is non-square or singular — the caller stays symbolic, the same "domain error stays symbolic" contract as x / 0 in scalar.Ratio.
Inverse via Gauss–Jordan elimination with partial pivoting, O(n³). None when the matrix is non-square or singular — the caller stays symbolic, the same "domain error stays symbolic" contract as x / 0 in scalar.Ratio.
Attributes
- Returns
-
Some(A⁻¹)for invertible square matrices,Noneotherwise
Returns true when every element is finite (not NaN, not infinite).
Returns true when every element is finite (not NaN, not infinite).
Attributes
Kronecker product this ⊗ that: the (rows·that.rows) × (cols·that.cols) block matrix whose (i, j) block is this(i, j) · that. The kernel behind the vectorized matrix-equation tier: vec(A·X·B) = (Bᵀ ⊗ A) · vec(X).
Kronecker product this ⊗ that: the (rows·that.rows) × (cols·that.cols) block matrix whose (i, j) block is this(i, j) · that. The kernel behind the vectorized matrix-equation tier: vec(A·X·B) = (Bᵀ ⊗ A) · vec(X).
Value parameters
- that
-
the right factor
Attributes
LU decomposition with partial pivoting: P·A = L·U, where L is unit lower triangular, U is upper triangular, and P is the permutation matrix. None when the matrix is non-square or singular (zero pivot encountered).
LU decomposition with partial pivoting: P·A = L·U, where L is unit lower triangular, U is upper triangular, and P is the permutation matrix. None when the matrix is non-square or singular (zero pivot encountered).
Attributes
- Returns
-
Some((L, U, P))for square non-singular matrices,Noneotherwise
Matrix multiplication this × that (this.cols must equal that.rows).
Matrix multiplication this × that (this.cols must equal that.rows).
Block-tiled i-k-j loop: Tile × Tile blocks keep the hot tile of that (and out) cache-resident across a whole row block. Within each output cell, k-accumulation is ascending, so results are bit-identical to the untiled kernel. Row blocks write disjoint slices of out and parallelise with no locking above the work-volume threshold.
Value parameters
- that
-
right factor;
that.rowsmust equalthis.cols
Attributes
QR decomposition via modified Gram-Schmidt: A = Q·R (m ≥ n). Q is m × n with orthonormal columns; R is n × n upper triangular. None when rows < cols or the matrix is rank-deficient (a column reduces to zero norm).
QR decomposition via modified Gram-Schmidt: A = Q·R (m ≥ n). Q is m × n with orthonormal columns; R is n × n upper triangular. None when rows < cols or the matrix is rank-deficient (a column reduces to zero norm).
Attributes
- Returns
-
Some((Q, R))orNone
Reconstructs the same node shape with replacement sub-expressions.
Reconstructs the same node shape with replacement sub-expressions.
Value parameters
- newChildren
-
replacements in the same order and count as
children
Attributes
- Definition Classes
Multiplies every element by scalar k.
Multiplies every element by scalar k.
Value parameters
- k
-
the scalar factor
Attributes
Spectral decomposition: eigenvalues and right eigenvectors. Returns (columns of V, eigenvalues) where eigenvector column j corresponds to eigenvalue j. Complex conjugate pairs (α ± βi) occupy consecutive positions. None when non-square, QR iteration fails, or an eigenvector cannot be extracted (numerically degenerate or defective matrix).
Spectral decomposition: eigenvalues and right eigenvectors. Returns (columns of V, eigenvalues) where eigenvector column j corresponds to eigenvalue j. Complex conjugate pairs (α ± βi) occupy consecutive positions. None when non-square, QR iteration fails, or an eigenvector cannot be extracted (numerically degenerate or defective matrix).
Attributes
- Returns
-
Some((V, eigenvalues))orNone
Renders this matrix at Environment.DefaultPrecision decimal places.
Renders this matrix at Environment.DefaultPrecision decimal places.
Attributes
- Definition Classes
-
Any
Read-only view of the dense storage in row-major order.
Read-only view of the dense storage in row-major order.
Attributes
Returns the transpose of this matrix (cols × rows).
Returns the transpose of this matrix (cols × rows).
Attributes
Column-stacking vectorisation: returns the (rows·cols) × 1 column vector where vec[j·rows + i] = this(i, j). Paired with _MatrixValue$.unvec.
Column-stacking vectorisation: returns the (rows·cols) × 1 column vector where vec[j·rows + i] = this(i, j). Paired with _MatrixValue$.unvec.
Attributes
Inherited fields
Cached set of free variable names; O(1) after the first access.
Cached set of free variable names; O(1) after the first access.
Attributes
- Inherited from:
- _Expression