Skip to main content

Dual

Struct Dual 

Source
pub struct Dual<const N: usize> {
    pub v: Scalar,
    pub d: [Scalar; N],
}
Expand description

A value together with its gradient with respect to up to N seeded variables — as many as the residual it is computed for depends on.

Fields§

§v: Scalar§d: [Scalar; N]

Implementations§

Source§

impl<const N: usize> Dual<N>

Source

pub const fn cst(v: Scalar) -> Self

A constant, with no dependence on any variable.

Source

pub fn var(v: Scalar, slot: usize) -> Self

The slot-th independent variable, with value v.

Source

pub fn embed<const M: usize>(self, slot: usize, vars: usize) -> Dual<M>

The same value in a gradient of M variables: its own first vars the ones from slot on — and no dependence on any other (its own beyond vars it has none of).

Source

pub fn chain(self, v: Scalar, df: Scalar) -> Self

f(self) for a scalar function with value v and derivative df = f'(self.v): d <- d * df by the chain rule.

Trait Implementations§

Source§

impl<const N: usize> Clone for Dual<N>

Source§

fn clone(&self) -> Dual<N>

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<const N: usize> Copy for Dual<N>

Source§

impl<const N: usize> Debug for Dual<N>

Source§

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

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

impl<const N: usize> Default for Dual<N>

Source§

fn default() -> Self

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

impl<const N: usize> Display for Dual<N>

Source§

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

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

impl<const N: usize> Number for Dual<N>

Source§

fn acos(self) -> GeopResult<Self>

d acos(x) = -1 / sqrt(1 - x^2), which fails where it is infinite, at x = ±1.

Source§

fn is_sharp(self) -> bool

A single, exactly known point: a sharp value that does not vary with any variable. A value that is sharp but moves with a variable is no point — taking it for one drops the gradient.

Source§

fn union(self, other: Self) -> Self

The union of the values, with self‘s derivatives: the width a series’ remainder adds (see crate::primitives::Pose::exp).

Source§

const ZERO: Self

Source§

const ONE: Self

Source§

const TWO: Self

Source§

const PI: Self

Source§

fn from_i64(v: i64) -> Self

Source§

fn from_f64(v: f64) -> Self

Source§

fn from_scalar(s: Scalar) -> Self

The scalar s as a constant: depending on no variable.
Source§

fn from_ratio(num: i64, den: i64) -> GeopResult<Self>

Source§

fn to_f64(self) -> f64

The value’s midpoint, for rendering and debugging.
Source§

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

Source§

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

Source§

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

Source§

fn neg(self) -> Self

Source§

fn div(self, o: Self) -> GeopResult<Self>

Fails where the divisor could be zero.
Source§

fn abs(self) -> Self

Source§

fn sqrt(self) -> GeopResult<Self>

Source§

fn sin(self) -> Self

Source§

fn cos(self) -> Self

Source§

fn could_be_equal(self, other: Self) -> bool

Source§

fn definitely_not_equal(self, other: Self) -> bool

Source§

fn could_be_greater(self, other: Self) -> bool

Source§

fn definitely_greater(self, other: Self) -> bool

Source§

fn could_be_less(self, other: Self) -> bool

Source§

fn definitely_less(self, other: Self) -> bool

Source§

fn is_exactly(self, other: Self) -> bool

Whether its value is exactly other’s, as a set (see Scalar::is_exactly).
Source§

fn degrees_to_radians(self) -> GeopResult<Self>

The angle self, given in degrees, in radians.

Auto Trait Implementations§

§

impl<const N: usize> Freeze for Dual<N>

§

impl<const N: usize> RefUnwindSafe for Dual<N>

§

impl<const N: usize> Send for Dual<N>

§

impl<const N: usize> Sync for Dual<N>

§

impl<const N: usize> Unpin for Dual<N>

§

impl<const N: usize> UnsafeUnpin for Dual<N>

§

impl<const N: usize> UnwindSafe for Dual<N>

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.