pub trait ForwardModel {
// Required methods
fn predict(&self, params: &[f64]) -> Result<Vec<f64>, FittingError>;
fn n_data(&self) -> usize;
fn n_params(&self) -> usize;
// Provided method
fn jacobian(
&self,
_params: &[f64],
_free_param_indices: &[usize],
_y_current: &[f64],
) -> Option<Vec<Vec<f64>>> { ... }
}Expand description
Solver-agnostic forward model.
Implementations provide the model prediction and (optionally) its analytical Jacobian. Solvers wrap this trait to compute solver-specific objectives (chi-squared, Poisson NLL, etc.).
Required Methods§
Provided Methods§
Sourcefn jacobian(
&self,
_params: &[f64],
_free_param_indices: &[usize],
_y_current: &[f64],
) -> Option<Vec<Vec<f64>>>
fn jacobian( &self, _params: &[f64], _free_param_indices: &[usize], _y_current: &[f64], ) -> Option<Vec<Vec<f64>>>
Analytical Jacobian (column-major layout).
Returns a Vec of column vectors: result[j] is the j-th column
(partial derivatives of all data points w.r.t. the j-th free
parameter), so result[j][i] = ∂predict[i] / ∂params[free_param_indices[j]].
Only the columns corresponding to free_param_indices are needed.
Returns None to signal “use finite differences” (the default).
y_current is the output of predict(params), provided so
implementations can avoid redundant computation.