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