Skip to main content

MeasureState

Struct MeasureState 

Source
pub struct MeasureState<F: SemiflowFloat, const D: usize> { /* private fields */ }
Expand description

Sparse signed-measure state on M(ℝ^D) for adjoint Fokker-Planck Chernoff. Representation: finite weighted-Dirac sum + optional Gaussian background. Lemma A.1 pushes each Dirac at x to four children x±h, x+k, x with weights (1/4, 1/4, 1/2, τc). The 4^n blow-up is resolved by gridless.rs.

Implementations§

Source§

impl<F: SemiflowFloat, const D: usize> MeasureState<F, D>

Source

pub fn dirac(position: [F; D], weight: F) -> Self

Construct a single Dirac δ_position with signed weight.

Source

pub fn gaussian( mean: [F; D], variance: F, weight: F, ) -> Result<Self, SemiflowError>

Construct a Gaussian-smoothed measure (isotropic variance).

§Errors

SemiflowError::DomainViolation if variance ≤ 0 or weight non-finite.

Source

pub fn from_particles(particles: &[([F; D], F)]) -> Self

Construct from (position, weight) pairs; no validity checks.

Source

pub fn total_variation(&self) -> F

Total-variation norm ‖ρ‖_TV — rate modulator in Theorem A.2 (§38.4).

Source

pub fn second_moment(&self) -> F

Second moment ⟨x², ρ⟩ — tightness monitor per Lemma A.3 (§38.5).

Source

pub fn pair<G: Fn(&[F; D]) -> F>(&self, f: G) -> F

Dual pairing ⟨f, ρ⟩ for a test function f ∈ C_b. Gaussians use point evaluation at the mean.

Source

pub fn n_diracs(&self) -> usize

Number of Dirac components (diagnostic).

Source

pub fn first_moment(&self) -> [F; D]

Mass-weighted centre of mass (first moment), per axis (§38.12).

Returns E[x_d] = (Σ_diracs w·pos[d] + Σ_gauss w·mean[d]) / mass for each axis d, where mass = total_variation().

If mass = 0, returns all-zeros (undefined mean for the zero measure).

Source

pub fn variance(&self) -> F

Total scalar variance Var = E[|x|²] − |E[x]|² (§38.12).

Uses mass-normalised second moment: E[|x|²] = second_moment() / mass. Returns 0 if mass = 0.

Source

pub fn variance_per_axis(&self) -> [F; D]

Per-axis variance Var_d = E[x_d²] − (E[x_d])² (§38.12).

Returns all-zeros if mass = 0.

Source

pub fn to_flat_buffers_d1(&self) -> (Vec<F>, Vec<F>)
where [F; 1]: Sized, F: Copy,

Extract Dirac positions and weights as (positions, weights) (D=1 binding ABI). Gaussians are not included; use on pure-Dirac states from apply_into. Used by G_BINDING_ADJOINT_FP_PARITY integration tests.

Trait Implementations§

Source§

impl<F: Clone + SemiflowFloat, const D: usize> Clone for MeasureState<F, D>

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
Source§

impl<F: SemiflowFloat, const D: usize> State<F> for MeasureState<F, D>

State<F> impl for MeasureState<F, D> (dynamic-length signed measure).

len() = atom count (grows after axpy_into). axpy_into APPENDS atoms; norm_sup() returns ‖ρ‖_TV. Fixed-length invariants from GridFn1D do NOT apply here.

Source§

fn norm_sup(&self) -> F

Returns ‖ρ‖_TV as a surrogate (TV-norm is the natural measure norm).

Source§

fn len(&self) -> usize

Number of degrees of freedom (grid nodes, graph nodes, etc.).
Source§

fn axpy_into(&mut self, alpha: F, src: &Self)

In-place AXPY: self ← self + alpha · src. No allocation. Read more
Source§

fn copy_from(&mut self, src: &Self)

Node-wise copy: self ← src. No allocation. Read more
Source§

fn zero_into(&mut self)

Zero all nodes: self[i] ← 0 for all i. len() unchanged.
Source§

fn scale_into(&mut self, k: F)

In-place scale: self ← k · self. Read more
Source§

fn is_empty(&self) -> bool

Returns true if this state has no nodes.

Auto Trait Implementations§

§

impl<F, const D: usize> Freeze for MeasureState<F, D>
where Vec<([F; D], F)>: Freeze, Vec<GaussianComponent<F, D>>: Freeze,

§

impl<F, const D: usize> RefUnwindSafe for MeasureState<F, D>
where Vec<([F; D], F)>: RefUnwindSafe, Vec<GaussianComponent<F, D>>: RefUnwindSafe,

§

impl<F, const D: usize> Send for MeasureState<F, D>
where Vec<([F; D], F)>: Send, Vec<GaussianComponent<F, D>>: Send,

§

impl<F, const D: usize> Sync for MeasureState<F, D>
where Vec<([F; D], F)>: Sync, Vec<GaussianComponent<F, D>>: Sync,

§

impl<F, const D: usize> Unpin for MeasureState<F, D>
where Vec<([F; D], F)>: Unpin, Vec<GaussianComponent<F, D>>: Unpin,

§

impl<F, const D: usize> UnsafeUnpin for MeasureState<F, D>
where Vec<([F; D], F)>: UnsafeUnpin, Vec<GaussianComponent<F, D>>: UnsafeUnpin,

§

impl<F, const D: usize> UnwindSafe for MeasureState<F, D>
where Vec<([F; D], F)>: UnwindSafe, Vec<GaussianComponent<F, D>>: UnwindSafe,

Blanket Implementations§

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<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.