Struct num_dual::Dual2Vec [−][src]
pub struct Dual2Vec<T, F, const N: usize> { pub re: T, pub v1: StaticVec<T, N>, pub v2: StaticMat<T, N, N>, // some fields omitted }
Expand description
A second order dual number for the calculation of Hessians.
Fields
re: TReal part of the second order dual number
v1: StaticVec<T, N>Gradient part of the second order dual number
v2: StaticMat<T, N, N>Hessian part of the second order dual number
Implementations
Create a new scalar second order dual number from its fields.
Derive a scalar second order dual number
let xy = StaticVec::new_vec([5.0, 3.0]).map(Dual2Vec64::<2>::from).derive(); let z = xy[0] * xy[1].powi(2); assert_eq!(z.re, 45.0); // xy² assert_eq!(z.v1[0], 9.0); // y² assert_eq!(z.v1[1], 30.0); // 2xy assert_eq!(z.v2[(0,0)], 0.0); // 0 assert_eq!(z.v2[(0,1)], 6.0); // 2y assert_eq!(z.v2[(1,0)], 6.0); // 2y assert_eq!(z.v2[(1,1)], 10.0); // 2x
Trait Implementations
Performs the += operation. Read more
Performs the += operation. Read more
Performs the /= operation. Read more
Performs the /= operation. Read more
Return 1.0 / sqrt(2.0).
Return 2.0 / sqrt(π).
impl<T: DualNum<F>, F: Float + FromPrimitive, const N: usize> FromPrimitive for Dual2Vec<T, F, N>
impl<T: DualNum<F>, F: Float + FromPrimitive, const N: usize> FromPrimitive for Dual2Vec<T, F, N>Converts an isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read more
Converts an i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read more
Converts an i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read more
Converts an i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read more
Converts an i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read more
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 more
Converts a usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read more
Converts an u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read more
Converts an u16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read more
Converts an u32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read more
Converts an u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read more
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 more
Converts a f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read more
Performs the *= operation. Read more
Performs the *= operation. Read more
type FromStrRadixErr = F::FromStrRadixErrConvert from a string and radix (typically 2..=36). Read more
Performs the %= operation. Read more
Performs the %= operation. Read more
Returns true if the number is positive and false if the number is zero or negative.
Returns true if the number is negative and false if the number is zero or positive.
Performs the -= operation. Read more
Performs the -= operation. Read more
Auto Trait Implementations
impl<T, F, const N: usize> RefUnwindSafe for Dual2Vec<T, F, N> where
F: RefUnwindSafe,
T: RefUnwindSafe, impl<T, F, const N: usize> UnwindSafe for Dual2Vec<T, F, N> where
F: UnwindSafe,
T: UnwindSafe, Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T, Rhs> NumAssignOps<Rhs> for T where
T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,