Skip to main content

tiny_solver/linear/
sparse.rs

1#[non_exhaustive]
2#[derive(Default, Clone)]
3pub enum LinearSolverType {
4    #[default]
5    SparseCholesky,
6    SparseQR,
7}
8
9pub trait SparseLinearSolver {
10    /// Solves the least-squares problem `min ||J * dx + r||` for `dx`.
11    fn solve(
12        &mut self,
13        residuals: &faer::Mat<f64>,
14        jacobians: &faer::sparse::SparseColMat<usize, f64>,
15    ) -> Option<faer::Mat<f64>>;
16    /// Solves `jtj * dx = jtr` for `dx`, where the caller passes the normal
17    /// equations already assembled, i.e. `jtj = J^T * J` and `jtr = J^T * -r`.
18    fn solve_jtj(
19        &mut self,
20        jtr: &faer::Mat<f64>,
21        jtj: &faer::sparse::SparseColMat<usize, f64>,
22    ) -> Option<faer::Mat<f64>>;
23}