Skip to main content

Dual22

Type Alias Dual22 

Source
pub type Dual22 = Dual2<Dual2<f64>>;
Expand description

A Dual2<Dual2<f64>> seeded with independent directions a (outer) and b (inner): value x, unit first derivative along both requested directions. p0 should be seeded (a=1, b=0) and p1 (a=0, b=1) for a two-primary program (mirrors Tower4::variable(x, 0) / Tower4::variable(x, 1)).

Aliased Type§

pub struct Dual22 {
    pub v: Dual2<f64>,
    pub g: Dual2<f64>,
    pub h: Dual2<f64>,
}

Fields§

§v: Dual2<f64>

Value channel.

§g: Dual2<f64>

First derivative in this dual’s direction.

§h: Dual2<f64>

Second derivative in this dual’s direction.

Implementations§

Source§

impl Dual22

Source

pub fn seed_outer(x: f64) -> Self

Seed a primary that varies only along the OUTER direction a (∂/∂a = 1, ∂/∂b = 0) — the Tower4::variable(x, 0) analogue.

Source

pub fn seed_inner(x: f64) -> Self

Seed a primary that varies only along the INNER direction b (∂/∂a = 0, ∂/∂b = 1) — the Tower4::variable(x, 1) analogue.

Source

pub fn seed_directional(base: f64, d1: f64, d2: f64) -> Self

Seed a primary at value base that moves as base + s·d1 + t·d2 under the two independent scalar directions s (outer a) and t (inner b): ∂/∂a = d1, ∂/∂b = d2, all second-and-higher self-derivatives zero (the primary is affine in s, t). This is what a directional bidirectional contraction along arbitrary weight vectors d1, d2 needs — seed every primary i with seed_directional(base_i, d1_i, d2_i), run the program, and read channels()[8] (∂²_a ∂²_b) for Σ_{a,b,c,d} ℓ_{abcd}·d1_a d1_b d2_c d2_d.

Source

pub fn from_channels(c: [f64; 9]) -> Self

Build a nested dual directly from its nine (s-order, t-order) channels, ordered as Self::channels: [v, ∂a, ∂b, ∂aa, ∂ab, ∂bb, ∂aab, ∂abb, ∂aabb]. The inverse of Self::channels. Used to assemble the result of a channel-space operation (e.g. a moment-recurrence residual term) back into a Dual22.

Source

pub fn channels(&self) -> [f64; 9]

The nine channels this nested dual represents, keyed to the two-primary crate::jet_tower::Tower4 indices 0 (outer a) and 1 (inner b): (value, ∂a, ∂b, ∂aa, ∂ab, ∂bb, ∂aab, ∂abb, ∂aabb).