levenberg_marquardt/
problem.rs

1use nalgebra::{
2    ComplexField, Dim, Matrix, Vector,
3    storage::{IsContiguous, RawStorageMut, Storage},
4};
5
6/// A least squares minimization problem.
7///
8/// This is what [`LevenbergMarquardt`](struct.LevenbergMarquardt.html) needs
9/// to compute the residuals and the Jacobian. See the [module documentation](index.html)
10/// for a usage example.
11pub trait LeastSquaresProblem<F, M, N>
12where
13    F: ComplexField + Copy,
14    N: Dim,
15    M: Dim,
16{
17    /// Storage type used for the residuals. Use `nalgebra::storage::Owned<F, M>`
18    /// if you want to use `VectorN` or `MatrixMN`.
19    type ResidualStorage: RawStorageMut<F, M> + Storage<F, M> + IsContiguous;
20    type JacobianStorage: RawStorageMut<F, M, N> + Storage<F, M, N> + IsContiguous;
21    type ParameterStorage: RawStorageMut<F, N> + Storage<F, N> + IsContiguous + Clone;
22
23    /// Set the stored parameters `$\vec{x}$`.
24    fn set_params(&mut self, x: &Vector<F, N, Self::ParameterStorage>);
25
26    /// Get the current parameter vector `$\vec{x}$`.
27    fn params(&self) -> Vector<F, N, Self::ParameterStorage>;
28
29    /// Compute the residual vector.
30    fn residuals(&self) -> Option<Vector<F, M, Self::ResidualStorage>>;
31
32    /// Compute the Jacobian of the residual vector.
33    fn jacobian(&self) -> Option<Matrix<F, M, N, Self::JacobianStorage>>;
34}