pub struct Tower4<const K: usize> {
pub v: f64,
pub g: [f64; K],
pub h: [[f64; K]; K],
pub t3: [[[f64; K]; K]; K],
pub t4: [[[[f64; K]; K]; K]; K],
}Expand description
Truncated fourth-order multivariate Taylor scalar in K variables.
See the module documentation for semantics and conventions. Copy is
intentional despite the size (2 KiB at K=4): towers are per-row
temporaries that live entirely in registers/stack during a row program,
and value semantics keep program code readable (a * b + c).
Fields§
§v: f64Value ℓ.
g: [f64; K]Gradient ∂ℓ/∂p_a.
h: [[f64; K]; K]Hessian ∂²ℓ/∂p_a∂p_b (symmetric).
t3: [[[f64; K]; K]; K]Third derivatives ∂³ℓ/∂p_a∂p_b∂p_c (fully symmetric).
t4: [[[[f64; K]; K]; K]; K]Fourth derivatives ∂⁴ℓ/∂p_a∂p_b∂p_c∂p_d (fully symmetric).
Implementations§
Source§impl<const K: usize> Tower4<K>
impl<const K: usize> Tower4<K>
Sourcepub fn variable(value: f64, idx: usize) -> Self
pub fn variable(value: f64, idx: usize) -> Self
The seeded variable p_idx with current value value:
unit first derivative in slot idx, zero elsewhere and above.
Sourcepub fn mul(&self, o: &Self) -> Self
pub fn mul(&self, o: &Self) -> Self
Exact truncated Leibniz product.
Every output entry D_S(ab) = Σ_{T ⊆ S} D_T(a) · D_{S∖T}(b) is summed
by the shared [jet_algebra::leibniz_product] subset walker (#1151),
the same kernel MultiDirJet::mul uses; the two layouts differ only in
how a slot-group selects a derivative.
Sourcepub fn compose_unary(&self, d: [f64; 5]) -> Self
pub fn compose_unary(&self, d: [f64; 5]) -> Self
Exact multivariate Faà di Bruno composition f ∘ self.
d = [f(u), f′(u), f″(u), f‴(u), f⁗(u)] evaluated at u = self.v —
the SAME [f64; 5] stack shape the families’ existing
unary_derivatives_* helpers produce, so those special-function
stacks (Φ, log-Φ, normal pdf, …) plug in directly.
The order-m output sums over the set partitions of the m indices
(Bell(3) = 5 terms at order 3, Bell(4) = 15 at order 4), grouped by
block count: each partition into r blocks contributes
f⁽ʳ⁾ · Π_blocks D_block(u).
Sourcepub fn powf(&self, a: f64) -> Self
pub fn powf(&self, a: f64) -> Self
self^a for real exponent a. Caller guarantees a positive base.
Trait Implementations§
impl<const K: usize> Copy for Tower4<K>
Source§impl<const K: usize> JetScalar<K> for Tower4<K>
The full dense crate::jet_tower::Tower4 is itself a JetScalar: it
carries EVERY channel, so a row expression written ONCE against JetScalar
can be evaluated at Tower4 to obtain the full (v, g, H, t3, t4) in one
pass. This is BOTH the #932 oracle ground truth the packed Order2 /
OneSeed / TwoSeed scalars are pinned against, AND a production scalar:
a family whose uncontracted third / fourth derivative tensors are needed
(the BMS rigid third_full / fourth_full caches) evaluates the SAME
generic row-NLL expression at Tower4 and reads .t3 / .t4 off the
result — so the dense tensors come from the single source of truth, not a
separately hand-written jet. The packed scalars serve the consumers that
need only (v, g, H) (Order2) or one / two contractions
(OneSeed / TwoSeed) without paying for the dense tensors.
impl<const K: usize> JetScalar<K> for Tower4<K>
The full dense crate::jet_tower::Tower4 is itself a JetScalar: it
carries EVERY channel, so a row expression written ONCE against JetScalar
can be evaluated at Tower4 to obtain the full (v, g, H, t3, t4) in one
pass. This is BOTH the #932 oracle ground truth the packed Order2 /
OneSeed / TwoSeed scalars are pinned against, AND a production scalar:
a family whose uncontracted third / fourth derivative tensors are needed
(the BMS rigid third_full / fourth_full caches) evaluates the SAME
generic row-NLL expression at Tower4 and reads .t3 / .t4 off the
result — so the dense tensors come from the single source of truth, not a
separately hand-written jet. The packed scalars serve the consumers that
need only (v, g, H) (Order2) or one / two contractions
(OneSeed / TwoSeed) without paying for the dense tensors.
Source§fn variable(x: f64, axis: usize) -> Self
fn variable(x: f64, axis: usize) -> Self
p_axis at value x: unit first derivative in slot
axis, all higher channels zero. (The nilpotent / cross channels of the
directional scalars are seeded zero — callers set ε/δ directions through
the scalar-specific OneSeed::seed_direction / TwoSeed::seed.)Source§fn compose_unary(&self, d: [f64; 5]) -> Self
fn compose_unary(&self, d: [f64; 5]) -> Self
f ∘ self, given the outer
derivative stack d = [f(u), f′(u), f″(u), f‴(u), f⁗(u)] at
u = self.value(). Read moreSource§fn ln(&self) -> Self
fn ln(&self) -> Self
ln(self). Caller guarantees positivity. Same derivative stack
crate::jet_tower::Tower4::ln uses, so any program written over both
matches term-for-term.Source§fn powf(&self, a: f64) -> Self
fn powf(&self, a: f64) -> Self
self^a for real exponent a. Caller guarantees a positive base.
Mirrors crate::jet_tower::Tower4::powf (falling-factorial stack).Source§fn ln_gamma(&self) -> Self
fn ln_gamma(&self) -> Self
ln Γ(self). Caller guarantees a positive argument. Uses the SAME
hand-certified derivative stack crate::jet_tower::Tower4::ln_gamma
consumes (crate::jet_tower::ln_gamma_derivative_stack), so any
program written over both matches term-for-term.Source§fn digamma(&self) -> Self
fn digamma(&self) -> Self
ψ(self) = d/dx ln Γ(x) (digamma). Caller guarantees a positive
argument. Same hand-certified stack
crate::jet_tower::digamma_derivative_stack.Auto Trait Implementations§
impl<const K: usize> Freeze for Tower4<K>
impl<const K: usize> RefUnwindSafe for Tower4<K>
impl<const K: usize> Send for Tower4<K>
impl<const K: usize> Sync for Tower4<K>
impl<const K: usize> Unpin for Tower4<K>
impl<const K: usize> UnsafeUnpin for Tower4<K>
impl<const K: usize> UnwindSafe for Tower4<K>
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,
impl<T> ClosedNeg for Twhere
T: Neg<Output = 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.