Skip to main content

JetField

Trait JetField 

Source
pub trait JetField: Clone {
    // Required methods
    fn value(&self) -> f64;
    fn add(&self, o: &Self) -> Self;
    fn sub(&self, o: &Self) -> Self;
    fn mul(&self, o: &Self) -> Self;
    fn neg(&self) -> Self;
    fn scale(&self, s: f64) -> Self;
    fn compose_unary(&self, d: [f64; 5]) -> Self;

    // Provided methods
    fn constant_like(&self, v: f64) -> Self { ... }
    fn with_value(&self, v: f64) -> Self { ... }
}
Expand description

Minimal scalar field a Dual2 can be built over. Implemented by f64 (the base case) and by Dual2 itself (the nesting case). Every operation mirrors the crate::jet_tower::Tower4 / crate::jet_scalar::JetScalar Faà di Bruno convention exactly, so a program written against JetField evaluates identically on the engine tower and on a nested dual.

This is the SHARED scalar-field algebra base of the #932 tower: the const-K packed crate::jet_scalar::JetScalar and the runtime-p Vec-backed flex jets (survival::marginal_slope::timepoint_exact::FlexJet) both EXTEND it, so the field ops and the single Faà di Bruno composition are declared exactly ONCE here. It is deliberately NOT Copy (the Vec-backed flex jets are Clone, not Copy) and carries no constructor (a Vec-backed constant needs a primary count) — the Copy, from_f64-carrying nested-dual oracle path adds those through JetFieldConst.

Required Methods§

Source

fn value(&self) -> f64

The real value channel (recurses through any nesting to the f64 leaf).

Source

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

Source

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

Source

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

Source

fn neg(&self) -> Self

Source

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

Multiply every channel by a plain f64.

Source

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

Faà di Bruno composition f ∘ self given the OUTER real function’s derivative stack d = [f(u), f′(u), f″(u), f‴(u), f⁗(u)] evaluated at u = self.value() — the identical [f64; 5] stack shape crate::jet_tower::Tower4::compose_unary consumes.

Provided Methods§

Source

fn constant_like(&self, v: f64) -> Self

A constant carrying THIS element’s shape: real value v, every derivative channel zero.

JetField deliberately has no dimensionless constructor (a Vec-backed runtime-width constant needs a primary count), so a shape has to come from an existing element. The default routes through Self::compose_unary with a zero-derivative stack, which is correct for every implementor but walks the whole Faa di Bruno partition sum to write a constant — at Dual2<Order2<K>> that is three inner compositions plus four products, all of whose channels are known zero ahead of time. Implementors on a hot path override it with the direct construction. (#932)

Source

fn with_value(&self, v: f64) -> Self

self with its real value channel replaced by v, every derivative channel untouched.

This is the explicit form of the “anchor the value, keep the derivatives” idiom that a row program uses to hold a previously computed f64 result bitwise while lifting it into a jet. Expressing it as a primitive (rather than as subtract-a-constant-then-add-a-constant) makes the bitwise contract exact by construction instead of emergent from floating-point cancellation. (#932)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl JetField for f64

Source§

fn value(&self) -> f64

Source§

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

Source§

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

Source§

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

Source§

fn neg(&self) -> Self

Source§

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

Source§

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

Source§

fn constant_like(&self, v: f64) -> Self

Source§

fn with_value(&self, v: f64) -> Self

Implementors§

Source§

impl<P, const K: usize, const H: usize> JetField for PatternedOrder2<P, K, H>
where P: HessianPattern<K, H>,

Source§

impl<S: JetField> JetField for Dual2<S>

Source§

impl<const K: usize> JetField for OneSeed<K>

Source§

impl<const K: usize> JetField for Order1<K>

Source§

impl<const K: usize> JetField for Order2<K>

Source§

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

Source§

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

Source§

impl<const K: usize> JetField for TwoSeed<K>