Tape

Struct Tape 

Source
pub struct Tape<F: IntegrateFloat> { /* private fields */ }
Expand description

Reverse mode AD tape for recording operations

Implementations§

Source§

impl<F: IntegrateFloat> Tape<F>

Source

pub fn new() -> Self

Create a new tape

Source

pub fn variable(&mut self, idx: usize, value: F) -> usize

Add a variable to the tape

Source

pub fn constant(&mut self, value: F) -> usize

Add a constant to the tape

Source

pub fn add(&mut self, a: usize, b: usize) -> usize

Record addition

Source

pub fn sub(&mut self, a: usize, b: usize) -> usize

Record subtraction

Source

pub fn mul(&mut self, a: usize, b: usize) -> usize

Record multiplication

Source

pub fn div(&mut self, a: usize, b: usize) -> usize

Record division

Source

pub fn neg(&mut self, a: usize) -> usize

Record negation

Source

pub fn pow(&mut self, a: usize, n: F) -> usize

Record power

Source

pub fn sin(&mut self, a: usize) -> usize

Record sin

Source

pub fn cos(&mut self, a: usize) -> usize

Record cos

Source

pub fn exp(&mut self, a: usize) -> usize

Record exp

Source

pub fn ln(&mut self, a: usize) -> usize

Record ln

Source

pub fn sqrt(&mut self, a: usize) -> usize

Record sqrt

Source

pub fn pow_general(&mut self, a: usize, b: usize) -> usize

Record general power where both base and exponent are variables

Source

pub fn tan(&mut self, a: usize) -> usize

Record tan

Source

pub fn tanh(&mut self, a: usize) -> usize

Record tanh

Source

pub fn sinh(&mut self, a: usize) -> usize

Record sinh

Source

pub fn cosh(&mut self, a: usize) -> usize

Record cosh

Source

pub fn atan2(&mut self, y: usize, x: usize) -> usize

Record atan2

Source

pub fn abs(&mut self, a: usize) -> usize

Record abs

Source

pub fn max(&mut self, a: usize, b: usize) -> usize

Record max

Source

pub fn min(&mut self, a: usize, b: usize) -> usize

Record min

Source

pub fn value(&self, idx: usize) -> F

Get the value at a node

Source

pub fn backward(&mut self, outputidx: usize, nvars: usize) -> Array1<F>

Backward pass to compute gradients

Trait Implementations§

Source§

impl<F: IntegrateFloat> Default for Tape<F>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<F> Freeze for Tape<F>

§

impl<F> !RefUnwindSafe for Tape<F>

§

impl<F> !Send for Tape<F>

§

impl<F> !Sync for Tape<F>

§

impl<F> Unpin for Tape<F>

§

impl<F> !UnwindSafe for Tape<F>

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

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

Source§

fn vzip(self) -> V