pub struct Tower3<const K: usize> {
pub v: f64,
pub g: [f64; K],
pub h: [[f64; K]; K],
pub t3: [[[f64; K]; K]; K],
}Expand description
Truncated THIRD-order multivariate Taylor scalar in K variables.
The value/gradient/Hessian/third-derivative sibling of Tower4, standing
between Tower2 and Tower4. Every channel it carries (v, g, h,
t3) is computed by the SAME shared Leibniz / Faà-di-Bruno kernels
Tower4 uses for those orders, and the order-≤3 terms of those kernels
read only the order-≤3 channels of their inputs (the order-3 Faà-di-Bruno
partitions never reach the f⁗ stack slot or the inner t4 tensor — see
Tower4::compose_unary). So for any program written over both towers the
order-≤3 outputs are bit-identical: dropping the fourth tensor cannot
perturb the value, gradient, Hessian, or third derivatives.
It exists purely for performance, exactly like Tower2: a consumer that
needs up to third derivatives (the survival location-scale row kernel reads
g, the diagonal h, and the diagonal t3, but never t4) pays the
K³ third-tensor arithmetic but skips the K⁴ fourth-tensor
product/composition that otherwise dominates the per-row cost.
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).
Implementations§
Source§impl<const K: usize> Tower3<K>
impl<const K: usize> Tower3<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 (order ≤ 3) Leibniz product. The v/g/h/t3
channels match Tower4::mul term-for-term.
Sourcepub fn compose_unary(&self, d: [f64; 4]) -> Self
pub fn compose_unary(&self, d: [f64; 4]) -> Self
Exact (order ≤ 3) multivariate Faà di Bruno composition f ∘ self.
d = [f(u), f′(u), f″(u), f‴(u)] evaluated at u = self.v. The
v/g/h/t3 channels match Tower4::compose_unary term-for-term
(which uses only d[0..=3] for those orders), so this is a strict
truncation, not an approximation. The full-order [f64; 5] derivative
stacks the families already produce can be passed by slicing their first
four entries.
Trait Implementations§
impl<const K: usize> Copy for Tower3<K>
Auto Trait Implementations§
impl<const K: usize> Freeze for Tower3<K>
impl<const K: usize> RefUnwindSafe for Tower3<K>
impl<const K: usize> Send for Tower3<K>
impl<const K: usize> Sync for Tower3<K>
impl<const K: usize> Unpin for Tower3<K>
impl<const K: usize> UnsafeUnpin for Tower3<K>
impl<const K: usize> UnwindSafe for Tower3<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> 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.