Skip to main content

Tower4

Struct Tower4 

Source
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: f64

Value ℓ.

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

Source

pub fn zero() -> Self

The additive identity.

Source

pub fn constant(c: f64) -> Self

A constant: value c, all derivatives zero.

Source

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.

Source

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.

Source

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

Source

pub fn scale(&self, s: f64) -> Self

Multiply every channel by a plain scalar.

Source

pub fn exp(&self) -> Self

e^self.

Source

pub fn ln(&self) -> Self

ln(self). Caller guarantees positivity (likelihood programs do).

Source

pub fn recip(&self) -> Self

1/self.

Source

pub fn sqrt(&self) -> Self

√self. Caller guarantees positivity.

Source

pub fn powf(&self, a: f64) -> Self

self^a for real exponent a. Caller guarantees a positive base.

Source

pub fn ln_gamma(&self) -> Self

ln Γ(self). Caller guarantees positivity.

Source

pub fn digamma(&self) -> Self

ψ(self), the digamma function. Caller guarantees positivity.

Source

pub fn trigamma(&self) -> Self

ψ′(self), the trigamma function. Caller guarantees positivity.

Source

pub fn third_contracted(&self, dir: &[f64; K]) -> [[f64; K]; K]

Contract t3 with one primary-space direction: out[a][b] = Σ_c t3[a][b][c] · dir[c] — exactly the row_third_contracted shape.

Source

pub fn fourth_contracted(&self, u: &[f64; K], w: &[f64; K]) -> [[f64; K]; K]

Contract t4 with two primary-space directions: out[a][b] = Σ_{c,d} t4[a][b][c][d] · u[c] · v[d] — exactly the row_fourth_contracted shape.

Trait Implementations§

Source§

impl<const K: usize> Add for Tower4<K>

Source§

type Output = Tower4<K>

The resulting type after applying the + operator.
Source§

fn add(self, o: Self) -> Self

Performs the + operation. Read more
Source§

impl<const K: usize> Add<f64> for Tower4<K>

Source§

type Output = Tower4<K>

The resulting type after applying the + operator.
Source§

fn add(self, c: f64) -> Self

Performs the + operation. Read more
Source§

impl<const K: usize> Clone for Tower4<K>

Source§

fn clone(&self) -> Tower4<K>

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<const K: usize> Copy for Tower4<K>

Source§

impl<const K: usize> Debug for Tower4<K>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const K: usize> Div for Tower4<K>

Source§

type Output = Tower4<K>

The resulting type after applying the / operator.
Source§

fn div(self, o: Self) -> Self

Performs the / operation. Read more
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.

Source§

fn constant(c: f64) -> Self

A constant: value c, every derivative channel zero.
Source§

fn variable(x: f64, axis: usize) -> Self

The seeded variable 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 value(&self) -> f64

The value channel ℓ(p).
Source§

fn add(&self, o: &Self) -> Self

Exact truncated Leibniz sum self + o.
Source§

fn sub(&self, o: &Self) -> Self

Exact truncated Leibniz difference self − o.
Source§

fn mul(&self, o: &Self) -> Self

Exact truncated Leibniz product self · o.
Source§

fn neg(&self) -> Self

Negate every channel.
Source§

fn scale(&self, s: f64) -> Self

Multiply every channel by a plain scalar s.
Source§

fn compose_unary(&self, d: [f64; 5]) -> Self

Exact multivariate Faà di Bruno composition f ∘ self, given the outer derivative stack d = [f(u), f′(u), f″(u), f‴(u), f⁗(u)] at u = self.value(). Read more
Source§

fn exp(&self) -> Self

e^self. Convenience for tame arguments (see module stability note).
Source§

fn sqrt(&self) -> Self

√self. Caller guarantees positivity.
Source§

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 recip(&self) -> Self

1/self.
Source§

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

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

ψ(self) = d/dx ln Γ(x) (digamma). Caller guarantees a positive argument. Same hand-certified stack crate::jet_tower::digamma_derivative_stack.
Source§

impl<const K: usize> Mul for Tower4<K>

Source§

type Output = Tower4<K>

The resulting type after applying the * operator.
Source§

fn mul(self, o: Self) -> Self

Performs the * operation. Read more
Source§

impl<const K: usize> Mul<f64> for Tower4<K>

Source§

type Output = Tower4<K>

The resulting type after applying the * operator.
Source§

fn mul(self, c: f64) -> Self

Performs the * operation. Read more
Source§

impl<const K: usize> Neg for Tower4<K>

Source§

type Output = Tower4<K>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<const K: usize> Sub for Tower4<K>

Source§

type Output = Tower4<K>

The resulting type after applying the - operator.
Source§

fn sub(self, o: Self) -> Self

Performs the - operation. Read more
Source§

impl<const K: usize> Sub<f64> for Tower4<K>

Source§

type Output = Tower4<K>

The resulting type after applying the - operator.
Source§

fn sub(self, c: f64) -> Self

Performs the - operation. Read more

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> ClosedNeg for T
where T: Neg<Output = T>,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V