Gradients

Trait Gradients 

Source
pub trait Gradients: Dim{
    type Dual<T: DualNum<F> + Copy, F: DualNumFloat>: DualNum<F, Inner = T> + Copy;
    type Dual2<T: DualNum<F> + Copy, F: DualNumFloat>: DualNum<F, Inner = T> + Copy;
    type HyperDual<T: DualNum<F> + Copy, F: DualNumFloat>: DualNum<F, Inner = T> + Copy;

    // Required methods
    fn gradient<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<Self::Dual<T, F>, F>>(
        g: G,
        x: &OVector<T, Self>,
        args: &A::Inner,
    ) -> (T, OVector<T, Self>)
       where G: Fn(OVector<Self::Dual<T, F>, Self>, &A) -> Self::Dual<T, F>;
    fn hessian<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<Self::Dual2<T, F>, F>>(
        g: G,
        x: &OVector<T, Self>,
        args: &A::Inner,
    ) -> (T, OVector<T, Self>, OMatrix<T, Self, Self>)
       where G: Fn(OVector<Self::Dual2<T, F>, Self>, &A) -> Self::Dual2<T, F>,
             DefaultAllocator: Allocator<Self, Self>;
    fn partial_hessian<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<Self::HyperDual<T, F>, F>>(
        g: G,
        x: &OVector<T, Self>,
        y: T,
        args: &A::Inner,
    ) -> (T, OVector<T, Self>, T, OVector<T, Self>)
       where G: Fn(OVector<Self::HyperDual<T, F>, Self>, Self::HyperDual<T, F>, &A) -> Self::HyperDual<T, F>;
    fn jacobian<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<Self::Dual<T, F>, F>>(
        g: G,
        x: &OVector<T, Self>,
        args: &A::Inner,
    ) -> (OVector<T, Self>, OMatrix<T, Self, Self>)
       where G: Fn(OVector<Self::Dual<T, F>, Self>, &A) -> OVector<Self::Dual<T, F>, Self>,
             DefaultAllocator: Allocator<Self, Self>;
}
Expand description

Evaluation of gradients, hessians, and partial (Nx1) hessians that is generic over the dimensionality of the input vector.

Required Associated Types§

Source

type Dual<T: DualNum<F> + Copy, F: DualNumFloat>: DualNum<F, Inner = T> + Copy

Source

type Dual2<T: DualNum<F> + Copy, F: DualNumFloat>: DualNum<F, Inner = T> + Copy

Source

type HyperDual<T: DualNum<F> + Copy, F: DualNumFloat>: DualNum<F, Inner = T> + Copy

Required Methods§

Source

fn gradient<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<Self::Dual<T, F>, F>>( g: G, x: &OVector<T, Self>, args: &A::Inner, ) -> (T, OVector<T, Self>)
where G: Fn(OVector<Self::Dual<T, F>, Self>, &A) -> Self::Dual<T, F>,

Source

fn hessian<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<Self::Dual2<T, F>, F>>( g: G, x: &OVector<T, Self>, args: &A::Inner, ) -> (T, OVector<T, Self>, OMatrix<T, Self, Self>)
where G: Fn(OVector<Self::Dual2<T, F>, Self>, &A) -> Self::Dual2<T, F>, DefaultAllocator: Allocator<Self, Self>,

Source

fn partial_hessian<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<Self::HyperDual<T, F>, F>>( g: G, x: &OVector<T, Self>, y: T, args: &A::Inner, ) -> (T, OVector<T, Self>, T, OVector<T, Self>)
where G: Fn(OVector<Self::HyperDual<T, F>, Self>, Self::HyperDual<T, F>, &A) -> Self::HyperDual<T, F>,

Source

fn jacobian<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<Self::Dual<T, F>, F>>( g: G, x: &OVector<T, Self>, args: &A::Inner, ) -> (OVector<T, Self>, OMatrix<T, Self, Self>)
where G: Fn(OVector<Self::Dual<T, F>, Self>, &A) -> OVector<Self::Dual<T, F>, Self>, DefaultAllocator: Allocator<Self, Self>,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Gradients for Dyn

Source§

type Dual<T: DualNum<F> + Copy, F: DualNumFloat> = Dual<T, F>

Source§

type Dual2<T: DualNum<F> + Copy, F: DualNumFloat> = HyperDual<T, F>

Source§

type HyperDual<T: DualNum<F> + Copy, F: DualNumFloat> = HyperDual<T, F>

Source§

fn gradient<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<Dual<T, F>, F>>( g: G, x: &DVector<T>, args: &A::Inner, ) -> (T, DVector<T>)
where G: Fn(OVector<Dual<T, F>, Dyn>, &A) -> Dual<T, F>,

Source§

fn hessian<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<HyperDual<T, F>, F>>( g: G, x: &DVector<T>, args: &A::Inner, ) -> (T, DVector<T>, DMatrix<T>)
where G: Fn(DVector<HyperDual<T, F>>, &A) -> HyperDual<T, F>,

Source§

fn partial_hessian<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<HyperDual<T, F>, F>>( g: G, x: &DVector<T>, y: T, args: &A::Inner, ) -> (T, DVector<T>, T, DVector<T>)
where G: Fn(DVector<HyperDual<T, F>>, HyperDual<T, F>, &A) -> HyperDual<T, F>,

Source§

fn jacobian<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<Self::Dual<T, F>, F>>( g: G, x: &OVector<T, Self>, args: &A::Inner, ) -> (OVector<T, Self>, OMatrix<T, Self, Self>)
where G: Fn(OVector<Dual<T, F>, Self>, &A) -> OVector<Dual<T, F>, Self>, DefaultAllocator: Allocator<Self, Self>,

Source§

impl<const N: usize> Gradients for Const<N>

Source§

type Dual<T: DualNum<F> + Copy, F: DualNumFloat> = DualVec<T, F, Const<N>>

Source§

type Dual2<T: DualNum<F> + Copy, F: DualNumFloat> = Dual2Vec<T, F, Const<N>>

Source§

type HyperDual<T: DualNum<F> + Copy, F: DualNumFloat> = HyperDualVec<T, F, Const<N>, Const<1>>

Source§

fn gradient<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<DualSVec<T, F, N>, F>>( g: G, x: &SVector<T, N>, args: &A::Inner, ) -> (T, SVector<T, N>)
where G: Fn(SVector<DualSVec<T, F, N>, N>, &A) -> DualSVec<T, F, N>,

Source§

fn hessian<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<Self::Dual2<T, F>, F>>( g: G, x: &OVector<T, Self>, args: &A::Inner, ) -> (T, OVector<T, Self>, OMatrix<T, Self, Self>)
where G: Fn(OVector<Self::Dual2<T, F>, Self>, &A) -> Self::Dual2<T, F>,

Source§

fn partial_hessian<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<Self::HyperDual<T, F>, F>>( g: G, x: &OVector<T, Self>, y: T, args: &A::Inner, ) -> (T, OVector<T, Self>, T, OVector<T, Self>)
where G: Fn(OVector<Self::HyperDual<T, F>, Self>, Self::HyperDual<T, F>, &A) -> Self::HyperDual<T, F>,

Source§

fn jacobian<G, T: DualNum<F> + Copy, F: DualNumFloat, A: DualStruct<Self::Dual<T, F>, F>>( g: G, x: &OVector<T, Self>, args: &A::Inner, ) -> (OVector<T, Self>, OMatrix<T, Self, Self>)
where G: Fn(OVector<DualVec<T, F, Self>, Self>, &A) -> OVector<DualVec<T, F, Self>, Self>,

Implementors§