Expand description
Dense linear algebra implemented entirely in-house (no external backend).
This crate owns the dynamically-sized DVector and DMatrix types used
as the storage backend for tpt-math-linalg and tpt-math-optimize. The
matrices are stored column-major in a plain Vec<T>, so there is no
faer/nalgebra dependency and no license exposure. The arithmetic, norms,
and the partial-pivot-LU solve/inverse are all hand-rolled.
Unlike the old nalgebra-backed path, this crate is the single storage
backend for tpt-math-linalg and tpt-math-optimize, so it owns its own
DVector/DMatrix types (which also resolves an orphan-rule problem for
any external solver trait impls).
§Features
std(default) — enable the allocator and thestdsupport of deps.alloc— signal allocator availability (dynamic vectors need it).
§Examples
use tpt_math_linalg_dense::{DMatrix, DVector};
let a = DVector::from_vec(vec![1.0_f64, 2.0, 3.0]);
let b = DVector::from_vec(vec![4.0_f64, 5.0, 6.0]);
assert_eq!(a.dot(&b), 32.0);
let m = DMatrix::from_row_slice(2, 2, &[1.0_f64, 2.0, 3.0, 4.0]);
let v = DVector::from_vec(vec![1.0_f64, 1.0]);
let mv = m * v;
assert_eq!(mv[0], 3.0);
assert_eq!(mv[1], 7.0);Structs§
- Cholesky
- A Cholesky factorisation
A = L Lᵀof a symmetric positive-definite matrix, kept for repeated solves. - DMatrix
- A dynamically-sized matrix of
T, stored column-major in a contiguousVec((i, j)lives ati + j * nrows). - DVector
- A dynamically-sized column vector of
T, stored as a contiguousVec. - Eigenvalue
- An eigenvalue
re + i·imof a real matrix. - Lu
- A reusable LU factorisation
P A = L Uof a square matrix. - Qr
- A Householder QR factorisation
A = Q Rof a tall (m ≥ n) matrix, used for least-squares solves.Qis kept implicitly as its reflectors. - Solve
Diagnostics - Quality measures for a dense linear solve, from
DMatrix::solve_with_report.
Enums§
- Dense
Error - Errors returned by the fallible dense linear-algebra routines.
Constants§
- ILL_
CONDITIONED_ THRESHOLD - The threshold on
cond · εabove which a solve is flagged.
Functions§
- solve_
banded - Solve
A x = bfor a bandedAwithklsub-diagonals andkusuper-diagonals, by Gaussian elimination with partial pivoting. - solve_
tridiagonal - Solve a tridiagonal system
T x = rhswith the Thomas algorithm in O(n).
Type Aliases§
- SvdFactors
- The factors
(U, σ, V)of a thin singular value decomposition.