pub(crate) struct Jet<const N: usize> {
pub(crate) value: Complex,
pub(crate) derivative: [Complex; N],
}Expand description
A complex value and its first derivatives with respect to N inputs.
Kernels that are generic in N serve forward evaluation and differentiation alike.
With N = 0 the derivative array is empty, so a forward evaluation stores and
computes no derivatives. Operations with a real or complex scalar skip the zero
derivative terms of a constant jet. Adding or subtracting a scalar still gives the
value a constant jet gives, signed zeros included: the sign of a zero imaginary part
selects the side of a branch cut downstream. special::RadialJet differs: it holds
the first two derivatives in one variable.
Fields§
§value: ComplexThe function value.
derivative: [Complex; N]The derivative with respect to each of the N inputs.
Implementations§
Source§impl<const N: usize> Jet<N>
impl<const N: usize> Jet<N>
Sourcepub(crate) fn constant(value: impl Into<Complex>) -> Self
pub(crate) fn constant(value: impl Into<Complex>) -> Self
A value that depends on no input: every derivative is zero.
Sourcepub(crate) fn variable(value: impl Into<Complex>, index: usize) -> Self
pub(crate) fn variable(value: impl Into<Complex>, index: usize) -> Self
Input number index itself: derivative one in that direction, zero in the others.
An index of N or more gives a constant.
Sourcepub(crate) fn chain(self, value: Complex, derivative: Complex) -> Self
pub(crate) fn chain(self, value: Complex, derivative: Complex) -> Self
The chain rule: the jet of f(self) from value = f(x) and derivative = f'(x)
at x = self.value. Each derivative of self is multiplied by f'(x).
Source§impl Jet<3>
impl Jet<3>
Sourcepub(crate) fn compose<const N: usize>(self, inner: [Jet<N>; 3]) -> Jet<N>
pub(crate) fn compose<const N: usize>(self, inner: [Jet<N>; 3]) -> Jet<N>
The chain rule through three intermediate variables: self holds f and its
derivatives with respect to x_b, inner[b] holds x_b and its derivatives with
respect to N inputs. Returns the value of f with the derivatives
sum_b df/dx_b dx_b/dt_a, summed in the order b = 0, 1, 2.
Trait Implementations§
Source§impl<const N: usize, Rhs> AddAssign<Rhs> for Jet<N>where
Self: Add<Rhs, Output = Self>,
impl<const N: usize, Rhs> AddAssign<Rhs> for Jet<N>where
Self: Add<Rhs, Output = Self>,
Source§fn add_assign(&mut self, rhs: Rhs)
fn add_assign(&mut self, rhs: Rhs)
+= operation. Read moreSource§impl<const N: usize, Rhs> MulAssign<Rhs> for Jet<N>where
Self: Mul<Rhs, Output = Self>,
impl<const N: usize, Rhs> MulAssign<Rhs> for Jet<N>where
Self: Mul<Rhs, Output = Self>,
Source§fn mul_assign(&mut self, rhs: Rhs)
fn mul_assign(&mut self, rhs: Rhs)
*= operation. Read moreSource§impl<const N: usize, Rhs> SubAssign<Rhs> for Jet<N>where
Self: Sub<Rhs, Output = Self>,
impl<const N: usize, Rhs> SubAssign<Rhs> for Jet<N>where
Self: Sub<Rhs, Output = Self>,
Source§fn sub_assign(&mut self, rhs: Rhs)
fn sub_assign(&mut self, rhs: Rhs)
-= operation. Read moreimpl<const N: usize> Copy for Jet<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for Jet<N>
impl<const N: usize> RefUnwindSafe for Jet<N>
impl<const N: usize> Send for Jet<N>
impl<const N: usize> Sync for Jet<N>
impl<const N: usize> Unpin for Jet<N>
impl<const N: usize> UnwindSafe for Jet<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.