pub struct DiffOp<F> { /* private fields */ }diffop only.Expand description
A linear differential operator L = Σ C_α D^α.
Each term is a (coefficient, multi-index) pair. The operator can be
evaluated exactly via DiffOp::eval using JetPlan, or used to build
a SparseSamplingDistribution for stochastic estimation.
§Examples
use echidna::diffop::DiffOp;
// Laplacian in 3 variables: ∂²/∂x₀² + ∂²/∂x₁² + ∂²/∂x₂²
let lap = DiffOp::laplacian(3);
// Biharmonic: ∂⁴/∂x₀⁴ + ∂⁴/∂x₁⁴ + ∂⁴/∂x₂⁴
let bih = DiffOp::biharmonic(3);Implementations§
Source§impl<F: Float> DiffOp<F>
impl<F: Float> DiffOp<F>
Sourcepub fn new(num_vars: usize, terms: Vec<(F, MultiIndex)>) -> Self
pub fn new(num_vars: usize, terms: Vec<(F, MultiIndex)>) -> Self
Create a differential operator from explicit (coefficient, multi-index) pairs.
§Panics
Panics if terms is empty or any multi-index has wrong num_vars.
Sourcepub fn from_orders(num_vars: usize, terms: &[(F, &[u8])]) -> Self
pub fn from_orders(num_vars: usize, terms: &[(F, &[u8])]) -> Self
Create a differential operator from raw order slices.
Each entry is (coefficient, orders_slice).
Sourcepub fn biharmonic(n: usize) -> Self
pub fn biharmonic(n: usize) -> Self
Biharmonic operator: Δ² = (Σ_j ∂²/∂x_j²)².
Expands to Σ_j ∂⁴/∂x_j⁴ + 2 Σ_{j<k} ∂⁴/(∂x_j² ∂x_k²).
For n=1, equivalent to diagonal(1, 4). For n≥2, includes cross terms.
Evaluation via [eval] uses exact jet arithmetic. Stochastic estimation
via stde_sparse requires importance sampling (full deterministic sampling
is biased when coefficients are non-uniform).
Sourcepub fn terms(&self) -> &[(F, MultiIndex)]
pub fn terms(&self) -> &[(F, MultiIndex)]
The terms of the operator.
Sourcepub fn is_diagonal(&self) -> bool
pub fn is_diagonal(&self) -> bool
True if every term has exactly one active variable (no mixed partials).
Sourcepub fn split_by_order(&self) -> Vec<DiffOp<F>>
pub fn split_by_order(&self) -> Vec<DiffOp<F>>
Split an inhomogeneous operator into groups of the same total order.
Returns a vector of DiffOp, each containing terms with the same
total order, sorted by increasing order.
Source§impl<F: Float + TaylorArenaLocal> DiffOp<F>
impl<F: Float + TaylorArenaLocal> DiffOp<F>
Sourcepub fn eval(&self, tape: &BytecodeTape<F>, x: &[F]) -> (F, F)
pub fn eval(&self, tape: &BytecodeTape<F>, x: &[F]) -> (F, F)
Exact evaluation: compute Lu(x) via JetPlan.
Returns (value, operator_value).
Sourcepub fn sparse_distribution(&self) -> SparseSamplingDistribution<F>
pub fn sparse_distribution(&self) -> SparseSamplingDistribution<F>
Build a SparseSamplingDistribution for stochastic estimation.
Requires all terms to have the same total order k (homogeneous operator).
Use split_by_order to decompose inhomogeneous
operators first.
§Panics
Panics if the operator is not homogeneous (mixed total orders).
Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for DiffOp<F>
impl<F> RefUnwindSafe for DiffOp<F>where
F: RefUnwindSafe,
impl<F> Send for DiffOp<F>where
F: Send,
impl<F> Sync for DiffOp<F>where
F: Sync,
impl<F> Unpin for DiffOp<F>where
F: Unpin,
impl<F> UnsafeUnpin for DiffOp<F>
impl<F> UnwindSafe for DiffOp<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.