Skip to main content

Tower3Lane

Struct Tower3Lane 

Source
pub struct Tower3Lane<L: Lane, const K: usize> {
    pub v: L,
    pub g: [L; K],
    pub h: [[L; K]; K],
    pub t3: [[[L; K]; K]; K],
}
Expand description

Lane-batched Tower3 (order-≤3 sibling of Tower4Lane).

Fields§

§v: L

Value channel.

§g: [L; K]

Gradient.

§h: [[L; K]; K]

Hessian.

§t3: [[[L; K]; K]; K]

Third tensor.

Implementations§

Source§

impl<L: Lane, const K: usize> Tower3Lane<L, K>

Source

pub fn zero() -> Self

All-zero tower.

Source

pub fn constant(c: L) -> Self

Constant c (per lane).

Source

pub fn variable(value: L, idx: usize) -> Self

Seeded variable p_idx at per-lane value.

Source

pub fn lane(&self, i: usize) -> Tower3<K>

Extract lane i as a scalar Tower3<K>.

Source

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

Per-channel lane-wise self + o.

Source

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

Per-channel lane-wise self - o.

Source

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

Multiply every channel by the plain scalar s (mirrors Tower3::scale).

Source

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

Leibniz product self · o, term-for-term lift of Tower3::mul.

Source

pub fn compose_unary(&self, d: [L; 4]) -> Self

Faà di Bruno composition f ∘ self, term-for-term lift of Tower3::compose_unary. d = [f, f′, f″, f‴] packed per lane.

Source

pub fn compose_unary_with(&self, stack_fn: impl Fn(f64) -> [f64; 4]) -> Self

Compose with a unary special-function whose [f64; 4] derivative stack is built from the base value through stack_fn, evaluated PER LANE — the batch arm of the generic-over-Lane compose seam (the SIMD twin of Tower3::compose_unary_with, order-≤3 sibling of Tower4Lane::compose_unary_with). The scalar stack_fn is run once per lane at that lane’s own base value (via Lane::unary_with) and packed into [L; 4] for the existing per-lane Self::compose_unary, so lane i is to_bits-identical to self.lane(i).compose_unary_with(stack_fn).

Source

pub fn compose_unary_single_slot(&self, d: [L; 4], slot: usize) -> Self

Single-active-slot fast path, term-for-term lift of Tower3::compose_unary_single_slot.

Trait Implementations§

Source§

impl<L: Clone + Lane, const K: usize> Clone for Tower3Lane<L, K>

Source§

fn clone(&self) -> Tower3Lane<L, 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<L: Copy + Lane, const K: usize> Copy for Tower3Lane<L, K>

Source§

impl<const K: usize> RowJet<K> for Tower3Lane<f64x4, K>

The f64x4 lane Tower3Lane is a RowJet<K> with Value = [f64; 4], the order-≤3 sibling of the Tower4Lane impl. A body that uses N == 5 stacks drops the (unused) fourth-derivative entry here, matching the scalar Tower3 which also carries only up to the third tensor.

Source§

type Value = [f64; 4]

The value channel(s) seen by guard and values: a single f64 on a scalar jet, [f64; 4] on an f64x4 lane tower.
Source§

fn constant(c: f64) -> Self

A constant (value c, all derivatives zero), broadcast to every lane.
Source§

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

The seeded primary slot at value x (unit first derivative in slot), broadcast to every lane. Per-lane-DISTINCT seeding for the batch path is done by the lane instantiators (generic_batched_fourth_tower / generic_batched_third_tower), which build the tower variables directly from each row’s primaries; this method is for any row-invariant auxiliary variable a body introduces.
Source§

fn values(&self) -> [f64; 4]

The value channel(s): f64 (scalar) or [f64; 4] (lane).
Source§

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

Truncated Leibniz self + o.
Source§

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

Truncated Leibniz self − o.
Source§

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

Truncated Leibniz self · o.
Source§

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

Multiply every channel by the plain scalar s.
Source§

fn compose_unary_with<const N: usize>( &self, stack_fn: impl Fn(f64) -> [f64; N], ) -> Self

Faà di Bruno compose with a unary special function whose [f64; N] derivative stack is built from the running base value PER LANE through stack_fn. This is the SHARED-TRAIT version of the compose_unary_with inherent method that already exists on both the scalar towers and the lane towers: on a scalar jet stack_fn is run once at the value; on an f64x4 lane tower it is re-run per lane (the four rows carry four distinct base values), so lane i is to_bits-identical to the scalar result on row i. Making it a trait method is precisely what lets a body written once over R: RowJet<K> instantiate at the batch towers. N is widened/narrowed to the tower’s native width by [resize_stack] (N == 5 is a verbatim copy).
Source§

fn guard(&self, pred: impl Fn(f64) -> bool) -> GuardVerdict

Per-lane domain guard: evaluate pred on each active lane’s value channel and report which lanes failed (see GuardVerdict). A scalar jet checks its one value; a lane tower checks all four. Lets a batched program detect an out-of-domain row in a 4-group and bail that group to the scalar tail.
Source§

fn scale_rows(&self, s: [f64; 4]) -> Self

Per-lane scale: multiply every channel by the per-lane factor s (Self::Value). On a scalar jet Self::Value = f64, so this is exactly scale and the scalar call sites stay BIT-IDENTICAL when .scale(x) is rewritten to .scale_rows(x); on an f64x4 lane tower Self::Value = [f64; 4] and lane i is multiplied by s[i]. This is the primitive that lets a batched body carry CONTINUOUS per-row data — the survival covariance_ones / z_sum / observation-weight wi factors that enter the jet algebra as .scale(per_row_value) and that the single-f64 scale would broadcast wrongly across the four rows. Build s from the lane→row map with pack_rows.
Source§

fn pack_rows(rows: &[usize], value_of: impl Fn(usize) -> f64) -> [f64; 4]

Gather a per-lane auxiliary datum from the lane→row map rows: value_of(r) is evaluated for each active lane’s row and packed into Self::Value (a single f64 on a scalar jet, [f64; 4] on an f64x4 lane tower). This is how a body written once over RowJet feeds per-row CONTINUOUS data (the arguments to scale_rows) into the batch path without knowing the concrete representation: the program holds the per-row data and the caller threads rows (length 1 scalar, length 4 batch) into RowNllProgramRowJet::row_nll, so the body writes x.scale_rows(R::pack_rows(rows, |r| self.cov(r))). A multiplicative weight buried in a compose_unary_with stack is pulled out the same way: x.compose_unary_with(|u| stack(u, 1.0)).scale_rows(R::pack_rows(rows, |r| self.wi(r))). (Binary per-row branches such as the event indicator di are kept lane-uniform by grouping and the guard bail, not packed.)
Source§

fn neg(&self) -> Self

Negate every channel. Defaults to scale(-1.0); the blanket overrides it to delegate to crate::jet_scalar::JetScalar::neg.
Source§

fn exp(&self) -> Self

e^self.
Source§

fn ln(&self) -> Self

ln(self). Caller guarantees positivity.
Source§

fn sqrt(&self) -> Self

√self. Caller guarantees positivity.
Source§

fn recip(&self) -> Self

1/self.
Source§

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

self^a for real a. Caller guarantees a positive base.
Source§

fn ln_gamma(&self) -> Self

ln Γ(self). Caller guarantees a positive argument.
Source§

fn digamma(&self) -> Self

ψ(self) (digamma). Caller guarantees a positive argument.

Auto Trait Implementations§

§

impl<L, const K: usize> Freeze for Tower3Lane<L, K>
where L: Freeze,

§

impl<L, const K: usize> RefUnwindSafe for Tower3Lane<L, K>
where L: RefUnwindSafe,

§

impl<L, const K: usize> Send for Tower3Lane<L, K>
where L: Send,

§

impl<L, const K: usize> Sync for Tower3Lane<L, K>
where L: Sync,

§

impl<L, const K: usize> Unpin for Tower3Lane<L, K>
where L: Unpin,

§

impl<L, const K: usize> UnsafeUnpin for Tower3Lane<L, K>
where L: UnsafeUnpin,

§

impl<L, const K: usize> UnwindSafe for Tower3Lane<L, K>
where L: UnwindSafe,

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