Skip to main content

tiny_solver/linear/
sparse.rs

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