[][src]Struct peroxide::structure::ad::ADLift

pub struct ADLift<F> { /* fields omitted */ }

Lift AD functions

Description

To lift AD functions

Implementation

  • All Fn(T) -> T where T:AD functions can be lift to Fn(f64) -> f64
  • If j > i, then Fn(AD{j}) -> AD{j} can be lift to Fn(AD{i}) -> AD{i}

Usage

extern crate peroxide;
use peroxide::fuga::*;

fn main() {
    let ad0 = 2f64;
    let ad1 = AD1(2f64, 1f64);

    let lift = ADLift::new(f_ad);

    let ans_ad0 = ad0.powi(2);
    let ans_ad1 = ad1.powi(2);

    // f_0: f64 -> f64
    // f:   AD -> AD
    assert_eq!(ans_ad0, lift.f_0(ad0));
    assert_eq!(ans_ad1, lift.f(ad1));
}

fn f_ad(x: AD) -> AD {
    x.powi(2)
}

Implementations

impl<F: Fn(AD) -> AD> ADLift<F>[src]

pub fn new(f: F) -> Self[src]

pub fn f(&self, t: AD) -> AD[src]

pub fn f_0(&self, t: f64) -> f64[src]

Trait Implementations

impl<F: Fn(AD) -> AD> StableFn<f64> for ADLift<F>[src]

type Output = f64

Auto Trait Implementations

impl<F> RefUnwindSafe for ADLift<F> where
    F: RefUnwindSafe
[src]

impl<F> Send for ADLift<F> where
    F: Send
[src]

impl<F> Sync for ADLift<F> where
    F: Sync
[src]

impl<F> Unpin for ADLift<F>[src]

impl<F> UnwindSafe for ADLift<F> where
    F: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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