Skip to main content

Module matrix

Module matrix 

Source
Expand description

Symbolic matrix type and operations. Symbolic matrix type.

Provides Matrix, a dense matrix of symbolic expressions with exact arithmetic: construction, arithmetic operators, determinant (Bareiss / Berkowitz), inverse, linear solving, characteristic polynomial, eigenvalues/eigenvectors, diagonalization, Jordan form, matrix exponential, LU/RREF, subspaces and code generation.

Additional decompositions (QR, LDLᵀ, Gram–Schmidt), structure tests (is_symmetric, is_positive_definite, …) and norms live in matrix_decomp but are all methods on Matrix.

§API conventions

  • Shape preconditions (non-square input, mismatched dimensions, empty data) return SymplexError::InvalidArgument.
  • Mathematical failure (singular matrix, not diagonalizable, eigenvalue solver gave up, …) returns SymplexError::ComputationFailed.
  • Indexing (get, row, col, m[(i, j)], submatrix) panics on out-of-bounds indices, exactly like slice indexing; use Matrix::try_get for a checked variant.
  • Sized constructors (zeros, identity, from_fn) panic on a zero dimension — that is a programming error, not a data error. Data constructors (new, TryFrom<Vec<Vec<Ex>>>, from_i64) return Result.
  • Structural queries (is_symmetric, is_diagonalizable, …) are three-valued Option<bool>: None means “cannot decide symbolically”.
  • The eigen-family (eigenvals, eigenvects, diagonalize, jordan_form, matrix_exp) creates its own internal bound variable; the reserved name never appears in results. Only Matrix::char_poly takes a caller-supplied variable because the result is a polynomial in it.

Structs§

CodegenOptions
Configuration for Rust code generation.
Matrix
A dense matrix of symbolic expressions.

Enums§

MathBackend
Math function dispatch strategy for generated code.
Precision
Floating-point precision for generated code.

Constants§

EXPRESSION_BUDGET
Upper bound on the total expression-tree size (nodes, counted without sharing) of the operands and intermediate results of the symbolic algorithms that can swell: Matrix::det, Matrix::inv, Matrix::solve, Matrix::diagonalize, Matrix::jordan_form, Matrix::matrix_exp and Matrix::qr.

Functions§

cross
Cross product of two 3×1 column vectors.
dot
Dot product of two column vectors (n×1 matrices).
jacobian
Build the Jacobian matrix of funcs with respect to vars: J[i][j] = ∂funcs[i] / ∂vars[j].