Skip to main content

apply_r

Function apply_r 

Source
pub fn apply_r(matrix: &ResolutionMatrix, spectrum: &[f64]) -> Vec<f64>
Expand description

Apply a compiled ResolutionMatrix to a spectrum on the same target grid the matrix was compiled for.

For finite spectra, the output is numerically equivalent to ResolutionPlan::apply on the same spectrum within 1e-12 relative tolerance per element; not bit-exact, because CSR matvec sums in column order while ResolutionPlan::apply sums in entry order.

§Non-finite and near-overflow inputs

See ResolutionPlan::compile_to_matrix for the full contract on NaN / ±∞ spectra and on near-f64::MAX finite spectra — the equivalence bound does not extend to either. Production forward models feed Beer-Lambert transmissions (T ∈ [0, 1]) so the distinction never arises in practice.

§Panics

Panics if spectrum.len() != matrix.len(). Use apply_resolution_with_matrix for a checked entrypoint that returns ResolutionError::LengthMismatch instead.