Skip to main content

Tower3

Struct Tower3 

Source
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 third-tensor arithmetic but skips the K⁴ fourth-tensor product/composition that otherwise dominates the per-row cost.

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

Implementations§

Source§

impl<const K: usize> Tower3<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 (order ≤ 3) Leibniz product. The v/g/h/t3 channels match Tower4::mul term-for-term.

Source

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.

Source

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

Multiply every channel by a plain scalar.

Trait Implementations§

Source§

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

Source§

type Output = Tower3<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> Clone for Tower3<K>

Source§

fn clone(&self) -> Tower3<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 Tower3<K>

Source§

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

Source§

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

Formats the value using the given formatter. Read more

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