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§
Sourcefn to_constant(&self) -> f64
fn to_constant(&self) -> f64
Converts the current AD value back to its base f64 representation.
This retrieves the value without its derivative information.
Sourcefn ad_num_mode() -> ADNumMode
fn ad_num_mode() -> ADNumMode
Returns the mode of automatic differentiation used by this type.
Sourcefn ad_num_type() -> ADNumType
fn ad_num_type() -> ADNumType
Returns the specific numerical type identifier for this AD type.
Sourcefn add_scalar(arg1: f64, arg2: Self) -> Self
fn add_scalar(arg1: f64, arg2: Self) -> Self
Scalar addition between an f64 and an AD value.
Sourcefn sub_l_scalar(arg1: f64, arg2: Self) -> Self
fn sub_l_scalar(arg1: f64, arg2: Self) -> Self
Scalar subtraction: arg1 (f64) - arg2 (AD).
Sourcefn sub_r_scalar(arg1: Self, arg2: f64) -> Self
fn sub_r_scalar(arg1: Self, arg2: f64) -> Self
Scalar subtraction: arg1 (AD) - arg2 (f64).
Sourcefn mul_scalar(arg1: f64, arg2: Self) -> Self
fn mul_scalar(arg1: f64, arg2: Self) -> Self
Scalar multiplication between an f64 and an AD value.
Sourcefn div_l_scalar(arg1: f64, arg2: Self) -> Self
fn div_l_scalar(arg1: f64, arg2: Self) -> Self
Scalar division: arg1 (f64) / arg2 (AD).
Sourcefn div_r_scalar(arg1: Self, arg2: f64) -> Self
fn div_r_scalar(arg1: Self, arg2: f64) -> Self
Scalar division: arg1 (AD) / arg2 (f64).
Sourcefn rem_l_scalar(arg1: f64, arg2: Self) -> Self
fn rem_l_scalar(arg1: f64, arg2: Self) -> Self
Scalar remainder: arg1 (f64) % arg2 (AD).
Sourcefn rem_r_scalar(arg1: Self, arg2: f64) -> Self
fn rem_r_scalar(arg1: Self, arg2: f64) -> Self
Scalar remainder: arg1 (AD) % arg2 (f64).
Sourcefn 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<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.
Sourcefn 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_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.
Provided Methods§
Sourcefn to_constant_ad(&self) -> Self
fn to_constant_ad(&self) -> Self
Returns the constant version of the current value as a new AD object.
Sourcefn to_other_ad_type<T2: AD>(&self) -> T2
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.
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.