pub trait LinearSolver<M: LinearizationMode> {
// Required methods
fn solve_normal_equation(
&mut self,
residuals: &Mat<f64>,
jacobian: &M::Jacobian,
) -> LinAlgResult<Mat<f64>>;
fn solve_augmented_equation(
&mut self,
residuals: &Mat<f64>,
jacobian: &M::Jacobian,
lambda: f64,
) -> LinAlgResult<Mat<f64>>;
fn get_hessian(&self) -> Option<&M::Hessian>;
fn get_gradient(&self) -> Option<&Mat<f64>>;
// Provided methods
fn compute_covariance_matrix(&mut self) -> Option<&Mat<f64>> { ... }
fn get_covariance_matrix(&self) -> Option<&Mat<f64>> { ... }
}Expand description
Unified linear solver interface parameterized by LinearizationMode.
This is the single trait implemented by all linear solvers. When M is
a concrete type (e.g., SparseMode), this trait is object-safe and can
be used as dyn LinearSolver<SparseMode> or dyn LinearSolver<DenseMode>.
- Sparse solvers (
SparseCholeskySolver,SparseQRSolver,SchurSolverAdapter) implementLinearSolver<SparseMode>. - Dense solvers (
DenseCholeskySolver,DenseQRSolver) implementLinearSolver<DenseMode>.
Required Methods§
Sourcefn solve_normal_equation(
&mut self,
residuals: &Mat<f64>,
jacobian: &M::Jacobian,
) -> LinAlgResult<Mat<f64>>
fn solve_normal_equation( &mut self, residuals: &Mat<f64>, jacobian: &M::Jacobian, ) -> LinAlgResult<Mat<f64>>
Solve the normal equations: (J^T · J) · dx = −J^T · r
Sourcefn solve_augmented_equation(
&mut self,
residuals: &Mat<f64>,
jacobian: &M::Jacobian,
lambda: f64,
) -> LinAlgResult<Mat<f64>>
fn solve_augmented_equation( &mut self, residuals: &Mat<f64>, jacobian: &M::Jacobian, lambda: f64, ) -> LinAlgResult<Mat<f64>>
Solve the augmented equations: (J^T · J + λI) · dx = −J^T · r
Sourcefn get_hessian(&self) -> Option<&M::Hessian>
fn get_hessian(&self) -> Option<&M::Hessian>
Get the cached Hessian matrix (J^T · J) from the last solve
Sourcefn get_gradient(&self) -> Option<&Mat<f64>>
fn get_gradient(&self) -> Option<&Mat<f64>>
Get the cached gradient vector (J^T · r) from the last solve
Provided Methods§
Sourcefn compute_covariance_matrix(&mut self) -> Option<&Mat<f64>>
fn compute_covariance_matrix(&mut self) -> Option<&Mat<f64>>
Compute the covariance matrix (H^{-1}) by inverting the cached Hessian.
Returns None for solvers that do not support covariance estimation
(e.g., QR solvers, Schur complement solvers). Only Cholesky-based
solvers provide a real implementation.
Sourcefn get_covariance_matrix(&self) -> Option<&Mat<f64>>
fn get_covariance_matrix(&self) -> Option<&Mat<f64>>
Get the cached covariance matrix (H^{-1}) computed from the Hessian.
Returns None if covariance has not been computed or is not supported.