Skip to main content

apply_resolution_with_plan

Function apply_resolution_with_plan 

Source
pub fn apply_resolution_with_plan(
    plan: Option<&ResolutionPlan>,
    energies: &[f64],
    spectrum: &[f64],
    resolution: &ResolutionFunction,
) -> Result<Vec<f64>, ResolutionError>
Expand description

Apply resolution broadening, optionally via a pre-built ResolutionPlan.

When plan is Some(p) and resolution is a tabulated kernel, p.apply(spectrum) runs the cached per-target broadening inner loop — the expensive TOF / kernel-interpolation / bracket work was already captured at plan build time.

When plan is None, or when resolution is Gaussian, the call forwards to apply_resolution and is byte-identical to the un-planned path.

§Errors

  • Returns the same errors as apply_resolution on the non-plan path.
  • Returns ResolutionError::LengthMismatch if the plan was built for a different-length grid than energies, or if energies.len() != spectrum.len().
  • Returns ResolutionError::PlanGridMismatch if the plan was built for a different grid of the same length — the cached (lo_idx, frac, weight) entries encode brackets into the old grid and would silently produce a wrong broadened spectrum if applied.