pub struct Ad<const N: usize> { /* private fields */ }Expand description
Automatic differentiation value tracking first and second derivatives
§Value getters:
value() -> f64: Returns the current numerical valuegrad() -> SVector<f64, N>: Returns the gradient vectorhess() -> SMatrix<f64, N, N>: Returns the Hessian matrix
§Type Parameters
N- The dimension of the input space (number of variables)
§Fields (private)
value- The current value of the functiongrad- The gradient (first derivatives) as a vectorhess- The Hessian matrix (second derivatives)
Implementations§
Source§impl<const N: usize> Ad<N>
impl<const N: usize> Ad<N>
pub fn neg(&self) -> Self
pub fn sqrt(&self) -> Self
pub fn square(&self) -> Self
pub fn powf(&self, exponent: f64) -> Self
pub fn abs(&self) -> Self
pub fn exp(&self) -> Self
Sourcepub fn ln(&self) -> Self
pub fn ln(&self) -> Self
Examples found in repository?
src/examples/basic.rs (line 17)
9fn main() {
10 // 1.
11 // ################ scalar ################
12 let mut rng = thread_rng();
13 let val = rng.gen_range(0.0..10.0);
14
15 let var = var::scalar(val);
16 let var = &var;
17 let y = var.sin() * var + var.ln();
18 let g = val * val.cos() + val.sin() + val.recip();
19 let h = -val * val.sin() + 2.0 * val.cos() - val.powi(-2);
20
21 assert_abs_diff_eq!(y.grad()[(0, 0)], g, epsilon = EPS);
22 assert_abs_diff_eq!(y.hess()[(0, 0)], h, epsilon = EPS);
23
24 // 2.
25 // ############################# Matrix #############################
26
27 const N_TEST_MAT_4: usize = 4;
28 type NaConst = Const<N_TEST_MAT_4>;
29 const N_VEC_4: usize = N_TEST_MAT_4 * N_TEST_MAT_4;
30
31 let vals: &[f64] = &(0..N_VEC_4)
32 .map(|_| rng.gen_range(-4.0..4.0))
33 .collect::<Vec<_>>();
34
35 let s: SVector<Ad<N_VEC_4>, N_VEC_4> = var::vector_from_slice(vals);
36 let z = s
37 .clone()
38 // This reshape is COL MAJOR!!!!!!!!!!!!!
39 .reshape_generic(NaConst {}, NaConst {})
40 .transpose();
41
42 let det = z.determinant();
43 let _grad = det.grad();
44 let _hess = det.hess();
45 // core logic ends ####################################################
46
47 // correctness
48 // let expected_grad = grad_det4(
49 // vals[0], vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], vals[8], vals[9],
50 // vals[10], vals[11], vals[12], vals[13], vals[14], vals[15],
51 // );
52 // let g_diff = (expected_grad - det.grad()).norm_squared();
53 // assert_abs_diff_eq!(g_diff, 0.0, epsilon = EPS);
54
55 // let expected_hess = hess_det4(
56 // vals[0], vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], vals[8], vals[9],
57 // vals[10], vals[11], vals[12], vals[13], vals[14], vals[15],
58 // );
59 // let h_diff = (det.hess() - expected_hess).norm_squared();
60 // assert_abs_diff_eq!(h_diff, 0.0, epsilon = EPS);
61}pub fn log(&self, base: f64) -> Self
pub fn log2(&self) -> Self
pub fn log10(&self) -> Self
Sourcepub fn sin(&self) -> Self
pub fn sin(&self) -> Self
Examples found in repository?
src/examples/basic.rs (line 17)
9fn main() {
10 // 1.
11 // ################ scalar ################
12 let mut rng = thread_rng();
13 let val = rng.gen_range(0.0..10.0);
14
15 let var = var::scalar(val);
16 let var = &var;
17 let y = var.sin() * var + var.ln();
18 let g = val * val.cos() + val.sin() + val.recip();
19 let h = -val * val.sin() + 2.0 * val.cos() - val.powi(-2);
20
21 assert_abs_diff_eq!(y.grad()[(0, 0)], g, epsilon = EPS);
22 assert_abs_diff_eq!(y.hess()[(0, 0)], h, epsilon = EPS);
23
24 // 2.
25 // ############################# Matrix #############################
26
27 const N_TEST_MAT_4: usize = 4;
28 type NaConst = Const<N_TEST_MAT_4>;
29 const N_VEC_4: usize = N_TEST_MAT_4 * N_TEST_MAT_4;
30
31 let vals: &[f64] = &(0..N_VEC_4)
32 .map(|_| rng.gen_range(-4.0..4.0))
33 .collect::<Vec<_>>();
34
35 let s: SVector<Ad<N_VEC_4>, N_VEC_4> = var::vector_from_slice(vals);
36 let z = s
37 .clone()
38 // This reshape is COL MAJOR!!!!!!!!!!!!!
39 .reshape_generic(NaConst {}, NaConst {})
40 .transpose();
41
42 let det = z.determinant();
43 let _grad = det.grad();
44 let _hess = det.hess();
45 // core logic ends ####################################################
46
47 // correctness
48 // let expected_grad = grad_det4(
49 // vals[0], vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], vals[8], vals[9],
50 // vals[10], vals[11], vals[12], vals[13], vals[14], vals[15],
51 // );
52 // let g_diff = (expected_grad - det.grad()).norm_squared();
53 // assert_abs_diff_eq!(g_diff, 0.0, epsilon = EPS);
54
55 // let expected_hess = hess_det4(
56 // vals[0], vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], vals[8], vals[9],
57 // vals[10], vals[11], vals[12], vals[13], vals[14], vals[15],
58 // );
59 // let h_diff = (det.hess() - expected_hess).norm_squared();
60 // assert_abs_diff_eq!(h_diff, 0.0, epsilon = EPS);
61}pub fn cos(&self) -> Self
pub fn tan(&self) -> Self
pub fn asin(&self) -> Self
pub fn acos(&self) -> Self
pub fn atan(&self) -> Self
👎Deprecated: Please use atan2 instead.
pub fn sinh(&self) -> Self
pub fn cosh(&self) -> Self
pub fn tanh(&self) -> Self
pub fn asinh(&self) -> Self
pub fn acosh(&self) -> Self
pub fn atanh(&self) -> Self
Source§impl<const N: usize> Ad<N>
impl<const N: usize> Ad<N>
pub fn add_value(&self, other: f64) -> Self
pub fn sub_value(&self, other: f64) -> Self
pub fn mul_value(&self, other: f64) -> Self
pub fn recip(&self) -> Self
pub fn div_value(&self, other: f64) -> Self
pub fn min(&self, other: &Self) -> Self
pub fn max(&self, other: &Self) -> Self
pub fn clamp(&self, low: &Self, high: &Self) -> Self
pub fn hypot(&self, other: &Self) -> Self
Source§impl<const N: usize> Ad<N>
impl<const N: usize> Ad<N>
Sourcepub fn grad(&self) -> SVector<f64, L>
pub fn grad(&self) -> SVector<f64, L>
Returns the gradient (first derivatives) of the AD variable
§Returns
The gradient (A vector containing the partial derivatives with respect to each input variable).
Examples found in repository?
src/examples/basic.rs (line 21)
9fn main() {
10 // 1.
11 // ################ scalar ################
12 let mut rng = thread_rng();
13 let val = rng.gen_range(0.0..10.0);
14
15 let var = var::scalar(val);
16 let var = &var;
17 let y = var.sin() * var + var.ln();
18 let g = val * val.cos() + val.sin() + val.recip();
19 let h = -val * val.sin() + 2.0 * val.cos() - val.powi(-2);
20
21 assert_abs_diff_eq!(y.grad()[(0, 0)], g, epsilon = EPS);
22 assert_abs_diff_eq!(y.hess()[(0, 0)], h, epsilon = EPS);
23
24 // 2.
25 // ############################# Matrix #############################
26
27 const N_TEST_MAT_4: usize = 4;
28 type NaConst = Const<N_TEST_MAT_4>;
29 const N_VEC_4: usize = N_TEST_MAT_4 * N_TEST_MAT_4;
30
31 let vals: &[f64] = &(0..N_VEC_4)
32 .map(|_| rng.gen_range(-4.0..4.0))
33 .collect::<Vec<_>>();
34
35 let s: SVector<Ad<N_VEC_4>, N_VEC_4> = var::vector_from_slice(vals);
36 let z = s
37 .clone()
38 // This reshape is COL MAJOR!!!!!!!!!!!!!
39 .reshape_generic(NaConst {}, NaConst {})
40 .transpose();
41
42 let det = z.determinant();
43 let _grad = det.grad();
44 let _hess = det.hess();
45 // core logic ends ####################################################
46
47 // correctness
48 // let expected_grad = grad_det4(
49 // vals[0], vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], vals[8], vals[9],
50 // vals[10], vals[11], vals[12], vals[13], vals[14], vals[15],
51 // );
52 // let g_diff = (expected_grad - det.grad()).norm_squared();
53 // assert_abs_diff_eq!(g_diff, 0.0, epsilon = EPS);
54
55 // let expected_hess = hess_det4(
56 // vals[0], vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], vals[8], vals[9],
57 // vals[10], vals[11], vals[12], vals[13], vals[14], vals[15],
58 // );
59 // let h_diff = (det.hess() - expected_hess).norm_squared();
60 // assert_abs_diff_eq!(h_diff, 0.0, epsilon = EPS);
61}Sourcepub fn hess(&self) -> SMatrix<f64, RC, RC>
pub fn hess(&self) -> SMatrix<f64, RC, RC>
Examples found in repository?
src/examples/basic.rs (line 22)
9fn main() {
10 // 1.
11 // ################ scalar ################
12 let mut rng = thread_rng();
13 let val = rng.gen_range(0.0..10.0);
14
15 let var = var::scalar(val);
16 let var = &var;
17 let y = var.sin() * var + var.ln();
18 let g = val * val.cos() + val.sin() + val.recip();
19 let h = -val * val.sin() + 2.0 * val.cos() - val.powi(-2);
20
21 assert_abs_diff_eq!(y.grad()[(0, 0)], g, epsilon = EPS);
22 assert_abs_diff_eq!(y.hess()[(0, 0)], h, epsilon = EPS);
23
24 // 2.
25 // ############################# Matrix #############################
26
27 const N_TEST_MAT_4: usize = 4;
28 type NaConst = Const<N_TEST_MAT_4>;
29 const N_VEC_4: usize = N_TEST_MAT_4 * N_TEST_MAT_4;
30
31 let vals: &[f64] = &(0..N_VEC_4)
32 .map(|_| rng.gen_range(-4.0..4.0))
33 .collect::<Vec<_>>();
34
35 let s: SVector<Ad<N_VEC_4>, N_VEC_4> = var::vector_from_slice(vals);
36 let z = s
37 .clone()
38 // This reshape is COL MAJOR!!!!!!!!!!!!!
39 .reshape_generic(NaConst {}, NaConst {})
40 .transpose();
41
42 let det = z.determinant();
43 let _grad = det.grad();
44 let _hess = det.hess();
45 // core logic ends ####################################################
46
47 // correctness
48 // let expected_grad = grad_det4(
49 // vals[0], vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], vals[8], vals[9],
50 // vals[10], vals[11], vals[12], vals[13], vals[14], vals[15],
51 // );
52 // let g_diff = (expected_grad - det.grad()).norm_squared();
53 // assert_abs_diff_eq!(g_diff, 0.0, epsilon = EPS);
54
55 // let expected_hess = hess_det4(
56 // vals[0], vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], vals[8], vals[9],
57 // vals[10], vals[11], vals[12], vals[13], vals[14], vals[15],
58 // );
59 // let h_diff = (det.hess() - expected_hess).norm_squared();
60 // assert_abs_diff_eq!(h_diff, 0.0, epsilon = EPS);
61}Source§impl Ad<1>
impl Ad<1>
Sourcepub fn given_scalar(value: f64, grad: f64, hess: f64) -> Self
pub fn given_scalar(value: f64, grad: f64, hess: f64) -> Self
Sourcepub fn active_scalar(value: f64) -> Self
pub fn active_scalar(value: f64) -> Self
Source§impl<const N: usize> Ad<N>
impl<const N: usize> Ad<N>
Sourcepub fn inactive_scalar(value: f64) -> Self
pub fn inactive_scalar(value: f64) -> Self
Sourcepub fn inactive_from_slice<const L: usize>(values: &[f64]) -> SVector<Self, L>
pub fn inactive_from_slice<const L: usize>(values: &[f64]) -> SVector<Self, L>
Sourcepub fn given_vector(
value: f64,
grad: &SVector<f64, L>,
hess: &SMatrix<f64, RC, RC>,
) -> Self
pub fn given_vector( value: f64, grad: &SVector<f64, L>, hess: &SMatrix<f64, RC, RC>, ) -> Self
Sourcepub fn active_vector(vector: &SVector<f64, N>) -> SVector<Self, N>
pub fn active_vector(vector: &SVector<f64, N>) -> SVector<Self, N>
Trait Implementations§
Source§impl<const N: usize> AbsDiffEq for Ad<N>
impl<const N: usize> AbsDiffEq for Ad<N>
Source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
The default tolerance to use when testing values that are close together. Read more
Source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
A test for equality that uses the absolute difference to compute the approximate
equality of two numbers.
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of
AbsDiffEq::abs_diff_eq.Source§impl<const N: usize> AddAssign<&Ad<N>> for Ad<N>
impl<const N: usize> AddAssign<&Ad<N>> for Ad<N>
Source§fn add_assign(&mut self, rhs: &Ad<N>)
fn add_assign(&mut self, rhs: &Ad<N>)
Performs the
+= operation. Read moreSource§impl<const N: usize> AddAssign for Ad<N>
impl<const N: usize> AddAssign for Ad<N>
Source§fn add_assign(&mut self, rhs: Ad<N>)
fn add_assign(&mut self, rhs: Ad<N>)
Performs the
+= operation. Read moreSource§impl<const N: usize> ComplexField for Ad<N>
impl<const N: usize> ComplexField for Ad<N>
Source§fn from_real(re: Self::RealField) -> Self
fn from_real(re: Self::RealField) -> Self
Builds a pure-real complex number from the given value.
Source§fn modulus_squared(self) -> Self::RealField
fn modulus_squared(self) -> Self::RealField
The squared modulus of this complex number.
Source§fn argument(self) -> Self::RealField
fn argument(self) -> Self::RealField
The argument of this complex number. This should be zero with no grad w.r.t. self, but the use of this method is itself a bug.
Source§fn norm1(self) -> Self::RealField
fn norm1(self) -> Self::RealField
The sum of the absolute value of this complex number’s real and imaginary part.
Source§fn abs(self) -> Self::RealField
fn abs(self) -> Self::RealField
The absolute value of this complex number: self / self.signum().
This is equivalent to self.modulus().
Source§fn hypot(self, other: Self) -> Self::RealField
fn hypot(self, other: Self) -> Self::RealField
Computes (self.conjugate() * self + other.conjugate() * other).sqrt()
type RealField = Ad<N>
fn floor(self) -> Self
fn ceil(self) -> Self
fn round(self) -> Self
fn trunc(self) -> Self
fn fract(self) -> Self
fn mul_add(self, a: Self, b: Self) -> Self
fn recip(self) -> Self
fn sin(self) -> Self
fn cos(self) -> Self
fn sin_cos(self) -> (Self, Self)
fn tan(self) -> Self
fn asin(self) -> Self
fn acos(self) -> Self
fn atan(self) -> Self
fn sinh(self) -> Self
fn cosh(self) -> Self
fn tanh(self) -> Self
fn asinh(self) -> Self
fn acosh(self) -> Self
fn atanh(self) -> Self
fn log(self, base: Self::RealField) -> Self
fn log2(self) -> Self
fn log10(self) -> Self
fn ln(self) -> Self
fn ln_1p(self) -> Self
fn sqrt(self) -> Self
fn exp(self) -> Self
fn exp2(self) -> Self
fn exp_m1(self) -> Self
fn powi(self, exponent: i32) -> Self
fn powf(self, n: Self::RealField) -> Self
fn powc(self, n: Self) -> Self
fn cbrt(self) -> Self
fn is_finite(&self) -> bool
fn try_sqrt(self) -> Option<Self>
Source§fn to_polar(self) -> (Self::RealField, Self::RealField)
fn to_polar(self) -> (Self::RealField, Self::RealField)
The polar form of this complex number: (modulus, arg)
Source§fn to_exp(self) -> (Self::RealField, Self)
fn to_exp(self) -> (Self::RealField, Self)
The exponential form of this complex number: (modulus, e^{i arg})
fn sinh_cosh(self) -> (Self, Self)
fn sinhc(self) -> Self
fn coshc(self) -> Self
Source§impl<const N: usize> DivAssign<&Ad<N>> for Ad<N>
impl<const N: usize> DivAssign<&Ad<N>> for Ad<N>
Source§fn div_assign(&mut self, rhs: &Ad<N>)
fn div_assign(&mut self, rhs: &Ad<N>)
Performs the
/= operation. Read moreSource§impl<const N: usize> DivAssign for Ad<N>
impl<const N: usize> DivAssign for Ad<N>
Source§fn div_assign(&mut self, rhs: Ad<N>)
fn div_assign(&mut self, rhs: Ad<N>)
Performs the
/= operation. Read moreSource§impl<const N: usize> FromPrimitive for Ad<N>
impl<const N: usize> FromPrimitive for Ad<N>
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u16(n: u16) -> Option<Self>
fn from_u16(n: u16) -> Option<Self>
Converts an
u16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u32(n: u32) -> Option<Self>
fn from_u32(n: u32) -> Option<Self>
Converts an
u32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§impl<const N: usize, const R: usize, const C: usize> Mul<&Matrix<Ad<N>, Const<R>, Const<C>, ArrayStorage<Ad<N>, R, C>>> for &Ad<N>
impl<const N: usize, const R: usize, const C: usize> Mul<&Matrix<Ad<N>, Const<R>, Const<C>, ArrayStorage<Ad<N>, R, C>>> for &Ad<N>
Source§impl<const N: usize, const R: usize, const C: usize> Mul<&Matrix<Ad<N>, Const<R>, Const<C>, ArrayStorage<Ad<N>, R, C>>> for Ad<N>
impl<const N: usize, const R: usize, const C: usize> Mul<&Matrix<Ad<N>, Const<R>, Const<C>, ArrayStorage<Ad<N>, R, C>>> for Ad<N>
Source§impl<const N: usize, const R: usize, const C: usize> Mul<Matrix<Ad<N>, Const<R>, Const<C>, ArrayStorage<Ad<N>, R, C>>> for &Ad<N>
impl<const N: usize, const R: usize, const C: usize> Mul<Matrix<Ad<N>, Const<R>, Const<C>, ArrayStorage<Ad<N>, R, C>>> for &Ad<N>
Source§impl<const N: usize, const R: usize, const C: usize> Mul<Matrix<Ad<N>, Const<R>, Const<C>, ArrayStorage<Ad<N>, R, C>>> for Ad<N>
impl<const N: usize, const R: usize, const C: usize> Mul<Matrix<Ad<N>, Const<R>, Const<C>, ArrayStorage<Ad<N>, R, C>>> for Ad<N>
Source§impl<const N: usize> MulAssign<&Ad<N>> for Ad<N>
impl<const N: usize> MulAssign<&Ad<N>> for Ad<N>
Source§fn mul_assign(&mut self, rhs: &Ad<N>)
fn mul_assign(&mut self, rhs: &Ad<N>)
Performs the
*= operation. Read moreSource§impl<const N: usize> MulAssign for Ad<N>
impl<const N: usize> MulAssign for Ad<N>
Source§fn mul_assign(&mut self, rhs: Ad<N>)
fn mul_assign(&mut self, rhs: Ad<N>)
Performs the
*= operation. Read moreSource§impl<const N: usize> Num for Ad<N>
impl<const N: usize> Num for Ad<N>
type FromStrRadixErr = ()
Source§fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
Convert from a string and radix (typically
2..=36). Read moreSource§impl<const N: usize> PartialOrd<Ad<N>> for f64
impl<const N: usize> PartialOrd<Ad<N>> for f64
Source§impl<const N: usize> PartialOrd<f64> for Ad<N>
impl<const N: usize> PartialOrd<f64> for Ad<N>
Source§impl<const N: usize> PartialOrd for Ad<N>
impl<const N: usize> PartialOrd for Ad<N>
Source§impl<const N: usize> RealField for Ad<N>
impl<const N: usize> RealField for Ad<N>
Source§fn is_sign_positive(&self) -> bool
fn is_sign_positive(&self) -> bool
Is the sign of this real number positive?
Source§fn is_sign_negative(&self) -> bool
fn is_sign_negative(&self) -> bool
Is the sign of this real number negative?
fn max(self, other: Self) -> Self
fn min(self, other: Self) -> Self
fn clamp(self, min: Self, max: Self) -> Self
fn atan2(self, other: Self) -> Self
Source§fn min_value() -> Option<Self>
fn min_value() -> Option<Self>
The smallest finite positive value representable using this type.
Source§fn max_value() -> Option<Self>
fn max_value() -> Option<Self>
The largest finite positive value representable using this type.
fn pi() -> Self
fn two_pi() -> Self
fn frac_pi_2() -> Self
fn frac_pi_3() -> Self
fn frac_pi_4() -> Self
fn frac_pi_6() -> Self
fn frac_pi_8() -> Self
fn frac_1_pi() -> Self
fn frac_2_pi() -> Self
fn frac_2_sqrt_pi() -> Self
fn e() -> Self
fn log2_e() -> Self
fn log10_e() -> Self
fn ln_2() -> Self
fn ln_10() -> Self
Source§impl<const N: usize> RelativeEq for Ad<N>
impl<const N: usize> RelativeEq for Ad<N>
Source§fn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
Source§fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
A test for equality that uses a relative comparison if the values are far apart.
Source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
The inverse of
RelativeEq::relative_eq.Source§impl<const N: usize> RemAssign<&Ad<N>> for Ad<N>
impl<const N: usize> RemAssign<&Ad<N>> for Ad<N>
Source§fn rem_assign(&mut self, rhs: &Ad<N>)
fn rem_assign(&mut self, rhs: &Ad<N>)
Performs the
%= operation. Read moreSource§impl<const N: usize> RemAssign for Ad<N>
impl<const N: usize> RemAssign for Ad<N>
Source§fn rem_assign(&mut self, rhs: Ad<N>)
fn rem_assign(&mut self, rhs: Ad<N>)
Performs the
%= operation. Read moreSource§impl<const N: usize> Signed for Ad<N>
impl<const N: usize> Signed for Ad<N>
Source§fn is_positive(&self) -> bool
fn is_positive(&self) -> bool
Returns true if the number is positive and false if the number is zero or negative.
Source§fn is_negative(&self) -> bool
fn is_negative(&self) -> bool
Returns true if the number is negative and false if the number is zero or positive.
Source§impl<const N: usize> SimdValue for Ad<N>
impl<const N: usize> SimdValue for Ad<N>
Source§unsafe fn extract_unchecked(&self, i: usize) -> Self::Element
unsafe fn extract_unchecked(&self, i: usize) -> Self::Element
Extracts the i-th lane of
self without bound-checking. Read moreSource§unsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element)
unsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element)
Source§impl<const N: usize> SubAssign<&Ad<N>> for Ad<N>
impl<const N: usize> SubAssign<&Ad<N>> for Ad<N>
Source§fn sub_assign(&mut self, rhs: &Ad<N>)
fn sub_assign(&mut self, rhs: &Ad<N>)
Performs the
-= operation. Read moreSource§impl<const N: usize> SubAssign for Ad<N>
impl<const N: usize> SubAssign for Ad<N>
Source§fn sub_assign(&mut self, rhs: Ad<N>)
fn sub_assign(&mut self, rhs: Ad<N>)
Performs the
-= operation. Read moreSource§impl<const N: usize> SubsetOf<Ad<N>> for Ad<N>
impl<const N: usize> SubsetOf<Ad<N>> for Ad<N>
Source§fn to_superset(&self) -> Ad<N>
fn to_superset(&self) -> Ad<N>
The inclusion map: converts
self to the equivalent element of its superset.Source§fn from_superset_unchecked(element: &Ad<N>) -> Self
fn from_superset_unchecked(element: &Ad<N>) -> Self
Use with care! Same as
self.to_superset but without any property checks. Always succeeds.Source§fn is_in_subset(element: &Ad<N>) -> bool
fn is_in_subset(element: &Ad<N>) -> bool
Checks if
element is actually part of the subset Self (and can be converted to it).Source§impl<const N: usize> SubsetOf<Ad<N>> for f32
impl<const N: usize> SubsetOf<Ad<N>> for f32
Source§fn to_superset(&self) -> Ad<N>
fn to_superset(&self) -> Ad<N>
The inclusion map: converts
self to the equivalent element of its superset.Source§fn from_superset_unchecked(element: &Ad<N>) -> Self
fn from_superset_unchecked(element: &Ad<N>) -> Self
Use with care! Same as
self.to_superset but without any property checks. Always succeeds.Source§fn is_in_subset(element: &Ad<N>) -> bool
fn is_in_subset(element: &Ad<N>) -> bool
Checks if
element is actually part of the subset Self (and can be converted to it).Source§impl<const N: usize> SubsetOf<Ad<N>> for f64
impl<const N: usize> SubsetOf<Ad<N>> for f64
Source§fn to_superset(&self) -> Ad<N>
fn to_superset(&self) -> Ad<N>
The inclusion map: converts
self to the equivalent element of its superset.Source§fn from_superset_unchecked(element: &Ad<N>) -> Self
fn from_superset_unchecked(element: &Ad<N>) -> Self
Use with care! Same as
self.to_superset but without any property checks. Always succeeds.Source§fn is_in_subset(element: &Ad<N>) -> bool
fn is_in_subset(element: &Ad<N>) -> bool
Checks if
element is actually part of the subset Self (and can be converted to it).Source§impl<const N: usize> UlpsEq for Ad<N>
impl<const N: usize> UlpsEq for Ad<N>
impl<const N: usize> Field for Ad<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for Ad<N>
impl<const N: usize> RefUnwindSafe for Ad<N>
impl<const N: usize> Send for Ad<N>
impl<const N: usize> Sync for Ad<N>
impl<const N: usize> Unpin for Ad<N>
impl<const N: usize> UnwindSafe for Ad<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SimdComplexField for Twhere
T: ComplexField,
impl<T> SimdComplexField for Twhere
T: ComplexField,
Source§type SimdRealField = <T as ComplexField>::RealField
type SimdRealField = <T as ComplexField>::RealField
Type of the coefficients of a complex number.
Source§fn from_simd_real(re: <T as SimdComplexField>::SimdRealField) -> T
fn from_simd_real(re: <T as SimdComplexField>::SimdRealField) -> T
Builds a pure-real complex number from the given value.
Source§fn simd_real(self) -> <T as SimdComplexField>::SimdRealField
fn simd_real(self) -> <T as SimdComplexField>::SimdRealField
The real part of this complex number.
Source§fn simd_imaginary(self) -> <T as SimdComplexField>::SimdRealField
fn simd_imaginary(self) -> <T as SimdComplexField>::SimdRealField
The imaginary part of this complex number.
Source§fn simd_modulus(self) -> <T as SimdComplexField>::SimdRealField
fn simd_modulus(self) -> <T as SimdComplexField>::SimdRealField
The modulus of this complex number.
Source§fn simd_modulus_squared(self) -> <T as SimdComplexField>::SimdRealField
fn simd_modulus_squared(self) -> <T as SimdComplexField>::SimdRealField
The squared modulus of this complex number.
Source§fn simd_argument(self) -> <T as SimdComplexField>::SimdRealField
fn simd_argument(self) -> <T as SimdComplexField>::SimdRealField
The argument of this complex number.
Source§fn simd_norm1(self) -> <T as SimdComplexField>::SimdRealField
fn simd_norm1(self) -> <T as SimdComplexField>::SimdRealField
The sum of the absolute value of this complex number’s real and imaginary part.
Source§fn simd_scale(self, factor: <T as SimdComplexField>::SimdRealField) -> T
fn simd_scale(self, factor: <T as SimdComplexField>::SimdRealField) -> T
Multiplies this complex number by
factor.Source§fn simd_unscale(self, factor: <T as SimdComplexField>::SimdRealField) -> T
fn simd_unscale(self, factor: <T as SimdComplexField>::SimdRealField) -> T
Divides this complex number by
factor.Source§fn simd_to_polar(
self,
) -> (<T as SimdComplexField>::SimdRealField, <T as SimdComplexField>::SimdRealField)
fn simd_to_polar( self, ) -> (<T as SimdComplexField>::SimdRealField, <T as SimdComplexField>::SimdRealField)
The polar form of this complex number: (modulus, arg)
Source§fn simd_to_exp(self) -> (<T as SimdComplexField>::SimdRealField, T)
fn simd_to_exp(self) -> (<T as SimdComplexField>::SimdRealField, T)
The exponential form of this complex number: (modulus, e^{i arg})
Source§fn simd_signum(self) -> T
fn simd_signum(self) -> T
The exponential part of this complex number:
self / self.modulus()fn simd_floor(self) -> T
fn simd_ceil(self) -> T
fn simd_round(self) -> T
fn simd_trunc(self) -> T
fn simd_fract(self) -> T
fn simd_mul_add(self, a: T, b: T) -> T
Source§fn simd_abs(self) -> <T as SimdComplexField>::SimdRealField
fn simd_abs(self) -> <T as SimdComplexField>::SimdRealField
The absolute value of this complex number:
self / self.signum(). Read moreSource§fn simd_hypot(self, other: T) -> <T as SimdComplexField>::SimdRealField
fn simd_hypot(self, other: T) -> <T as SimdComplexField>::SimdRealField
Computes (self.conjugate() * self + other.conjugate() * other).sqrt()
fn simd_recip(self) -> T
fn simd_conjugate(self) -> T
fn simd_sin(self) -> T
fn simd_cos(self) -> T
fn simd_sin_cos(self) -> (T, T)
fn simd_sinh_cosh(self) -> (T, T)
fn simd_tan(self) -> T
fn simd_asin(self) -> T
fn simd_acos(self) -> T
fn simd_atan(self) -> T
fn simd_sinh(self) -> T
fn simd_cosh(self) -> T
fn simd_tanh(self) -> T
fn simd_asinh(self) -> T
fn simd_acosh(self) -> T
fn simd_atanh(self) -> T
fn simd_sinhc(self) -> T
fn simd_coshc(self) -> T
fn simd_log(self, base: <T as SimdComplexField>::SimdRealField) -> T
fn simd_log2(self) -> T
fn simd_log10(self) -> T
fn simd_ln(self) -> T
fn simd_ln_1p(self) -> T
fn simd_sqrt(self) -> T
fn simd_exp(self) -> T
fn simd_exp2(self) -> T
fn simd_exp_m1(self) -> T
fn simd_powi(self, n: i32) -> T
fn simd_powf(self, n: <T as SimdComplexField>::SimdRealField) -> T
fn simd_powc(self, n: T) -> T
fn simd_cbrt(self) -> T
Source§fn simd_horizontal_sum(self) -> <T as SimdValue>::Element
fn simd_horizontal_sum(self) -> <T as SimdValue>::Element
Computes the sum of all the lanes of
self.Source§fn simd_horizontal_product(self) -> <T as SimdValue>::Element
fn simd_horizontal_product(self) -> <T as SimdValue>::Element
Computes the product of all the lanes of
self.Source§impl<T> SimdPartialOrd for T
impl<T> SimdPartialOrd for T
Source§fn simd_ge(self, other: T) -> <T as SimdValue>::SimdBool
fn simd_ge(self, other: T) -> <T as SimdValue>::SimdBool
Lanewise greater or equal
>= comparison.Source§fn simd_le(self, other: T) -> <T as SimdValue>::SimdBool
fn simd_le(self, other: T) -> <T as SimdValue>::SimdBool
Lanewise less or equal
<= comparison.Source§fn simd_clamp(self, min: T, max: T) -> T
fn simd_clamp(self, min: T, max: T) -> T
Clamps each lane of
self between the corresponding lane of min and max.Source§fn simd_horizontal_min(self) -> <T as SimdValue>::Element
fn simd_horizontal_min(self) -> <T as SimdValue>::Element
The min value among all lanes of
self.Source§fn simd_horizontal_max(self) -> <T as SimdValue>::Element
fn simd_horizontal_max(self) -> <T as SimdValue>::Element
The max value among all lanes of
self.Source§impl<T> SimdRealField for Twhere
T: RealField,
impl<T> SimdRealField for Twhere
T: RealField,
fn simd_atan2(self, other: T) -> T
fn simd_default_epsilon() -> T
Source§fn simd_copysign(self, sign: T) -> T
fn simd_copysign(self, sign: T) -> T
fn simd_pi() -> T
fn simd_two_pi() -> T
fn simd_frac_pi_2() -> T
fn simd_frac_pi_3() -> T
fn simd_frac_pi_4() -> T
fn simd_frac_pi_6() -> T
fn simd_frac_pi_8() -> T
fn simd_frac_1_pi() -> T
fn simd_frac_2_pi() -> T
fn simd_frac_2_sqrt_pi() -> T
fn simd_e() -> T
fn simd_log2_e() -> T
fn simd_log10_e() -> T
fn simd_ln_2() -> T
fn simd_ln_10() -> T
Source§impl<T> SimdSigned for T
impl<T> SimdSigned for T
Source§fn simd_abs_sub(&self, other: &T) -> T
fn simd_abs_sub(&self, other: &T) -> T
The absolute difference of each lane of
self. Read moreSource§fn simd_signum(&self) -> T
fn simd_signum(&self) -> T
The signum of each lane of
Self.Source§fn is_simd_positive(&self) -> <T as SimdValue>::SimdBool
fn is_simd_positive(&self) -> <T as SimdValue>::SimdBool
Tests which lane is positive.
Source§fn is_simd_negative(&self) -> <T as SimdValue>::SimdBool
fn is_simd_negative(&self) -> <T as SimdValue>::SimdBool
Tests which lane is negative.
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.