pub struct Jet1Vec<T: Passive = f64> {
pub real: T,
pub dual: Vec<T>,
}Expand description
Multi-variable forward-mode dual number.
real: the function valuef(x_1, ..., x_n)dual: the gradient[∂f/∂x_1, ..., ∂f/∂x_n]
Note on storage: the tangent vector is a plain heap-backed Vec<T>.
We evaluated a SmallVec<[T; N]> implementation for several values
of N (see the CHANGELOG under stage 7 of the 2026-04 perf refactor);
it gave 40 – 58 % wins when the tangent fit inline but regressed
spilled workloads (e.g. the 30-input swap pricer) by 30 – 45 % because
SmallVec’s spilled-mode discriminated-union layout bloats every heap
operand. A single inline cap that wins at both n = 6 and n = 30
without blowing up register pressure does not exist, so we keep plain
Vec for predictable, uniform performance across tangent sizes.
Fields§
§real: T§dual: Vec<T>Implementations§
Source§impl<T: Passive> Jet1Vec<T>
impl<T: Passive> Jet1Vec<T>
Sourcepub fn new(real: T, dual: Vec<T>) -> Self
pub fn new(real: T, dual: Vec<T>) -> Self
Create a Jet1Vec with the given value and gradient vector.
Sourcepub fn constant(real: T, n: usize) -> Self
pub fn constant(real: T, n: usize) -> Self
Create a derivative-free Jet1Vec (all tangents zero).
Sourcepub fn variable(value: T, i: usize, n: usize) -> Self
pub fn variable(value: T, i: usize, n: usize) -> Self
Create the i-th active variable in an n-dimensional input space.
The resulting Jet1Vec has real = value and dual = e_i (unit vector
in direction i), so after propagation result.dual[j] = ∂result/∂x_i
when j = i and zero from this seed alone.
Sourcepub fn erf(&self) -> Jet1Vec<T>
pub fn erf(&self) -> Jet1Vec<T>
Error function erf(self).
Derivative: erf'(x) = (2/√π) · exp(-x²).
Sourcepub fn norm_cdf(&self) -> Jet1Vec<T>
pub fn norm_cdf(&self) -> Jet1Vec<T>
Standard normal CDF: Φ(x) = 0.5 · (1 + erf(x / √2)).
Derivative: φ(x) = (1/√(2π)) · exp(-x²/2) (the standard normal PDF).
Sourcepub fn inv_norm_cdf(&self) -> Jet1Vec<T>
pub fn inv_norm_cdf(&self) -> Jet1Vec<T>
Inverse standard normal CDF: Φ⁻¹(p).
Derivative: 1 / φ(Φ⁻¹(p)) = √(2π) · exp(Φ⁻¹(p)² / 2).
Sourcepub fn into_powi(self, n: i32) -> Jet1Vec<T>
pub fn into_powi(self, n: i32) -> Jet1Vec<T>
Consuming powi — reuses self’s tangent allocation.
Sourcepub fn into_norm_cdf(self) -> Jet1Vec<T>
pub fn into_norm_cdf(self) -> Jet1Vec<T>
Consuming norm_cdf — reuses self’s tangent allocation.
Sourcepub fn into_inv_norm_cdf(self) -> Jet1Vec<T>
pub fn into_inv_norm_cdf(self) -> Jet1Vec<T>
Consuming inv_norm_cdf — reuses self’s tangent allocation.
Trait Implementations§
Source§impl<T: Passive> AddAssign<&Jet1Vec<T>> for Jet1Vec<T>
impl<T: Passive> AddAssign<&Jet1Vec<T>> for Jet1Vec<T>
Source§fn add_assign(&mut self, rhs: &Jet1Vec<T>)
fn add_assign(&mut self, rhs: &Jet1Vec<T>)
+= operation. Read moreSource§impl<T: Passive> AddAssign<T> for Jet1Vec<T>
impl<T: Passive> AddAssign<T> for Jet1Vec<T>
Source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
+= operation. Read moreSource§impl<T: Passive> AddAssign for Jet1Vec<T>
impl<T: Passive> AddAssign for Jet1Vec<T>
Source§fn add_assign(&mut self, rhs: Jet1Vec<T>)
fn add_assign(&mut self, rhs: Jet1Vec<T>)
+= operation. Read moreSource§impl<T: Passive> DivAssign<&Jet1Vec<T>> for Jet1Vec<T>
impl<T: Passive> DivAssign<&Jet1Vec<T>> for Jet1Vec<T>
Source§fn div_assign(&mut self, rhs: &Jet1Vec<T>)
fn div_assign(&mut self, rhs: &Jet1Vec<T>)
/= operation. Read moreSource§impl<T: Passive> DivAssign<T> for Jet1Vec<T>
impl<T: Passive> DivAssign<T> for Jet1Vec<T>
Source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
/= operation. Read moreSource§impl<T: Passive> MulAssign<&Jet1Vec<T>> for Jet1Vec<T>
impl<T: Passive> MulAssign<&Jet1Vec<T>> for Jet1Vec<T>
Source§fn mul_assign(&mut self, rhs: &Jet1Vec<T>)
fn mul_assign(&mut self, rhs: &Jet1Vec<T>)
*= operation. Read moreSource§impl<T: Passive> MulAssign<T> for Jet1Vec<T>
impl<T: Passive> MulAssign<T> for Jet1Vec<T>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
*= operation. Read moreSource§impl<T: Passive> PartialOrd<T> for Jet1Vec<T>
impl<T: Passive> PartialOrd<T> for Jet1Vec<T>
Source§impl<T: Passive> PartialOrd for Jet1Vec<T>
impl<T: Passive> PartialOrd for Jet1Vec<T>
Source§impl<T: Passive> SubAssign<&Jet1Vec<T>> for Jet1Vec<T>
impl<T: Passive> SubAssign<&Jet1Vec<T>> for Jet1Vec<T>
Source§fn sub_assign(&mut self, rhs: &Jet1Vec<T>)
fn sub_assign(&mut self, rhs: &Jet1Vec<T>)
-= operation. Read more