Skip to main content

TruncatedExp4WithCache

Struct TruncatedExp4WithCache 

Source
pub struct TruncatedExp4WithCache { /* private fields */ }
Expand description

TruncatedExp4thDiffusionChernoff with pre-evaluated a(x) half-node cache.

Implements ChernoffFunction identically to the wrapped type but replaces the 4-per-node function-pointer dispatches in apply_g4_at_node_f64 with direct Vec<f64> index reads.

§Construction

use semiflow::{chernoff::ApplyChernoffExt, Grid1D, GridFn1D, TruncatedExp4WithCache};
let grid = Grid1D::new(-4.0, 4.0, 64).unwrap();
let me4c = TruncatedExp4WithCache::with_cached_coefficients(
    |_| 1.0, |_| 0.0, |_| 0.0, 1.0, grid,
);
let u0 = GridFn1D::from_fn(grid, |x| (-x * x).exp());
let u1 = me4c.apply_chernoff(0.001, &u0).unwrap();
assert_eq!(u1.values.len(), 64);

§Caller invariants

Same as TruncatedExp4thDiffusionChernoff. Additionally, a(x) MUST be pure and deterministic — see HalfNodeCoeffCache doc.

See ADR-0034 Amendment 1.

Implementations§

Source§

impl TruncatedExp4WithCache

Source

pub fn with_cached_coefficients( a: fn(f64) -> f64, a_prime: fn(f64) -> f64, a_double_prime: fn(f64) -> f64, a_norm_bound: f64, grid: Grid1D<f64>, ) -> Self

Construct with pre-evaluated a(x) half-node coefficients.

The hot loop indexes the cache instead of calling the closure, enabling SIMD lane saturation in Wave B3.

Memory cost: 4N × 8 bytes ≈ 16 KB at N=512, negligible vs the 2.8 MB per-call baseline measured in iter-3 benchmarks.

§Panics

Does not panic. All grid operations are deterministic.

Trait Implementations§

Source§

impl ChernoffFunction for TruncatedExp4WithCache

Source§

fn order(&self) -> u32

Consistency order 2.

Source§

fn growth(&self) -> Growth<f64>

Growth (M, ω) = (1.0, 0.0).

Source§

fn apply_into( &self, tau: f64, src: &GridFn1D<f64>, dst: &mut GridFn1D<f64>, _scratch: &mut ScratchPool<f64>, ) -> Result<(), SemiflowError>

Allocation-free output override using pre-evaluated coefficient cache.

Uses the same precompute_g4_grids_cached stencil path (including SIMD dispatch) as apply to guarantee bit-identical results. The only savings vs the default bridge: output is written directly into dst instead of returning a new GridFn1D allocation.

The four g-grid GridFn1D intermediates are still heap-allocated per call. Scratch is accepted but unused (GridFn1D state cannot be stored in ScratchPool).

Source§

type S = GridFn1D

The state space type on which S(tau) acts. Read more
Source§

fn apply_adjoint_into( &self, tau: F, src: &Self::S, dst: &mut Self::S, scratch: &mut ScratchPool<F>, ) -> Result<(), SemiflowError>

Apply the TRANSPOSE (adjoint) semigroup exp(τ Aᵀ) src into dst. Read more
Source§

fn plan_len(&self, tau: F, proto: &Self::S) -> Option<(usize, usize)>

Sizes (data, work) of a τ-keyed step plan for states shaped like proto (ADR-0215), or None (default) when the engine has no plan. Read more
Source§

fn fill_plan( &self, tau: F, proto: &Self::S, data: &mut [F], ) -> Result<(), SemiflowError>

Fill data (length plan_len(..).0) for (τ, proto). Read more
Source§

fn apply_planned_into( &self, tau: F, data: &[F], work: &mut [F], src: &Self::S, dst: &mut Self::S, scratch: &mut ScratchPool<F>, ) -> Result<(), SemiflowError>

dst := S(τ) src with a plan data filled by THIS engine for τ, and a work area of length plan_len(..).1. A plan that does not match — another τ, sampling grid, length or engine state, or a truncated buffer — falls back to apply_into. Default: apply_into. Read more
Source§

impl Clone for TruncatedExp4WithCache

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<C, F> Adjointable<F, 1> for C

Source§

fn apply_adjoint_into( &self, tau: F, a: F, b: F, c: F, src: &MeasureState<F, 1>, dst: &mut MeasureState<F, 1>, ) -> Result<(), SemiflowError>

Push-forward one Chernoff step on the measure side (Lemma A.1, §38.3). Read more
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<C, F> ApplyChernoffExt<F> for C
where C: ChernoffFunction<F>, <C as ChernoffFunction<F>>::S: Clone, F: SemiflowFloat,

Source§

fn apply_chernoff( &self, tau: F, src: &Self::S, ) -> Result<Self::S, SemiflowError>

Allocating single-step apply: returns S(tau) src as a fresh state. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.