ScalarAd

Trait ScalarAd 

Source
pub trait ScalarAd:
    Copy
    + PartialEq
    + Neg<Output = Self>
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self> {
    type Real: Copy + Float + FloatConst;

Show 34 methods // Required methods fn conj(self) -> Self; fn recip(self) -> Self; fn cbrt(self) -> Self; fn sqrt(self) -> Self; fn exp(self) -> Self; fn exp2(self) -> Self; fn exp10(self) -> Self; fn expm1(self) -> Self; fn ln(self) -> Self; fn log1p(self) -> Self; fn log2(self) -> Self; fn log10(self) -> Self; fn sin(self) -> Self; fn cos(self) -> Self; fn tan(self) -> Self; fn tanh(self) -> Self; fn asin(self) -> Self; fn acos(self) -> Self; fn atan(self) -> Self; fn sinh(self) -> Self; fn cosh(self) -> Self; fn asinh(self) -> Self; fn acosh(self) -> Self; fn atanh(self) -> Self; fn abs(self) -> Self::Real; fn abs2(self) -> Self::Real; fn real(self) -> Self::Real; fn imag(self) -> Self::Real; fn angle(self) -> Self::Real; fn powf(self, exponent: Self::Real) -> Self; fn powi(self, exponent: i32) -> Self; fn pow(self, exponent: Self) -> Self; fn from_real(value: Self::Real) -> Self; fn from_i32(value: i32) -> Self;
}
Expand description

Scalar trait used by elementary AD rule helpers.

§Examples

use chainrules::ScalarAd;

fn takes_scalar<S: ScalarAd>(_x: S) {}

takes_scalar(1.0_f32);
takes_scalar(1.0_f64);

Required Associated Types§

Source

type Real: Copy + Float + FloatConst

Real exponent type for powf.

Required Methods§

Source

fn conj(self) -> Self

Complex conjugate (identity for real scalars).

Source

fn recip(self) -> Self

Reciprocal.

Source

fn cbrt(self) -> Self

Cubic root.

Source

fn sqrt(self) -> Self

Square root.

Source

fn exp(self) -> Self

Exponential.

Source

fn exp2(self) -> Self

2^self.

Source

fn exp10(self) -> Self

10^self.

Source

fn expm1(self) -> Self

exp(self) - 1.

Source

fn ln(self) -> Self

Natural logarithm.

Source

fn log1p(self) -> Self

ln(1 + self).

Source

fn log2(self) -> Self

Base-2 logarithm.

Source

fn log10(self) -> Self

Base-10 logarithm.

Source

fn sin(self) -> Self

Sine.

Source

fn cos(self) -> Self

Cosine.

Source

fn tan(self) -> Self

Tangent.

Source

fn tanh(self) -> Self

Hyperbolic tangent.

Source

fn asin(self) -> Self

Arc sine.

Source

fn acos(self) -> Self

Arc cosine.

Source

fn atan(self) -> Self

Arc tangent.

Source

fn sinh(self) -> Self

Hyperbolic sine.

Source

fn cosh(self) -> Self

Hyperbolic cosine.

Source

fn asinh(self) -> Self

Area hyperbolic sine.

Source

fn acosh(self) -> Self

Area hyperbolic cosine.

Source

fn atanh(self) -> Self

Area hyperbolic tangent.

Source

fn abs(self) -> Self::Real

Absolute value.

Source

fn abs2(self) -> Self::Real

Absolute value squared.

Source

fn real(self) -> Self::Real

Real part.

Source

fn imag(self) -> Self::Real

Imaginary part.

Source

fn angle(self) -> Self::Real

Polar angle.

Source

fn powf(self, exponent: Self::Real) -> Self

Power by real exponent.

Source

fn powi(self, exponent: i32) -> Self

Power by integer exponent.

Source

fn pow(self, exponent: Self) -> Self

Power by same-scalar exponent.

Source

fn from_real(value: Self::Real) -> Self

Convert real scalar to this scalar type.

Source

fn from_i32(value: i32) -> Self

Convert signed integer to this scalar type.

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 ScalarAd for f32

Source§

type Real = f32

Source§

fn conj(self) -> Self

Source§

fn recip(self) -> Self

Source§

fn cbrt(self) -> Self

Source§

fn sqrt(self) -> Self

Source§

fn exp(self) -> Self

Source§

fn exp2(self) -> Self

Source§

fn exp10(self) -> Self

Source§

fn expm1(self) -> Self

Source§

fn ln(self) -> Self

Source§

fn log1p(self) -> Self

Source§

fn log2(self) -> Self

Source§

fn log10(self) -> Self

Source§

fn sin(self) -> Self

Source§

fn cos(self) -> Self

Source§

fn tan(self) -> Self

Source§

fn tanh(self) -> Self

Source§

fn asin(self) -> Self

Source§

fn acos(self) -> Self

Source§

fn atan(self) -> Self

Source§

fn sinh(self) -> Self

Source§

fn cosh(self) -> Self

Source§

fn asinh(self) -> Self

Source§

fn acosh(self) -> Self

Source§

fn atanh(self) -> Self

Source§

fn abs(self) -> Self::Real

Source§

fn abs2(self) -> Self::Real

Source§

fn real(self) -> Self::Real

Source§

fn imag(self) -> Self::Real

Source§

fn angle(self) -> Self::Real

Source§

fn powf(self, exponent: Self::Real) -> Self

Source§

fn powi(self, exponent: i32) -> Self

Source§

fn pow(self, exponent: Self) -> Self

Source§

fn from_real(value: Self::Real) -> Self

Source§

fn from_i32(value: i32) -> Self

Source§

impl ScalarAd for f64

Source§

type Real = f64

Source§

fn conj(self) -> Self

Source§

fn recip(self) -> Self

Source§

fn cbrt(self) -> Self

Source§

fn sqrt(self) -> Self

Source§

fn exp(self) -> Self

Source§

fn exp2(self) -> Self

Source§

fn exp10(self) -> Self

Source§

fn expm1(self) -> Self

Source§

fn ln(self) -> Self

Source§

fn log1p(self) -> Self

Source§

fn log2(self) -> Self

Source§

fn log10(self) -> Self

Source§

fn sin(self) -> Self

Source§

fn cos(self) -> Self

Source§

fn tan(self) -> Self

Source§

fn tanh(self) -> Self

Source§

fn asin(self) -> Self

Source§

fn acos(self) -> Self

Source§

fn atan(self) -> Self

Source§

fn sinh(self) -> Self

Source§

fn cosh(self) -> Self

Source§

fn asinh(self) -> Self

Source§

fn acosh(self) -> Self

Source§

fn atanh(self) -> Self

Source§

fn abs(self) -> Self::Real

Source§

fn abs2(self) -> Self::Real

Source§

fn real(self) -> Self::Real

Source§

fn imag(self) -> Self::Real

Source§

fn angle(self) -> Self::Real

Source§

fn powf(self, exponent: Self::Real) -> Self

Source§

fn powi(self, exponent: i32) -> Self

Source§

fn pow(self, exponent: Self) -> Self

Source§

fn from_real(value: Self::Real) -> Self

Source§

fn from_i32(value: i32) -> Self

Source§

impl ScalarAd for Complex32

Source§

type Real = f32

Source§

fn conj(self) -> Self

Source§

fn recip(self) -> Self

Source§

fn cbrt(self) -> Self

Source§

fn sqrt(self) -> Self

Source§

fn exp(self) -> Self

Source§

fn exp2(self) -> Self

Source§

fn exp10(self) -> Self

Source§

fn expm1(self) -> Self

Source§

fn ln(self) -> Self

Source§

fn log1p(self) -> Self

Source§

fn log2(self) -> Self

Source§

fn log10(self) -> Self

Source§

fn sin(self) -> Self

Source§

fn cos(self) -> Self

Source§

fn tan(self) -> Self

Source§

fn tanh(self) -> Self

Source§

fn asin(self) -> Self

Source§

fn acos(self) -> Self

Source§

fn atan(self) -> Self

Source§

fn sinh(self) -> Self

Source§

fn cosh(self) -> Self

Source§

fn asinh(self) -> Self

Source§

fn acosh(self) -> Self

Source§

fn atanh(self) -> Self

Source§

fn abs(self) -> Self::Real

Source§

fn abs2(self) -> Self::Real

Source§

fn real(self) -> Self::Real

Source§

fn imag(self) -> Self::Real

Source§

fn angle(self) -> Self::Real

Source§

fn powf(self, exponent: Self::Real) -> Self

Source§

fn powi(self, exponent: i32) -> Self

Source§

fn pow(self, exponent: Self) -> Self

Source§

fn from_real(value: Self::Real) -> Self

Source§

fn from_i32(value: i32) -> Self

Source§

impl ScalarAd for Complex64

Source§

type Real = f64

Source§

fn conj(self) -> Self

Source§

fn recip(self) -> Self

Source§

fn cbrt(self) -> Self

Source§

fn sqrt(self) -> Self

Source§

fn exp(self) -> Self

Source§

fn exp2(self) -> Self

Source§

fn exp10(self) -> Self

Source§

fn expm1(self) -> Self

Source§

fn ln(self) -> Self

Source§

fn log1p(self) -> Self

Source§

fn log2(self) -> Self

Source§

fn log10(self) -> Self

Source§

fn sin(self) -> Self

Source§

fn cos(self) -> Self

Source§

fn tan(self) -> Self

Source§

fn tanh(self) -> Self

Source§

fn asin(self) -> Self

Source§

fn acos(self) -> Self

Source§

fn atan(self) -> Self

Source§

fn sinh(self) -> Self

Source§

fn cosh(self) -> Self

Source§

fn asinh(self) -> Self

Source§

fn acosh(self) -> Self

Source§

fn atanh(self) -> Self

Source§

fn abs(self) -> Self::Real

Source§

fn abs2(self) -> Self::Real

Source§

fn real(self) -> Self::Real

Source§

fn imag(self) -> Self::Real

Source§

fn angle(self) -> Self::Real

Source§

fn powf(self, exponent: Self::Real) -> Self

Source§

fn powi(self, exponent: i32) -> Self

Source§

fn pow(self, exponent: Self) -> Self

Source§

fn from_real(value: Self::Real) -> Self

Source§

fn from_i32(value: i32) -> Self

Implementors§