Skip to main content

lm_bounded

Function lm_bounded 

Source
fn lm_bounded<F>(
    resid: F,
    x0: &[f64],
    lb: &[f64],
    ub: &[f64],
    max_iter: usize,
    s: &mut LmScratch,
) -> [f64; 3]
where F: Fn(&[f64], &mut [f64]),
Expand description

Minimise ‖resid(x)‖² over the box [lb, ub] by Levenberg–Marquardt with a forward finite-difference Jacobian and per-step projection onto the box. Sized for the 1–3 parameter DECOMPOSE stages.

resid writes the residual for a parameter vector into the caller’s buffer rather than returning a fresh one, and all other working storage is either a stack array (n ≤ LM_MAX_N) or a buffer in s, so a solve allocates nothing. Only the first x0.len() entries of the returned array are meaningful.