conspire/math/optimize/linear_solve/mod.rs
1use crate::math::Vector;
2
3/// The built-in direct linear solver.
4///
5/// A sparse factorization when the problem
6/// offers one, a dense factorization otherwise.
7#[derive(Clone, Copy, Debug, Default)]
8pub struct Direct;
9
10/// A way of solving the linear system a Newton step is made of.
11///
12/// The tangent is the one this solver can work from, as the problem hands it
13/// out. Choosing a solver for a problem that cannot supply that tangent is
14/// refused at compile time.
15pub trait LinearSolver {
16 /// The tangent this solver works from.
17 type Tangent;
18 /// The decrement over the retained variables, given the tangent at the
19 /// current state and the residual over those variables.
20 fn solve(
21 &self,
22 tangent: Self::Tangent,
23 retained: &[usize],
24 residual: &Vector,
25 ) -> Result<Vector, String>;
26}