Skip to main content

Dual

Struct Dual 

Source
pub struct Dual {
    pub re: f64,
    pub eps: f64,
}
Expand description

re + eps·ε with ε² = 0. Arithmetic on duals carries the derivative of every intermediate along a single direction, which is what the Hessian-vector product needs.

Fields§

§re: f64

The value.

§eps: f64

The derivative along the seeded direction.

Implementations§

Source§

impl Dual

Source

pub const fn new(re: f64, eps: f64) -> Self

A dual with the given value and derivative.

Source

pub const fn constant(re: f64) -> Self

A constant: derivative zero.

Trait Implementations§

Source§

impl Add for Dual

Source§

type Output = Dual

The resulting type after applying the + operator.
Source§

fn add(self, o: Dual) -> Dual

Performs the + operation. Read more
Source§

impl AddAssign for Dual

Source§

fn add_assign(&mut self, o: Dual)

Performs the += operation. Read more
Source§

impl Clone for Dual

Source§

fn clone(&self) -> Self

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 Copy for Dual

Source§

impl Debug for Dual

Source§

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

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

impl Default for Dual

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Div for Dual

Source§

type Output = Dual

The resulting type after applying the / operator.
Source§

fn div(self, o: Dual) -> Dual

Performs the / operation. Read more
Source§

impl DivAssign for Dual

Source§

fn div_assign(&mut self, o: Dual)

Performs the /= operation. Read more
Source§

impl Mul for Dual

Source§

type Output = Dual

The resulting type after applying the * operator.
Source§

fn mul(self, o: Dual) -> Dual

Performs the * operation. Read more
Source§

impl MulAssign for Dual

Source§

fn mul_assign(&mut self, o: Dual)

Performs the *= operation. Read more
Source§

impl Neg for Dual

Source§

type Output = Dual

The resulting type after applying the - operator.
Source§

fn neg(self) -> Dual

Performs the unary - operation. Read more
Source§

impl Num for Dual

Source§

type FromStrRadixErr = <f64 as Num>::FromStrRadixErr

Source§

fn from_str_radix(s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>

Convert from a string and radix (typically 2..=36). Read more
Source§

impl One for Dual

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

impl PartialEq for Dual

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Dual

Source§

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

Duals order by value alone, so pivoting and max choose the same branch as the f64 computation.

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 Rem for Dual

Source§

fn rem(self, o: Dual) -> Dual

a - trunc(a / b)·b, differentiated with the truncation held constant.

Source§

type Output = Dual

The resulting type after applying the % operator.
Source§

impl RemAssign for Dual

Source§

fn rem_assign(&mut self, o: Dual)

Performs the %= operation. Read more
Source§

impl Scalar for Dual

Source§

fn from_f64(v: f64) -> Self

A constant.
Source§

fn re(self) -> f64

The value part, used for comparisons, pivoting and norms.
Source§

fn sqrt(self) -> Self

Square root. Its derivative at zero is taken as zero, the subgradient the penalty relies on.
Source§

fn sin(self) -> Self

Sine.
Source§

fn cos(self) -> Self

Cosine.
Source§

fn exp(self) -> Self

Exponential.
Source§

fn ln(self) -> Self

Natural logarithm.
Source§

fn atan2(self, x: Self) -> Self

Four-quadrant arctangent of self / x.
Source§

fn abs(self) -> Self

Absolute value; derivative zero at zero.
Source§

fn powi(self, n: i32) -> Self

Integer power.
Source§

fn sinc(self) -> Self

sin(x) / x, continuous at zero.
Source§

impl StructuralPartialEq for Dual

Source§

impl Sub for Dual

Source§

type Output = Dual

The resulting type after applying the - operator.
Source§

fn sub(self, o: Dual) -> Dual

Performs the - operation. Read more
Source§

impl SubAssign for Dual

Source§

fn sub_assign(&mut self, o: Dual)

Performs the -= operation. Read more
Source§

impl Zero for Dual

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.

Auto Trait Implementations§

§

impl Forget for Dual

§

impl Freeze for Dual

§

impl Move for Dual

§

impl RefUnwindSafe for Dual

§

impl Send for Dual

§

impl Sync for Dual

§

impl Unpin for Dual

§

impl UnsafeUnpin for Dual

§

impl UnwindSafe for Dual

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<N, R, C, S> ArgminAdd<Matrix<N, R, C, S>, Matrix<N, R, C, <DefaultAllocator as Allocator<R, C>>::Buffer<N>>> for N
where N: Scalar + ClosedAddAssign + Copy, R: Dim, C: Dim, S: Storage<N, R, C>, DefaultAllocator: Allocator<N, R, C>,

Source§

fn add( &self, other: &Matrix<N, R, C, S>, ) -> Matrix<N, R, C, <DefaultAllocator as Allocator<R, C>>::Buffer<N>>

Add a T to self
Source§

impl<N, R, C, S> ArgminDiv<Matrix<N, R, C, S>, Matrix<N, R, C, <DefaultAllocator as Allocator<R, C>>::Buffer<N>>> for N
where N: Scalar + Copy + ClosedDivAssign, R: Dim, C: Dim, S: Storage<N, R, C>, DefaultAllocator: Allocator<N, R, C>,

Source§

fn div( &self, other: &Matrix<N, R, C, S>, ) -> Matrix<N, R, C, <DefaultAllocator as Allocator<R, C>>::Buffer<N>>

(Pointwise) Divide a T by self
Source§

impl<N, R, C, S> ArgminDot<Matrix<N, R, C, S>, Matrix<N, R, C, <DefaultAllocator as Allocator<R, C>>::Buffer<N>>> for N
where N: Scalar + Copy + ClosedMulAssign, R: Dim, C: Dim, S: Storage<N, R, C>, DefaultAllocator: Allocator<N, R, C>,

Source§

fn dot( &self, other: &Matrix<N, R, C, S>, ) -> Matrix<N, R, C, <DefaultAllocator as Allocator<R, C>>::Buffer<N>>

Dot/scalar product of T and self
Source§

impl<N, R, C, S> ArgminMul<Matrix<N, R, C, S>, Matrix<N, R, C, <DefaultAllocator as Allocator<R, C>>::Buffer<N>>> for N
where N: Scalar + Copy + ClosedMulAssign, R: Dim, C: Dim, S: Storage<N, R, C>, DefaultAllocator: Allocator<N, R, C>,

Source§

fn mul( &self, other: &Matrix<N, R, C, S>, ) -> Matrix<N, R, C, <DefaultAllocator as Allocator<R, C>>::Buffer<N>>

(Pointwise) Multiply a T with self
Source§

impl<N, R, C, S> ArgminSub<Matrix<N, R, C, S>, Matrix<N, R, C, <DefaultAllocator as Allocator<R, C>>::Buffer<N>>> for N
where N: Scalar + Copy + Sub<Output = N>, R: Dim, C: Dim, S: Storage<N, R, C>, DefaultAllocator: Allocator<N, R, C>,

Source§

fn sub( &self, other: &Matrix<N, R, C, S>, ) -> Matrix<N, R, C, <DefaultAllocator as Allocator<R, C>>::Buffer<N>>

Subtract a T from self
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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, Right> ClosedAdd<Right> for T
where T: Add<Right, Output = T> + AddAssign<Right>,

Source§

impl<T, Right> ClosedAddAssign<Right> for T
where T: ClosedAdd<Right> + AddAssign<Right>,

Source§

impl<T, Right> ClosedDiv<Right> for T
where T: Div<Right, Output = T> + DivAssign<Right>,

Source§

impl<T, Right> ClosedDivAssign<Right> for T
where T: ClosedDiv<Right> + DivAssign<Right>,

Source§

impl<T, Right> ClosedMul<Right> for T
where T: Mul<Right, Output = T> + MulAssign<Right>,

Source§

impl<T, Right> ClosedMulAssign<Right> for T
where T: ClosedMul<Right> + MulAssign<Right>,

Source§

impl<T> ClosedNeg for T
where T: Neg<Output = T>,

Source§

impl<T, Right> ClosedSub<Right> for T
where T: Sub<Right, Output = T> + SubAssign<Right>,

Source§

impl<T, Right> ClosedSubAssign<Right> for T
where T: ClosedSub<Right> + SubAssign<Right>,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> NumAssign for T
where T: Num + NumAssignOps,

Source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<T> SendAlias for T

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> SyncAlias for T

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V