Skip to main content

build_resolution_plan

Function build_resolution_plan 

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

Build a broadening plan for (energies, resolution).

Returns Some(plan) for ResolutionFunction::Tabulated โ€” the plan hoists the per-target TOF / kernel-interpolation / bracket / trap-weight work that would otherwise run on every call to apply_resolution. Returns None for ResolutionFunction::Gaussian โ€” the Gaussian path has no meaningful pixel-invariant kernel structure to cache at this level, so callers fall back to the per-call broadening path with no loss.

Callers that want a single-branch API can unconditionally call apply_resolution_with_plan passing plan.as_ref(); when the plan is None it transparently forwards to the non-plan path and returns byte-identical output.

ยงErrors

Returns ResolutionError::UnsortedEnergies if energies is not non-descending โ€” the same precondition that apply_resolution enforces per-call.