AD

Trait AD 

Source
pub trait AD:
    RealField
    + ComplexField
    + PartialOrd
    + PartialEq
    + Signed
    + Scalar
    + Clone
    + Copy
    + Debug
    + Display
    + Default
    + Add<F64, Output = Self>
    + AddAssign<F64>
    + Mul<F64, Output = Self>
    + MulAssign<F64>
    + Sub<F64, Output = Self>
    + SubAssign<F64>
    + Div<F64, Output = Self>
    + DivAssign<F64>
    + Rem<F64, Output = Self>
    + RemAssign<F64>
    + From<f32>
    + Into<f64>
    + SimdRealField
    + SimdComplexField
    + Serialize
    + DeserializeOwned
    + MaybeReflect
    + ScalarOperand {
Show 17 methods // Required methods fn constant(constant: f64) -> Self; fn to_constant(&self) -> f64; fn ad_num_mode() -> ADNumMode; fn ad_num_type() -> ADNumType; fn add_scalar(arg1: f64, arg2: Self) -> Self; fn sub_l_scalar(arg1: f64, arg2: Self) -> Self; fn sub_r_scalar(arg1: Self, arg2: f64) -> Self; fn mul_scalar(arg1: f64, arg2: Self) -> Self; fn div_l_scalar(arg1: f64, arg2: Self) -> Self; fn div_r_scalar(arg1: Self, arg2: f64) -> Self; fn rem_l_scalar(arg1: f64, arg2: Self) -> Self; fn rem_r_scalar(arg1: Self, arg2: f64) -> Self; fn mul_by_nalgebra_matrix<R: Clone + Dim, C: Clone + Dim, S: Clone + RawStorageMut<Self, R, C>>( &self, other: Matrix<Self, R, C, S>, ) -> Matrix<Self, R, C, S>; fn mul_by_nalgebra_matrix_ref<'a, R: Clone + Dim, C: Clone + Dim, S: Clone + RawStorageMut<Self, R, C>>( &'a self, other: &'a Matrix<Self, R, C, S>, ) -> Matrix<Self, R, C, S>; fn mul_by_ndarray_matrix_ref<D: Dimension>( &self, other: &ArrayBase<OwnedRepr<Self>, D>, ) -> ArrayBase<OwnedRepr<Self>, D>; // Provided methods fn to_constant_ad(&self) -> Self { ... } fn to_other_ad_type<T2: AD>(&self) -> T2 { ... }
}
Expand description

The core trait for Automatic Differentiation (AD).

This trait defines the interface for types that can participate in automatic differentiation computations. It combines numerical traits (like RealField and ComplexField from simba) with AD-specific functionality.

Types implementing AD can represent:

  • Standard floating-point values (f64, f32) for non-derivative computations.
  • Forward-mode AD types (adfn<K>) for tangent propagation.
  • Reverse-mode AD types (adr) for gradient backpropagation.

Required Methods§

Source

fn constant(constant: f64) -> Self

Creates a constant value of this AD type from an f64.

Source

fn to_constant(&self) -> f64

Converts the current AD value back to its base f64 representation. This retrieves the value without its derivative information.

Source

fn ad_num_mode() -> ADNumMode

Returns the mode of automatic differentiation used by this type.

Source

fn ad_num_type() -> ADNumType

Returns the specific numerical type identifier for this AD type.

Source

fn add_scalar(arg1: f64, arg2: Self) -> Self

Scalar addition between an f64 and an AD value.

Source

fn sub_l_scalar(arg1: f64, arg2: Self) -> Self

Scalar subtraction: arg1 (f64) - arg2 (AD).

Source

fn sub_r_scalar(arg1: Self, arg2: f64) -> Self

Scalar subtraction: arg1 (AD) - arg2 (f64).

Source

fn mul_scalar(arg1: f64, arg2: Self) -> Self

Scalar multiplication between an f64 and an AD value.

Source

fn div_l_scalar(arg1: f64, arg2: Self) -> Self

Scalar division: arg1 (f64) / arg2 (AD).

Source

fn div_r_scalar(arg1: Self, arg2: f64) -> Self

Scalar division: arg1 (AD) / arg2 (f64).

Source

fn rem_l_scalar(arg1: f64, arg2: Self) -> Self

Scalar remainder: arg1 (f64) % arg2 (AD).

Source

fn rem_r_scalar(arg1: Self, arg2: f64) -> Self

Scalar remainder: arg1 (AD) % arg2 (f64).

Source

fn mul_by_nalgebra_matrix<R: Clone + Dim, C: Clone + Dim, S: Clone + RawStorageMut<Self, R, C>>( &self, other: Matrix<Self, R, C, S>, ) -> Matrix<Self, R, C, S>

Multiplies this scalar by an nalgebra matrix of AD values.

Source

fn mul_by_nalgebra_matrix_ref<'a, R: Clone + Dim, C: Clone + Dim, S: Clone + RawStorageMut<Self, R, C>>( &'a self, other: &'a Matrix<Self, R, C, S>, ) -> Matrix<Self, R, C, S>

Multiplies this scalar by a reference to an nalgebra matrix of AD values.

Source

fn mul_by_ndarray_matrix_ref<D: Dimension>( &self, other: &ArrayBase<OwnedRepr<Self>, D>, ) -> ArrayBase<OwnedRepr<Self>, D>

Multiplies this scalar by an ndarray matrix of AD values.

Provided Methods§

Source

fn to_constant_ad(&self) -> Self

Returns the constant version of the current value as a new AD object.

Source

fn to_other_ad_type<T2: AD>(&self) -> T2

Converts this AD value to another AD type. This is useful for reparameterizing functions during the differentiation process.

Examples found in repository?
examples/example1.rs (line 28)
27    pub fn to_other_ad_type<T2: AD>(&self) -> Test<T2> {
28        Test { coeff: self.coeff.to_other_ad_type::<T2>() }
29    }

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

Source§

fn constant(v: f64) -> Self

Source§

fn to_constant(&self) -> f64

Source§

fn ad_num_mode() -> ADNumMode

Source§

fn ad_num_type() -> ADNumType

Source§

fn add_scalar(arg1: f64, arg2: Self) -> Self

Source§

fn sub_l_scalar(arg1: f64, arg2: Self) -> Self

Source§

fn sub_r_scalar(arg1: Self, arg2: f64) -> Self

Source§

fn mul_scalar(arg1: f64, arg2: Self) -> Self

Source§

fn div_l_scalar(arg1: f64, arg2: Self) -> Self

Source§

fn div_r_scalar(arg1: Self, arg2: f64) -> Self

Source§

fn rem_l_scalar(arg1: f64, arg2: Self) -> Self

Source§

fn rem_r_scalar(arg1: Self, arg2: f64) -> Self

Source§

fn mul_by_nalgebra_matrix<R: Clone + Dim, C: Clone + Dim, S: Clone + RawStorageMut<Self, R, C>>( &self, other: Matrix<Self, R, C, S>, ) -> Matrix<Self, R, C, S>

Source§

fn mul_by_nalgebra_matrix_ref<'a, R: Clone + Dim, C: Clone + Dim, S: Clone + RawStorageMut<Self, R, C>>( &'a self, other: &'a Matrix<Self, R, C, S>, ) -> Matrix<Self, R, C, S>

Source§

fn mul_by_ndarray_matrix_ref<D: Dimension>( &self, other: &ArrayBase<OwnedRepr<Self>, D>, ) -> ArrayBase<OwnedRepr<Self>, D>

Source§

impl AD for f64

Source§

fn constant(v: f64) -> Self

Source§

fn to_constant(&self) -> f64

Source§

fn ad_num_mode() -> ADNumMode

Source§

fn ad_num_type() -> ADNumType

Source§

fn add_scalar(arg1: f64, arg2: Self) -> Self

Source§

fn sub_l_scalar(arg1: f64, arg2: Self) -> Self

Source§

fn sub_r_scalar(arg1: Self, arg2: f64) -> Self

Source§

fn mul_scalar(arg1: f64, arg2: Self) -> Self

Source§

fn div_l_scalar(arg1: f64, arg2: Self) -> Self

Source§

fn div_r_scalar(arg1: Self, arg2: f64) -> Self

Source§

fn rem_l_scalar(arg1: f64, arg2: Self) -> Self

Source§

fn rem_r_scalar(arg1: Self, arg2: f64) -> Self

Source§

fn mul_by_nalgebra_matrix<R: Clone + Dim, C: Clone + Dim, S: Clone + RawStorageMut<Self, R, C>>( &self, other: Matrix<Self, R, C, S>, ) -> Matrix<Self, R, C, S>

Source§

fn mul_by_nalgebra_matrix_ref<'a, R: Clone + Dim, C: Clone + Dim, S: Clone + RawStorageMut<Self, R, C>>( &'a self, other: &'a Matrix<Self, R, C, S>, ) -> Matrix<Self, R, C, S>

Source§

fn mul_by_ndarray_matrix_ref<D: Dimension>( &self, other: &ArrayBase<OwnedRepr<Self>, D>, ) -> ArrayBase<OwnedRepr<Self>, D>

Implementors§

Source§

impl AD for adr

Source§

impl<const N: usize> AD for adfn<N>