Skip to main content

Jet1Vec

Struct Jet1Vec 

Source
pub struct Jet1Vec<T: Passive = f64> {
    pub real: T,
    pub dual: Vec<T>,
}
Expand description

Multi-variable forward-mode dual number.

  • real: the function value f(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>

Source

pub fn new(real: T, dual: Vec<T>) -> Self

Create a Jet1Vec with the given value and gradient vector.

Source

pub fn constant(real: T, n: usize) -> Self

Create a derivative-free Jet1Vec (all tangents zero).

Source

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.

Source

pub fn real(&self) -> T

Value accessor.

Source

pub fn dual(&self) -> &[T]

Full gradient as a slice view.

Source

pub fn partial(&self, i: usize) -> T

Partial derivative with respect to the i-th variable.

Source

pub fn num_vars(&self) -> usize

Number of tracked variables (length of the gradient vector).

Source

pub fn powf(&self, n: T) -> Jet1Vec<T>

self^n with scalar exponent.

Source

pub fn powi(&self, n: i32) -> Jet1Vec<T>

self^n with integer exponent.

Source

pub fn exp(&self) -> Jet1Vec<T>

Natural exponential.

Source

pub fn ln(&self) -> Jet1Vec<T>

Natural logarithm.

Source

pub fn sqrt(&self) -> Jet1Vec<T>

Square root.

Source

pub fn sin(&self) -> Jet1Vec<T>

Sine.

Source

pub fn cos(&self) -> Jet1Vec<T>

Cosine.

Source

pub fn tan(&self) -> Jet1Vec<T>

Tangent.

Source

pub fn tanh(&self) -> Jet1Vec<T>

Hyperbolic tangent.

Source

pub fn abs(&self) -> Jet1Vec<T>

Absolute value (sub-gradient at 0 is 0).

Source

pub fn erf(&self) -> Jet1Vec<T>

Error function erf(self).

Derivative: erf'(x) = (2/√π) · exp(-x²).

Source

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).

Source

pub fn inv_norm_cdf(&self) -> Jet1Vec<T>

Inverse standard normal CDF: Φ⁻¹(p).

Derivative: 1 / φ(Φ⁻¹(p)) = √(2π) · exp(Φ⁻¹(p)² / 2).

Source

pub fn into_powf(self, n: T) -> Jet1Vec<T>

Consuming powf — reuses self’s tangent allocation.

Source

pub fn into_powi(self, n: i32) -> Jet1Vec<T>

Consuming powi — reuses self’s tangent allocation.

Source

pub fn into_exp(self) -> Jet1Vec<T>

Consuming exp — reuses self’s tangent allocation.

Source

pub fn into_ln(self) -> Jet1Vec<T>

Consuming ln — reuses self’s tangent allocation.

Source

pub fn into_sqrt(self) -> Jet1Vec<T>

Consuming sqrt — reuses self’s tangent allocation.

Source

pub fn into_sin(self) -> Jet1Vec<T>

Consuming sin — reuses self’s tangent allocation.

Source

pub fn into_cos(self) -> Jet1Vec<T>

Consuming cos — reuses self’s tangent allocation.

Source

pub fn into_tan(self) -> Jet1Vec<T>

Consuming tan — reuses self’s tangent allocation.

Source

pub fn into_tanh(self) -> Jet1Vec<T>

Consuming tanh — reuses self’s tangent allocation.

Source

pub fn into_abs(self) -> Jet1Vec<T>

Consuming abs — reuses self’s tangent allocation.

Source

pub fn into_erf(self) -> Jet1Vec<T>

Consuming erf — reuses self’s tangent allocation.

Source

pub fn into_norm_cdf(self) -> Jet1Vec<T>

Consuming norm_cdf — reuses self’s tangent allocation.

Source

pub fn into_inv_norm_cdf(self) -> Jet1Vec<T>

Consuming inv_norm_cdf — reuses self’s tangent allocation.

Trait Implementations§

Source§

impl<'a, 'b, T: Passive> Add<&'b Jet1Vec<T>> for &'a Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'b Jet1Vec<T>) -> Jet1Vec<T>

Performs the + operation. Read more
Source§

impl<T: Passive> Add<&Jet1Vec<T>> for Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Jet1Vec<T>) -> Jet1Vec<T>

Performs the + operation. Read more
Source§

impl Add<&Jet1Vec<f32>> for f32

Source§

type Output = Jet1Vec<f32>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Jet1Vec<f32>) -> Jet1Vec<f32>

Performs the + operation. Read more
Source§

impl Add<&Jet1Vec> for f64

Source§

type Output = Jet1Vec

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Jet1Vec<f64>) -> Jet1Vec<f64>

Performs the + operation. Read more
Source§

impl<T: Passive> Add<Jet1Vec<T>> for &Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Jet1Vec<T>) -> Jet1Vec<T>

Performs the + operation. Read more
Source§

impl Add<Jet1Vec<f32>> for f32

Source§

type Output = Jet1Vec<f32>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Jet1Vec<f32>) -> Jet1Vec<f32>

Performs the + operation. Read more
Source§

impl Add<Jet1Vec> for f64

Source§

type Output = Jet1Vec

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Jet1Vec<f64>) -> Jet1Vec<f64>

Performs the + operation. Read more
Source§

impl<T: Passive> Add<T> for &Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Jet1Vec<T>

Performs the + operation. Read more
Source§

impl<T: Passive> Add<T> for Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Jet1Vec<T>

Performs the + operation. Read more
Source§

impl<T: Passive> Add for Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Jet1Vec<T>) -> Jet1Vec<T>

Performs the + operation. Read more
Source§

impl<T: Passive> AddAssign<&Jet1Vec<T>> for Jet1Vec<T>

Source§

fn add_assign(&mut self, rhs: &Jet1Vec<T>)

Performs the += operation. Read more
Source§

impl<T: Passive> AddAssign<T> for Jet1Vec<T>

Source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
Source§

impl<T: Passive> AddAssign for Jet1Vec<T>

Source§

fn add_assign(&mut self, rhs: Jet1Vec<T>)

Performs the += operation. Read more
Source§

impl<T: Clone + Passive> Clone for Jet1Vec<T>

Source§

fn clone(&self) -> Jet1Vec<T>

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<T: Debug + Passive> Debug for Jet1Vec<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Passive> Display for Jet1Vec<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, 'b, T: Passive> Div<&'b Jet1Vec<T>> for &'a Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'b Jet1Vec<T>) -> Jet1Vec<T>

Performs the / operation. Read more
Source§

impl<T: Passive> Div<&Jet1Vec<T>> for Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Jet1Vec<T>) -> Jet1Vec<T>

Performs the / operation. Read more
Source§

impl Div<&Jet1Vec<f32>> for f32

Source§

type Output = Jet1Vec<f32>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Jet1Vec<f32>) -> Jet1Vec<f32>

Performs the / operation. Read more
Source§

impl Div<&Jet1Vec> for f64

Source§

type Output = Jet1Vec

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Jet1Vec<f64>) -> Jet1Vec<f64>

Performs the / operation. Read more
Source§

impl<T: Passive> Div<Jet1Vec<T>> for &Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Jet1Vec<T>) -> Jet1Vec<T>

Performs the / operation. Read more
Source§

impl Div<Jet1Vec<f32>> for f32

Source§

type Output = Jet1Vec<f32>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Jet1Vec<f32>) -> Jet1Vec<f32>

Performs the / operation. Read more
Source§

impl Div<Jet1Vec> for f64

Source§

type Output = Jet1Vec

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Jet1Vec<f64>) -> Jet1Vec<f64>

Performs the / operation. Read more
Source§

impl<T: Passive> Div<T> for &Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Jet1Vec<T>

Performs the / operation. Read more
Source§

impl<T: Passive> Div<T> for Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Jet1Vec<T>

Performs the / operation. Read more
Source§

impl<T: Passive> Div for Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Jet1Vec<T>) -> Jet1Vec<T>

Performs the / operation. Read more
Source§

impl<T: Passive> DivAssign<&Jet1Vec<T>> for Jet1Vec<T>

Source§

fn div_assign(&mut self, rhs: &Jet1Vec<T>)

Performs the /= operation. Read more
Source§

impl<T: Passive> DivAssign<T> for Jet1Vec<T>

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl<'a, 'b, T: Passive> Mul<&'b Jet1Vec<T>> for &'a Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b Jet1Vec<T>) -> Jet1Vec<T>

Performs the * operation. Read more
Source§

impl<T: Passive> Mul<&Jet1Vec<T>> for Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Jet1Vec<T>) -> Jet1Vec<T>

Performs the * operation. Read more
Source§

impl Mul<&Jet1Vec<f32>> for f32

Source§

type Output = Jet1Vec<f32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Jet1Vec<f32>) -> Jet1Vec<f32>

Performs the * operation. Read more
Source§

impl Mul<&Jet1Vec> for f64

Source§

type Output = Jet1Vec

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Jet1Vec<f64>) -> Jet1Vec<f64>

Performs the * operation. Read more
Source§

impl<T: Passive> Mul<Jet1Vec<T>> for &Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Jet1Vec<T>) -> Jet1Vec<T>

Performs the * operation. Read more
Source§

impl Mul<Jet1Vec<f32>> for f32

Source§

type Output = Jet1Vec<f32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Jet1Vec<f32>) -> Jet1Vec<f32>

Performs the * operation. Read more
Source§

impl Mul<Jet1Vec> for f64

Source§

type Output = Jet1Vec

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Jet1Vec<f64>) -> Jet1Vec<f64>

Performs the * operation. Read more
Source§

impl<T: Passive> Mul<T> for &Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Jet1Vec<T>

Performs the * operation. Read more
Source§

impl<T: Passive> Mul<T> for Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Jet1Vec<T>

Performs the * operation. Read more
Source§

impl<T: Passive> Mul for Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Jet1Vec<T>) -> Jet1Vec<T>

Performs the * operation. Read more
Source§

impl<T: Passive> MulAssign<&Jet1Vec<T>> for Jet1Vec<T>

Source§

fn mul_assign(&mut self, rhs: &Jet1Vec<T>)

Performs the *= operation. Read more
Source§

impl<T: Passive> MulAssign<T> for Jet1Vec<T>

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<T: Passive> Neg for &Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Jet1Vec<T>

Performs the unary - operation. Read more
Source§

impl<T: Passive> Neg for Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Jet1Vec<T>

Performs the unary - operation. Read more
Source§

impl<T: Passive> PartialEq<T> for Jet1Vec<T>

Source§

fn eq(&self, other: &T) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Passive> PartialEq for Jet1Vec<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Passive> PartialOrd<T> for Jet1Vec<T>

Source§

fn partial_cmp(&self, other: &T) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Passive> PartialOrd for Jet1Vec<T>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, 'b, T: Passive> Sub<&'b Jet1Vec<T>> for &'a Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'b Jet1Vec<T>) -> Jet1Vec<T>

Performs the - operation. Read more
Source§

impl<T: Passive> Sub<&Jet1Vec<T>> for Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Jet1Vec<T>) -> Jet1Vec<T>

Performs the - operation. Read more
Source§

impl Sub<&Jet1Vec<f32>> for f32

Source§

type Output = Jet1Vec<f32>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Jet1Vec<f32>) -> Jet1Vec<f32>

Performs the - operation. Read more
Source§

impl Sub<&Jet1Vec> for f64

Source§

type Output = Jet1Vec

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Jet1Vec<f64>) -> Jet1Vec<f64>

Performs the - operation. Read more
Source§

impl<T: Passive> Sub<Jet1Vec<T>> for &Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Jet1Vec<T>) -> Jet1Vec<T>

Performs the - operation. Read more
Source§

impl Sub<Jet1Vec<f32>> for f32

Source§

type Output = Jet1Vec<f32>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Jet1Vec<f32>) -> Jet1Vec<f32>

Performs the - operation. Read more
Source§

impl Sub<Jet1Vec> for f64

Source§

type Output = Jet1Vec

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Jet1Vec<f64>) -> Jet1Vec<f64>

Performs the - operation. Read more
Source§

impl<T: Passive> Sub<T> for &Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Jet1Vec<T>

Performs the - operation. Read more
Source§

impl<T: Passive> Sub<T> for Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Jet1Vec<T>

Performs the - operation. Read more
Source§

impl<T: Passive> Sub for Jet1Vec<T>

Source§

type Output = Jet1Vec<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Jet1Vec<T>) -> Jet1Vec<T>

Performs the - operation. Read more
Source§

impl<T: Passive> SubAssign<&Jet1Vec<T>> for Jet1Vec<T>

Source§

fn sub_assign(&mut self, rhs: &Jet1Vec<T>)

Performs the -= operation. Read more
Source§

impl<T: Passive> SubAssign<T> for Jet1Vec<T>

Source§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
Source§

impl<T: Passive> SubAssign for Jet1Vec<T>

Source§

fn sub_assign(&mut self, rhs: Jet1Vec<T>)

Performs the -= operation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Jet1Vec<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Jet1Vec<T>
where T: RefUnwindSafe,

§

impl<T> Send for Jet1Vec<T>

§

impl<T> Sync for Jet1Vec<T>

§

impl<T> Unpin for Jet1Vec<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Jet1Vec<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Jet1Vec<T>
where T: 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<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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.