pub fn leastsq(
fun: impl FnMut(&[f64]) -> Vec<f64>,
jac: Option<JacobianFn<'_>>,
x0: &[f64],
options: LmOptions,
) -> Result<LmResult, ErrorsJSL>Expand description
Minimises ‖F(x)‖² by MINPACK’s Levenberg-Marquardt method (SciPy’s leastsq; lmder with
an analytic Jacobian, lmdif with forward differences). Each iteration factorises the
Jacobian J P = Q R once, then finds by lmpar the damping λ whose step
min ‖J p + F‖² + λ‖D p‖² fits the trust region ‖D p‖ ≤ Δ, with D the running maximum of
the column norms of J (MINPACK’s mode = 1); Δ grows or shrinks with the ratio of actual
to predicted reduction. jac returns the m × n Jacobian by rows.