it.grypho.scala.leonardo.matrix
Members list
Type members
Classlikes
Determinant of a matrix: det(A) -- a SCALAR result.
Determinant of a matrix: det(A) -- a SCALAR result.
Deliberately does NOT extend _MatrixOperation (and isMatrixShaped must not match it), so 2 * det(A) builds a scalar Product, not a matrix scale -- the same design as _MatrixIndex.
eval reduces the operand: a dense value uses the O(n^3) _MatrixValue.determinant kernel; a symbolic square matrix expands by cofactors (capped at MaxSymbolicDim); non-square or over-cap operands stay symbolic.
Value parameters
- m
-
the matrix expression whose determinant to compute
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
Identity matrix: eye(n) -- an n x n matrix with 1s on the diagonal.
Identity matrix: eye(n) -- an n x n matrix with 1s on the diagonal.
Extends _MatrixOperation so isMatrixShaped picks it up and the parser routes eye(3) + M to MatSum rather than Sum. Non-integer, non-positive, or over-MaxDenseDim arguments stay symbolic.
Value parameters
- n
-
the dimension expression (must reduce to a positive integer at most
MaxDenseDim)
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Matrix inverse: inv(A).
Matrix inverse: inv(A).
Result is a matrix, so this extends _MatrixOperation and isMatrixShaped matches it. eval reduces the operand: a dense value uses the Gauss-Jordan _MatrixValue.inverse kernel (None -> singular or non-square -> stays symbolic, like x/0 in scalar division); a symbolic square matrix builds adjugate/det (capped at MaxSymbolicDim) and reduces element-wise.
Value parameters
- m
-
the matrix expression to invert
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Matrix product: (A * B)_ij = sum_k A_ik * B_kj, for A: r x n and B: n x c.
Matrix product: (A * B)_ij = sum_k A_ik * B_kj, for A: r x n and B: n x c.
A _Number operand scales instead of multiplying -- the parser builds MatProduct(M, y) for M * y with a non-literal y, because y may be either a scalar or a matrix at eval time (variable bound to _MatrixValue). Both cases are resolved by reduceProduct at eval time.
Value parameters
- a
-
left operand (matrix or scalar)
- b
-
right operand (matrix or scalar)
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixProductShapedtrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Scalar multiple: (k * A)_ij = k * A_ij, where k is any scalar expression.
Scalar multiple: (k * A)_ij = k * A_ij, where k is any scalar expression.
When k turns out to be matrix-valued at eval time (a variable bound to a _MatrixValue, or a scalar Product that reduced to one), the node is really a matrix product k * m and is reduced as such via reduceProduct, preserving operand order (matrix products are not commutative in general).
Value parameters
- k
-
the scalar multiplier
- m
-
the matrix operand
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Element-wise matrix addition: (A + B)_ij = A_ij + B_ij.
Element-wise matrix addition: (A + B)_ij = A_ij + B_ij.
Marked _ElementWise because addition is linear: d/dx (A + B) = dA/dx + dB/dx. MatProduct and MatScale are NOT marked -- they need product rules.
Value parameters
- a
-
left matrix operand
- b
-
right matrix operand
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixSumShapedtrait _ElementWisetrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Which norm norm takes (F_0039 Decision B): the written order, kept so a saved session re-parses to the call it was typed as.
Which norm norm takes (F_0039 Decision B): the written order, kept so a saved session re-parses to the call it was typed as.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Which subspace a _NullSpace node asks for.
Which subspace a _NullSpace node asks for.
Attributes
Matrix transpose: (A^T)_ij = A_ji.
Matrix transpose: (A^T)_ij = A_ji.
Marked _ElementWise because transposition is linear and element-independent: d/dx (A^T) = (dA/dx)^T.
Value parameters
- m
-
the matrix to transpose
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _ElementWisetrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Zero matrix: zeros(rows, cols) -- a rows x cols matrix of zeros.
Zero matrix: zeros(rows, cols) -- a rows x cols matrix of zeros.
zeros(n) in the grammar is shorthand for zeros(n, n) (square zero matrix); the parser handles the one-argument form. Non-integer, non-positive, or over-MaxDenseDim arguments stay symbolic.
Value parameters
- nCols
-
number-of-columns expression
- nRows
-
number-of-rows expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Block diagonal: blkdiag(A, B, …), the blocks on the diagonal and zeros elsewhere — zeros in the blocks' tier, so exact blocks give an exact matrix.
Block diagonal: blkdiag(A, B, …), the blocks on the diagonal and zeros elsewhere — zeros in the blocks' tier, so exact blocks give an exact matrix.
Value parameters
- blocks
-
the diagonal blocks, top-left first; a number is a
1×1block
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Cholesky factorisation: chol(A) -- the lower-triangular L with A = L·Lᵀ (F_0054).
Cholesky factorisation: chol(A) -- the lower-triangular L with A = L·Lᵀ (F_0054).
A dense operand uses core._MatrixValue.cholesky; an exact one is factored over the rationals by exactCholesky and stays a symbolic _Matrix of exact cells, the inv/det precedent; a literal mixing exact and inexact cells demotes to the dense kernel. A matrix that is not square, not symmetric, or not positive definite stays unevaluated — that refusal is the convexity test the QP tier (F_0053) builds on — and so does a symbolic one.
Extends _MatrixOperation, like _MatrixExponential, because its result is a single matrix: chol(A) * x then dispatches as a matrix product.
Value parameters
- m
-
the matrix expression to factor
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
2-norm condition number: cond(A), σ_max/σ_min over the min(m, n) singular values (F_0061), inf for a numerically singular matrix.
2-norm condition number: cond(A), σ_max/σ_min over the min(m, n) singular values (F_0061), inf for a numerically singular matrix.
"Numerically singular" here is σ_min ≤ max(m, n)·ε·σ_max, not Decision B's precision-scaled tolerance — see conditionNumber for why the two questions take different cut-offs. A SCALAR result (the det rule); always a Double, since a ratio of singular values is irrational in general.
Value parameters
- m
-
the matrix expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
cross(u, v) — the right-handed product of two 3-vectors, in the first argument's shape (F_0161): (u₂v₃ − u₃v₂, u₃v₁ − u₁v₃, u₁v₂ − u₂v₁), so cross(e₁, e₂) = e₃.
cross(u, v) — the right-handed product of two 3-vectors, in the first argument's shape (F_0161): (u₂v₃ − u₃v₂, u₃v₁ − u₁v₃, u₁v₂ − u₂v₁), so cross(e₁, e₂) = e₃.
Right-handed, stated: curl's sphericalmaths case is the reminder that handedness is not to be left implicit. Any other length stays unevaluated — there is no 2-D "scalar cross product", which would be a different result type, the curl precedent. The −1 the differences need is built in the operands' tier (the numeric tier rule), so exact cells give exact cells. A matrix result, so this is a _MatrixOperation: 2 * cross(u, v) scales it.
Value parameters
- u
-
the first vector, whose shape the result keeps
- v
-
the second
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
dot(u, v) — the scalar Σ uᵢvᵢ of two rows or columns of one length, in any mix (F_0160).
dot(u, v) — the scalar Σ uᵢvᵢ of two rows or columns of one length, in any mix (F_0160).
No conjugate (F_0160 Decision 1): this is the bilinear form, numpy's dot. The Hermitian product conjugates its first argument, and the language has no conjugate yet, so a vector with a complex cell is refused rather than given the product of a different convention. A SCALAR result, so it is an _Expression and not a _MatrixOperation: 2 + dot(u, v) is a number, where 2 + transpose(u)*v is a 1×1 matrix sum.
Exact cells give an exact answer, symbolic cells a sum of products; a length mismatch, a non-vector and a complex cell stay unevaluated.
Value parameters
- u
-
the first vector
- v
-
the second
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
Eigenvalue/eigenvector decomposition: eig(A) -- returns [[V, D]] where A * V = V * D.
Eigenvalue/eigenvector decomposition: eig(A) -- returns [[V, D]] where A * V = V * D.
V columns are right eigenvectors; D is diagonal with the eigenvalues. Evaluates when A reduces to a dense square _MatrixValue; stays symbolic for non-convergent or defective-detected cases (when the eigenvector matrix V fails isJordanInvertible).
The result is Left(_Matrix(1, 2, ...)) because a matrix of matrices is not a _Value; individual components are accessible via at(result, 1, k).
Value parameters
- m
-
the square matrix expression to decompose
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
Eigenvalue decomposition: eigen(A) -- returns [[lambda_1, lambda_2, ..., lambda_n]].
Eigenvalue decomposition: eigen(A) -- returns [[lambda_1, lambda_2, ..., lambda_n]].
Eigenvalues are _Number for real results and _Complex for complex conjugate pairs. Evaluates when A reduces to a square dense _MatrixValue via the QR iteration kernel; stays symbolic for non-square operands or when the iteration does not converge.
Does NOT extend _MatrixOperation because the result is not a matrix of Doubles (eigenvalues can be complex): it stays as Left(_Matrix(1, n, ...)) rather than collapsing to a single _MatrixValue.
Value parameters
- m
-
the square matrix expression whose eigenvalues to compute
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
Horizontal concatenation: hcat(A, B, …), blocks of equal height side by side.
Horizontal concatenation: hcat(A, B, …), blocks of equal height side by side.
Value parameters
- blocks
-
the blocks, left to right; a number is a
1×1block
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Jordan decomposition: jordan(A) -- returns [[P, J]] where A = P * J * P^(-1).
Jordan decomposition: jordan(A) -- returns [[P, J]] where A = P * J * P^(-1).
An exact matrix whose eigenvalues are all rational gets its exact Jordan form, Jordan blocks included (exactJordan, F_0176): eigenvalues ascending, blocks by decreasing size, the 1s above the diagonal, P and J exact and certified by AP = PJ. Otherwise, for a diagonalizable matrix J is diagonal (identical to D in eig(A)) and P = V; a non-diagonalizable numeric matrix, or one whose eigenvalues are irrational or complex, stays symbolic, since in floating point a Jordan block is not computable.
The result is Left(_Matrix(1, 2, ...)) because a matrix of matrices is not a _Value.
Value parameters
- m
-
the square matrix expression to decompose
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
The Kronecker product: kron(A, B).
The Kronecker product: kron(A, B).
Dense operands use core._MatrixValue.kronecker; otherwise each cell is the product of a cell of A and a cell of B, through productOf, which keeps an exact zero exact.
Value parameters
- a
-
the left factor; a number is a
1×1matrix - b
-
the right factor; a number is a
1×1matrix
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
A symbolic matrix whose elements are arbitrary expressions.
A symbolic matrix whose elements are arbitrary expressions.
This is the AST-side matrix; the fully-reduced counterpart is _MatrixValue (a dense Array[Double] in core). Elements may be numbers, variables, functions, functionals, or any other _Expression.
eval reduces every element: when all of them fold to _Number values the matrix collapses to a single _MatrixValue; otherwise it stays symbolic with each element as far reduced as it goes (the dual-evaluation contract, applied element-wise).
Marked _ElementWise: derive/simplify/expand/integrate distribute over the elements (e.g. d/dx [a_ij] = [d(a_ij)/dx]), which is valid because the matrix is a plain container with no coupling between cells.
children / rebuild expose the elements to generic traversals, so substitute and dependsOn work through matrix elements without matrix-specific cases.
Value parameters
- cols
-
number of columns (must be positive)
- elems
-
row-major element vector; must have exactly
rows * colsentries - rows
-
number of rows (must be positive)
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixShapedtrait _ElementWisetrait _Expressionclass Objecttrait Matchableclass AnyShow all
Matrix exponential: expm(A).
Matrix exponential: expm(A).
Evaluates when A reduces to a square dense _MatrixValue, via the core._MatrixValue.expm kernel (scaling and squaring with a degree-13 Padé approximant); stays symbolic for a non-square or symbolic operand.
Extends _MatrixOperation, unlike the decompositions beside it, because its result is a single matrix rather than a row of them -- so isMatrixShaped picks it up and expm(A) * B dispatches as a matrix product rather than a scalar one.
Distinct from A^n: that is repeated multiplication by binary exponentiation, this is the exponential series, and the two share no machinery.
Value parameters
- m
-
the matrix expression to exponentiate
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Element access: at(A, i, j) returns the element at 1-based row i, column j.
Element access: at(A, i, j) returns the element at 1-based row i, column j.
Does NOT extend _MatrixOperation because the result is a scalar, not a matrix -- isMatrixShaped must not match it or the REPL would dispatch it as a matrix op. When the matrix is still symbolic but the indices are concrete, the element is extracted directly from the _Matrix literal so that at([[x, 2]], 1, 2) -> 2.0 without requiring the whole matrix to be dense.
Value parameters
- col
-
the column index expression (1-based)
- matrix
-
the matrix expression to index into
- row
-
the row index expression (1-based)
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
Marker trait for matrix-valued AST nodes.
Marker trait for matrix-valued AST nodes.
Evaluation is two-path: when both operands reduce to dense _MatrixValues the dense kernels in _MatrixValue are used (fast path); otherwise, matrix literals combine element-wise via the sumOf/productOf helpers, and the resulting _Matrix collapses to a dense value when every element folded, or stays symbolic otherwise.
Dimension mismatches and non-finite results are domain errors and stay symbolic, exactly like x/0 in scalar.Ratio.
Not every matrix-related node extends _MatrixOperation: Determinant and _MatrixIndex produce scalar results, so they extend _Expression directly to prevent the parser from treating 2 * det(A) as a matrix scale.
Attributes
- Supertypes
- Known subtypes
-
class IdentityMatrixclass Inverseclass MatProductclass MatScaleclass MatSumclass Transposeclass ZeroMatrixclass _BlkDiagclass _Choleskyclass _Crossclass _HCatclass _Kronclass _MatrixExponentialclass _Onesclass _PInvclass _RepMatclass _Sizeclass _SubMatrixclass _VCatShow all
norm(x) and norm(x, kind) (F_0039): a vector's or a matrix's norm.
norm(x) and norm(x, kind) (F_0039): a vector's or a matrix's norm.
The shape decides the reading (Decision A, MATLAB's rule, stated because the other reading exists): a row or a column is a vector — and so is a number, as a 1×1 — anything else a matrix. The default is the 2-norm either way, since the vector 2-norm and the spectral norm agree on a column, so the shape decides only what 1 and inf mean: the sum and the largest modulus of a vector, the largest column and row sum of a matrix.
- A vector:
1,2,inf,fro(the 2-norm) and anyp ≥ 1; apbelow 1 is not a norm and stays unevaluated. A complex entry counts by its modulus. InDoublethe 2- andp-norms are scaled by the largest modulus before they are raised, so[[1e200], [1e200]]is1.414…1e200rather than an overflow (the conditioning rule). Exact cells stay exact for1andinf; the 2-norm's root is taken at the working precision. Symbolic cells givesum(abs(xᵢ))or(Σ abs(xᵢ)^p)^(1/p); their max-norm stays unevaluated, since a maximum of unknown magnitudes is not decidable. - A matrix:
1andinfon numeric cells, exact on exact ones;froas above; the 2-norm is the largest singular value through the SVD, nevereigen(AᵀA), which squares the condition number (2.11) — an exact matrix is demoted for it, thesvdprecedent, and a complex one stays unevaluated. Any otherpstays unevaluated.
A SCALAR result, like Determinant, so 1 + norm(x) is a number.
Value parameters
- order
-
which norm
- x
-
the vector or matrix
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
An orthonormal basis of the null space, nullspace(A), or of the range, orth(A), each with rank's optional relative tolerance (F_0087).
An orthonormal basis of the null space, nullspace(A), or of the range, orth(A), each with rank's optional relative tolerance (F_0087).
The answer is a matrix whose columns are the basis. A trivial subspace answers false — the null space of a full-column-rank matrix, the range of the zero matrix — since a matrix cannot have zero columns, and false is what tfpoles and stationary answer for provably none. The zero matrix's null space is the whole space. The basis is unique only up to rotation; its columns come from the SVD's V or U. An exact matrix demotes and a symbolic one stays symbolic, the rank rules; a tolerance that is not a number in [0, 1) leaves the call as written, with the reason in declineReason.
It is the null-space method's N in z = z₀ + N·w for equality constraints, which is why it was filed (F_0061 Decision A, for F_0074 and F_0066).
Value parameters
- m
-
the matrix expression
- tol
-
the optional relative tolerance
- which
-
the subspace
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
All-ones matrix: ones(rows, cols), and ones(n) for the square one (F_0055).
All-ones matrix: ones(rows, cols), and ones(n) for the square one (F_0055).
The ZeroMatrix template exactly, so the two constructors cannot disagree about what a valid dimension is: non-integer, non-positive or over-MaxDenseDim arguments stay symbolic.
Value parameters
- nCols
-
number-of-columns expression
- nRows
-
number-of-rows expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Moore–Penrose pseudo-inverse: pinv(A), the n×m matrix V·Σ⁺·Uᵀ (F_0061).
Moore–Penrose pseudo-inverse: pinv(A), the n×m matrix V·Σ⁺·Uᵀ (F_0061).
Singular values at or below 0.5·10⁻ᵖ·σ_max are treated as zero (Decision B, shared with rank), so pinv of a rank-deficient matrix is the pseudo-inverse of its numerical-rank part rather than one amplified by rounding. For a square non-singular matrix it is the inverse; for a tall full-column-rank one it is the least-squares solver (AᵀA)⁻¹Aᵀ, without ever forming AᵀA (the conditioning rule). An exact matrix demotes; a symbolic one stays symbolic.
Extends _MatrixOperation, like chol, because its result is a single matrix.
Value parameters
- m
-
the matrix expression to pseudo-invert
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
Numerical rank: rank(A) or rank(A, tol) — the number of singular values above tol·σ_max (F_0061 Decision B).
Numerical rank: rank(A) or rank(A, tol) — the number of singular values above tol·σ_max (F_0061 Decision B).
The default tol is 0.5·10⁻ᵖ at session precision p; an explicit one is relative to the largest singular value too, so rank(k·A, tol) never depends on k. It must be a number in [0, 1); anything else stays unevaluated. The zero matrix has rank 0. A SCALAR result, so this does not extend _MatrixOperation (the det rule). The count is built in the operand's tier — an exact matrix answers an exact integer — although the decomposition behind it is Double.
Value parameters
- m
-
the matrix expression
- tol
-
the optional relative tolerance
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
rationalize(x) / rationalize(x, digits) — every decimal of x replaced by the rational it is closest to, with a denominator at most 10^digits (F_0170).
rationalize(x) / rationalize(x, digits) — every decimal of x replaced by the rational it is closest to, with a denominator at most 10^digits (F_0170).
The way back into the exact tier, and only when asked. A Double stays visibly inexact by design (the one-way float contagion of 4.L), so a value known to be exact that arrived as a decimal — a lu factor in exact mode, a frozen consolidate result, a number read from data — had no way back. Applied silently, the conversion would relabel a computed 0.3333333333333333 as an exact 1/3; asked for, it is the reader's statement that the value is rational.
- A number becomes
_Rational.fromApproximation(d, digits): the best fraction by continued-fraction truncation, so0.3333333333333333is1/3. - A dense matrix becomes the exact
_Matrixcarrier — the reason this node lives inmatrix:scalarcannot build that carrier. - A symbolic expression keeps its shape, its decimal leaves made exact; an exact leaf is left as it is.
digitsdefaults to the fewest that make every decimal its small fraction when each looks rational (rationalizeDigits, F_0240), else to the working precision, capped at 15, the digits aDoublecarries (_Rational.DoubleReliableDigits); an explicit one must be a whole number in1 .. 15.- A value it cannot make exact declines the whole call (the owner's decision): a complex number (no exact complex carrier exists), an interval, a non-finite value. Converting the rest would leave a result in two tiers that demotes again on evaluation.
It works outside exact mode too, since it is asked for; :save groups the exact value it leaves under exact on (F_0090).
Value parameters
- digits
-
the decimal digits the approximation is good for, optional
- x
-
the expression whose decimals to convert
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
Tiling: repmat(A, m, n), A repeated m times down and n times across.
Tiling: repmat(A, m, n), A repeated m times down and n times across.
Value parameters
- across
-
the number of copies across, a positive integer
- down
-
the number of copies down, a positive integer
- m
-
the block to tile (a matrix: Decision C does not extend to
repmat)
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
size(A) — the row [[rows, cols]] of a matrix (F_0173), so r, c := size(A) names both.
size(A) — the row [[rows, cols]] of a matrix (F_0173), so r, c := size(A) names both.
The shape is read off the evaluated operand in O(1); the only cost is evaluating the operand itself. The counts are built in the operand's tier, as rank answers: an exact matrix gives an exact row. A matrix result, so this is a _MatrixOperation and 2 * size(A) scales it. An operand of unknown shape stays unevaluated.
Value parameters
- m
-
the matrix
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
size(A, k) — the number of rows (k = 1) or of columns (k = 2) of a matrix (F_0173), in the operand's tier. A SCALAR result, like _Trace; any other k stays unevaluated.
size(A, k) — the number of rows (k = 1) or of columns (k = 2) of a matrix (F_0173), in the operand's tier. A SCALAR result, like _Trace; any other k stays unevaluated.
Value parameters
- dim
-
the dimension, 1 or 2
- m
-
the matrix
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
A slice: submatrix(A, r0, r1, c0, c1), rows r0..r1 and columns c0..c1, 1-based and inclusive (Decision A). Out-of-range, reversed or non-integer bounds leave it unevaluated.
A slice: submatrix(A, r0, r1, c0, c1), rows r0..r1 and columns c0..c1, 1-based and inclusive (Decision A). Out-of-range, reversed or non-integer bounds leave it unevaluated.
Value parameters
- c0
-
the first column, from 1
- c1
-
the last column, inclusive
- m
-
the matrix to slice
- r0
-
the first row, from 1
- r1
-
the last row, inclusive
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Singular value decomposition: svd(A) — [[U, S, V]] with A = U·S·Vᵀ (F_0061).
Singular value decomposition: svd(A) — [[U, S, V]] with A = U·S·Vᵀ (F_0061).
Economy by default; svd(A, full) gives the square U and V (Decision A — the slot word full is matched only there and is not reserved). The kernel is one-sided Jacobi (core._MatrixValue.svd), certified against its own reconstruction and orthonormality, so a matrix it cannot decompose stays unevaluated rather than being answered approximately. An exact matrix demotes, the lu/qr precedent: an SVD is iterative and irrational in general. A symbolic matrix stays symbolic.
Like lu, the result is a row of matrices, so it is a plain _Expression and tuple assignment binds the factors: U, S, V := svd(A).
Value parameters
- full
-
whether to return the full rather than the economy factors
- m
-
the matrix expression to decompose
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
trace(A) — the sum of a square matrix's diagonal (F_0162): exact on exact cells, symbolic on symbolic ones, and unevaluated for a non-square matrix. A SCALAR result, like Determinant.
trace(A) — the sum of a square matrix's diagonal (F_0162): exact on exact cells, symbolic on symbolic ones, and unevaluated for a non-square matrix. A SCALAR result, like Determinant.
Value parameters
- m
-
the matrix
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
Vertical concatenation: vcat(A, B, …), blocks of equal width stacked.
Vertical concatenation: vcat(A, B, …), blocks of equal width stacked.
Value parameters
- blocks
-
the blocks, top to bottom; a number is a
1×1block
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _MatrixOperationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Value members
Concrete methods
Reads a symbolic matrix as a dense Double one.
Reads a symbolic matrix as a dense Double one.
The demotion the iterative decompositions (qr, eigen, eig, a numeric jordan) need: they cannot be exact, so an exact operand must degrade rather than stay symbolic and lose the feature. Reads through the widening _Number extractor, so exact and inexact cells alike are accepted.
Value parameters
- m
-
the symbolic matrix
Attributes
- Returns
-
the dense matrix, or
Noneif any cell is not a real number
The cells of m as exact rationals, when every cell is one.
The cells of m as exact rationals, when every cell is one.
All-or-nothing on purpose: a matrix with one inexact entry is an inexact matrix, and running an exact kernel over it would dress float contagion up as an exact answer.
Value parameters
- m
-
the symbolic matrix
Attributes
- Returns
-
the row-major exact cells, or
Noneif any cell is not exact
The Cholesky factor of a symmetric positive-definite rational matrix (F_0054).
The Cholesky factor of a symmetric positive-definite rational matrix (F_0054).
Symmetry and the sign of every pivot are decided exactly, so no tolerance enters a refusal. Each diagonal entry is the square root of an exact pivot: rational when the pivot is a rational square, otherwise core.exactSqrt at the working precision — the entries below it are then exact quotients by that value, so L·Lᵀ reproduces A to the working precision.
Value parameters
- cells
-
the row-major exact cells
- digits
-
the working precision for an irrational pivot root
- n
-
the dimension
- policy
-
the reduction policy for the intermediate arithmetic
Attributes
- Returns
-
the row-major cells of the lower-triangular
L, orNonewhen the matrix is not symmetric or not positive definite
The exact determinant of a square rational matrix, by Gaussian elimination.
The exact determinant of a square rational matrix, by Gaussian elimination.
Elimination is O(n³) against the cofactor expansion's O(n!), which is what lets this be uncapped. A row swap flips the sign; a column with no usable pivot means a singular matrix, whose determinant is exactly zero — not a failure.
Value parameters
- cells
-
the row-major exact cells
- n
-
the dimension
- policy
-
the reduction policy for the intermediate arithmetic
Attributes
- Returns
-
the exact determinant
The exact inverse of a square rational matrix, by Gauss–Jordan elimination.
The exact inverse of a square rational matrix, by Gauss–Jordan elimination.
Value parameters
- cells
-
the row-major exact cells
- n
-
the dimension
- policy
-
the reduction policy for the intermediate arithmetic
Attributes
- Returns
-
the row-major cells of the inverse, or
Nonewhen the matrix is singular
The exact LU factorisation P·A = L·U of a square rational matrix (F_0226).
The exact LU factorisation P·A = L·U of a square rational matrix (F_0226).
Elimination is finite, so over the rationals it is exact. The pivot is the largest in magnitude, not merely the first non-zero pivotRow takes: exactness does not need it, but it makes P the one the dense kernel chooses, so the same matrix written exactly and inexactly factors the same way. A column with no non-zero pivot is skipped, not refused: a singular matrix has an LU factorisation too, with a zero on U's diagonal, where the dense kernel declines because in floating point an exact zero pivot cannot be told from a tiny one.
Value parameters
- cells
-
the row-major exact cells
- n
-
the dimension
- policy
-
the reduction policy for the intermediate arithmetic
Attributes
- Returns
-
the row-major cells of the unit lower-triangular
L, the upper-triangularUand the permutationP
Concrete fields
The most cells a block operation may produce, checked before anything is built.
The most cells a block operation may produce, checked before anything is built.
Assembly allocates one node per cell, so the cost is memory and time per cell rather than a dense array's eight bytes. Measured (F_0055, JVM, warm): repmat([[1]], 1000, 1000) — one million cells — assembles and collapses in 126 ms, a million-cell _Matrix holding about 96 MB; the next decade, ten million cells, took 1.9 s and about 937 MB. The MaxSampleCount rule: an uncapped size is an out-of-memory error, not a refusal.
The default of core.Limit.MaxMatrixCells (F_0124): every node reads its environment's value, which a library caller raises through core.Environment.withLimit.