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§
fn add(&self, o: &Self) -> Self
fn sub(&self, o: &Self) -> Self
fn mul(&self, o: &Self) -> Self
fn neg(&self) -> Self
Sourcefn compose_unary(&self, d: [f64; 5]) -> Self
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§
Sourcefn constant_like(&self, v: f64) -> Self
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)
Sourcefn with_value(&self, v: f64) -> Self
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".