numra_linalg/lib.rs
1#![allow(clippy::needless_range_loop)]
2#![allow(clippy::useless_vec)]
3
4//! Linear algebra abstractions for Numra.
5//!
6//! This crate provides matrix operations and linear solvers built on [faer].
7//!
8//! # Design
9//!
10//! The [`Matrix`] trait provides a backend-agnostic interface for matrix operations.
11//! The primary implementation wraps faer's `Mat<S>` type.
12//!
13//! # Example
14//!
15//! ```rust
16//! use numra_linalg::{Matrix, DenseMatrix};
17//!
18//! // Create a 3x3 matrix
19//! let mut a: DenseMatrix<f64> = DenseMatrix::zeros(3, 3);
20//! a.set(0, 0, 2.0);
21//! a.set(1, 1, 3.0);
22//! a.set(2, 2, 4.0);
23//!
24//! // Solve Ax = b
25//! let b = vec![1.0, 2.0, 3.0];
26//! let x = a.solve(&b).unwrap();
27//!
28//! assert!((x[0] - 0.5).abs() < 1e-10);
29//! assert!((x[1] - 2.0/3.0).abs() < 1e-10);
30//! assert!((x[2] - 0.75).abs() < 1e-10);
31//! ```
32//!
33//! Author: Moussa Leblouba
34//! Date: 9 February 2026
35//! Modified: 2 May 2026
36
37pub use numra_core::LinalgError;
38pub use numra_core::Scalar;
39
40mod cholesky;
41mod eigen;
42pub mod iterative;
43mod lu;
44mod matrix;
45pub mod preconditioner;
46mod qr;
47mod sparse;
48mod svd;
49
50pub use cholesky::CholeskyFactorization;
51pub use eigen::{EigenDecomposition, SymEigenDecomposition};
52pub use iterative::{bicgstab, cg, gmres, minres, pcg, IterativeOptions, IterativeResult};
53pub use lu::{LUFactorization, LUSolver};
54pub use matrix::{DenseMatrix, Matrix};
55pub use preconditioner::{IdentityPreconditioner, Ilu0, Jacobi, Preconditioner, Ssor};
56pub use qr::QRFactorization;
57pub use sparse::{SparseCholesky, SparseLU, SparseMatrix};
58pub use svd::{SvdDecomposition, ThinSvdDecomposition};