pub struct Nlls<'a> { /* private fields */ }Expand description
Nonlinear least-squares solver wrapping AOCL’s RAlfit family.
Provide a residual function (mandatory) and optionally a Jacobian.
If the Jacobian is omitted, AOCL will estimate derivatives by finite
differences. After Nlls::fit, the optimised coefficients are in
the user’s input vector and a 100-element rinfo of solver stats
can be retrieved via Nlls::info.
Implementations§
Source§impl<'a> Nlls<'a>
impl<'a> Nlls<'a>
Sourcepub fn new<F>(n_coef: usize, n_res: usize, resfun: F) -> Result<Self>
pub fn new<F>(n_coef: usize, n_res: usize, resfun: F) -> Result<Self>
Build a new NLLS solver with n_coef coefficients and n_res
residuals. resfun evaluates r(x); finite differences will
estimate the Jacobian unless one is supplied via
Nlls::with_jacobian.
Sourcepub fn with_jacobian<G>(self, resgrd: G) -> Result<Self>
pub fn with_jacobian<G>(self, resgrd: G) -> Result<Self>
Attach an analytic Jacobian. Layout follows the "storage scheme"
option set on the underlying handle (default row-major).
Sourcepub fn handle_mut(&mut self) -> &mut Handle
pub fn handle_mut(&mut self) -> &mut Handle
Borrow the underlying handle to set NLLS-specific options
("ralfit iteration limit", "storage scheme", etc.).
Sourcepub fn set_bounds(
&mut self,
lower: Option<&mut [f64]>,
upper: Option<&mut [f64]>,
) -> Result<()>
pub fn set_bounds( &mut self, lower: Option<&mut [f64]>, upper: Option<&mut [f64]>, ) -> Result<()>
Constrain coefficients to lie within lower[i] <= x[i] <= upper[i].
Pass None for an unbounded side; the slices must have length
n_coef.
Sourcepub fn set_weights(&mut self, weights: &mut [f64]) -> Result<()>
pub fn set_weights(&mut self, weights: &mut [f64]) -> Result<()>
Set per-residual weights w_i = √W_ii (length n_res).