Skip to main content

Var

Struct Var 

Source
pub struct Var {
    pub value: f64,
    /* private fields */
}
Expand description

A reverse-mode AD variable tracked on a computation tape.

Arithmetic operations on Var automatically record themselves on the shared tape. After computation, use Tape::gradient to differentiate.

Fields§

§value: f64

Primal (forward) value.

Implementations§

Source§

impl Var

Source

pub fn cst(&self, value: f64) -> Var

Create a constant (not differentiated) on the same tape as self.

Source

pub fn sin(&self) -> Var

sin(self)

Source

pub fn cos(&self) -> Var

cos(self)

Source

pub fn tan(&self) -> Var

tan(self)

Source

pub fn exp(&self) -> Var

exp(self)

Source

pub fn ln(&self) -> Var

ln(self) (natural logarithm)

Source

pub fn sqrt(&self) -> Var

sqrt(self)

Source

pub fn abs(&self) -> Var

abs(self)

Source

pub fn tanh(&self) -> Var

tanh(self)

Source

pub fn sinh(&self) -> Var

sinh(self)

Source

pub fn cosh(&self) -> Var

cosh(self)

Source

pub fn pow(&self, n: &Var) -> Var

self^n (power with another Var)

Source

pub fn powf(&self, n: f64) -> Var

self^n (power with f64 constant)

Source

pub fn powi(&self, n: i32) -> Var

self^n (integer power)

Source

pub fn asin(&self) -> Var

asin(self)

Source

pub fn acos(&self) -> Var

acos(self)

Source

pub fn atan(&self) -> Var

atan(self)

Trait Implementations§

Source§

impl Add<Var> for f64

Source§

type Output = Var

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Var) -> Var

Performs the + operation. Read more
Source§

impl Add<f64> for Var

Source§

type Output = Var

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> Var

Performs the + operation. Read more
Source§

impl Add for &Var

Source§

type Output = Var

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Var) -> Var

Performs the + operation. Read more
Source§

impl Add for Var

Source§

type Output = Var

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Var) -> Var

Performs the + operation. Read more
Source§

impl Clone for Var

Source§

fn clone(&self) -> Var

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 Debug for Var

Source§

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

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

impl Div<f64> for Var

Source§

type Output = Var

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Var

Performs the / operation. Read more
Source§

impl Div for &Var

Source§

type Output = Var

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Var) -> Var

Performs the / operation. Read more
Source§

impl Div for Var

Source§

type Output = Var

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Var) -> Var

Performs the / operation. Read more
Source§

impl Mul<&Var> for Var

Source§

type Output = Var

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Var) -> Var

Performs the * operation. Read more
Source§

impl Mul<Var> for &Var

Source§

type Output = Var

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Var) -> Var

Performs the * operation. Read more
Source§

impl Mul<Var> for f64

Source§

type Output = Var

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Var) -> Var

Performs the * operation. Read more
Source§

impl Mul<f64> for Var

Source§

type Output = Var

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Var

Performs the * operation. Read more
Source§

impl Mul for &Var

Source§

type Output = Var

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Var) -> Var

Performs the * operation. Read more
Source§

impl Mul for Var

Source§

type Output = Var

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Var) -> Var

Performs the * operation. Read more
Source§

impl Neg for &Var

Source§

type Output = Var

The resulting type after applying the - operator.
Source§

fn neg(self) -> Var

Performs the unary - operation. Read more
Source§

impl Neg for Var

Source§

type Output = Var

The resulting type after applying the - operator.
Source§

fn neg(self) -> Var

Performs the unary - operation. Read more
Source§

impl Sub<Var> for f64

Source§

type Output = Var

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Var) -> Var

Performs the - operation. Read more
Source§

impl Sub<f64> for Var

Source§

type Output = Var

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f64) -> Var

Performs the - operation. Read more
Source§

impl Sub for &Var

Source§

type Output = Var

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Var) -> Var

Performs the - operation. Read more
Source§

impl Sub for Var

Source§

type Output = Var

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Var) -> Var

Performs the - operation. Read more

Auto Trait Implementations§

§

impl Freeze for Var

§

impl !RefUnwindSafe for Var

§

impl !Send for Var

§

impl !Sync for Var

§

impl Unpin for Var

§

impl UnsafeUnpin for Var

§

impl !UnwindSafe for Var

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