Skip to main content

least_squares_lsmr

Function least_squares_lsmr 

Source
pub fn least_squares_lsmr<J: LinearOperator>(
    fun: impl Fn(&[f64]) -> Vec<f64>,
    jac: impl Fn(&[f64]) -> J,
    x0: &[f64],
    lb: &[f64],
    ub: &[f64],
    options: LeastSquaresOptions,
) -> Result<BoundedLeastSquaresResult, ErrorsJSL>
Expand description

The trust-region reflective method with an iterative trust-region solver, for large or sparse problems (SciPy’s least_squares(method='trf', tr_solver='lsmr')). The Jacobian is any LinearOperator (a sparse CsrMatrix, a dense matrix, or products supplied by closures), used only through products with vectors.

Each iteration solves the regularised Gauss-Newton problem min ‖[J_h; D] p + [f; 0]‖ approximately with lsmr, and then solves the trust-region problem exactly in the two-dimensional subspace spanned by that step and the scaled gradient. As in SciPy, D adds to the Coleman-Li term a regularisation −(m(Δ ĝ)) / Δ² from the best gradient step, which keeps LSMR’s step inside the trust region’s scale. The bounds, step selection and stopping rules are those of least_squares_bounded.