Struct num_dual::DualVec [−][src]
pub struct DualVec<T, F, const N: usize> { pub re: T, pub eps: StaticVec<T, N>, // some fields omitted }
Expand description
A dual number for the calculations of gradients or Jacobians.
Fields
re: TReal part of the dual number
eps: StaticVec<T, N>Derivative part of the dual number
Implementations
Create a new scalar dual number from its fields.
Trait Implementations
Performs the += operation. Read more
Performs the += operation. Read more
Performs the /= operation. Read more
Performs the /= operation. Read more
Caculates the eigenvalues and eigenvectors of a symmetric matrix
let a = arr2(&[[Dual64::new_scalar(2.0, 1.0), Dual64::new_scalar(2.0, 2.0)], [Dual64::new_scalar(2.0, 2.0), Dual64::new_scalar(5.0, 3.0)]]); let (l, v) = a.eigh(UPLO::Upper).unwrap(); let av = a.dot(&v); assert_abs_diff_eq!(av[(0,0)].re, (l[0]*v[(0,0)]).re, epsilon = 1e-14); assert_abs_diff_eq!(av[(1,0)].re, (l[0]*v[(1,0)]).re, epsilon = 1e-14); assert_abs_diff_eq!(av[(0,1)].re, (l[1]*v[(0,1)]).re, epsilon = 1e-14); assert_abs_diff_eq!(av[(1,1)].re, (l[1]*v[(1,1)]).re, epsilon = 1e-14); assert_abs_diff_eq!(av[(0,0)].eps[0], (l[0]*v[(0,0)]).eps[0], epsilon = 1e-14); assert_abs_diff_eq!(av[(1,0)].eps[0], (l[0]*v[(1,0)]).eps[0], epsilon = 1e-14); assert_abs_diff_eq!(av[(0,1)].eps[0], (l[1]*v[(0,1)]).eps[0], epsilon = 1e-14); assert_abs_diff_eq!(av[(1,1)].eps[0], (l[1]*v[(1,1)]).eps[0], epsilon = 1e-14);
Caculates the eigenvalues and eigenvectors of a symmetric matrix
let a = arr2(&[[DualVec64::new(2.0, StaticVec::new_vec([1.0, 1.0])), DualVec64::new(2.0, StaticVec::new_vec([2.0, 1.0]))], [DualVec64::new(2.0, StaticVec::new_vec([2.0, 1.0])), DualVec64::new(5.0, StaticVec::new_vec([3.0, 1.0]))]]); let (l, v) = a.eigh(UPLO::Upper).unwrap(); let av = a.dot(&v); assert_abs_diff_eq!(av[(0,0)].re, (l[0]*v[(0,0)]).re, epsilon = 1e-14); assert_abs_diff_eq!(av[(1,0)].re, (l[0]*v[(1,0)]).re, epsilon = 1e-14); assert_abs_diff_eq!(av[(0,1)].re, (l[1]*v[(0,1)]).re, epsilon = 1e-14); assert_abs_diff_eq!(av[(1,1)].re, (l[1]*v[(1,1)]).re, epsilon = 1e-14); assert_abs_diff_eq!(av[(0,0)].eps[0], (l[0]*v[(0,0)]).eps[0], epsilon = 1e-14); assert_abs_diff_eq!(av[(1,0)].eps[0], (l[0]*v[(1,0)]).eps[0], epsilon = 1e-14); assert_abs_diff_eq!(av[(0,1)].eps[0], (l[1]*v[(0,1)]).eps[0], epsilon = 1e-14); assert_abs_diff_eq!(av[(1,1)].eps[0], (l[1]*v[(1,1)]).eps[0], epsilon = 1e-14); assert_abs_diff_eq!(av[(0,0)].eps[1], (l[0]*v[(0,0)]).eps[1], epsilon = 1e-14); assert_abs_diff_eq!(av[(1,0)].eps[1], (l[0]*v[(1,0)]).eps[1], epsilon = 1e-14); assert_abs_diff_eq!(av[(0,1)].eps[1], (l[1]*v[(0,1)]).eps[1], epsilon = 1e-14); assert_abs_diff_eq!(av[(1,1)].eps[1], (l[1]*v[(1,1)]).eps[1], epsilon = 1e-14);
Return 1.0 / sqrt(2.0).
Return 2.0 / sqrt(π).
impl<T: DualNum<F>, F: Float + FromPrimitive, const N: usize> FromPrimitive for DualVec<T, F, N>
impl<T: DualNum<F>, F: Float + FromPrimitive, const N: usize> FromPrimitive for DualVec<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.
Solves a system of linear equations A * x = b where A is self, b
is the argument, and x is the successful result.
let a = arr2(&[[Dual64::new_scalar(1.0, 2.0), Dual64::new_scalar(3.0, 4.0)], [Dual64::new_scalar(5.0, 6.0), Dual64::new_scalar(7.0, 8.0)]]); let b = arr1(&[Dual64::new_scalar(10.0, 28.0), Dual64::new_scalar(26.0, 68.0)]); let x = a.solve_into(b).unwrap(); assert_abs_diff_eq!(x[0].re, 1.0, epsilon = 1e-14); assert_abs_diff_eq!(x[0].eps[0], 2.0, epsilon = 1e-14); assert_abs_diff_eq!(x[1].re, 3.0, epsilon = 1e-14); assert_abs_diff_eq!(x[1].eps[0], 4.0, epsilon = 1e-14);
Solves a system of linear equations A * x = b where A is self, b
is the argument, and x is the successful result. Read more
Solves a system of linear equations A * x = b where A is self, b
is the argument, and x is the successful result. Read more
Solves a system of linear equations A * x = b where A is self, b
is the argument, and x is the successful result. Read more
fn solve_recursive_into(
&self,
lu: &LUFactorized<OwnedRepr<f64>>,
b: Array1<D>
) -> Result<Array1<D>>Solves a system of linear equations A * x = b where A is self, b
is the argument, and x is the successful result.
let a = arr2(&[[DualVec64::new(1.0, StaticVec::new_vec([2.0, 1.0])), DualVec64::new(3.0, StaticVec::new_vec([4.0, 1.0]))], [DualVec64::new(5.0, StaticVec::new_vec([6.0, 1.0])), DualVec64::new(7.0, StaticVec::new_vec([8.0, 1.0]))]]); let b = arr1(&[DualVec64::new(10.0, StaticVec::new_vec([28.0, 18.0])), DualVec64::new(26.0, StaticVec::new_vec([68.0, 42.0]))]); let x = a.solve_into(b).unwrap(); assert_abs_diff_eq!(x[0].re, 1.0, epsilon = 1e-14); assert_abs_diff_eq!(x[0].eps[0], 2.0, epsilon = 1e-14); assert_abs_diff_eq!(x[0].eps[1], 2.0, epsilon = 1e-14); assert_abs_diff_eq!(x[1].re, 3.0, epsilon = 1e-14); assert_abs_diff_eq!(x[1].eps[0], 4.0, epsilon = 1e-14); assert_abs_diff_eq!(x[1].eps[1], 4.0, epsilon = 1e-14);
Solves a system of linear equations A * x = b where A is self, b
is the argument, and x is the successful result. Read more
Solves a system of linear equations A * x = b where A is self, b
is the argument, and x is the successful result. Read more
Solves a system of linear equations A * x = b where A is self, b
is the argument, and x is the successful result. Read more
fn solve_recursive_into(
&self,
lu: &LUFactorized<OwnedRepr<f64>>,
b: Array1<D>
) -> Result<Array1<D>>Performs the -= operation. Read more
Performs the -= operation. Read more
Auto Trait Implementations
impl<T, F, const N: usize> RefUnwindSafe for DualVec<T, F, N> where
F: RefUnwindSafe,
T: RefUnwindSafe, impl<T, F, const N: usize> UnwindSafe for DualVec<T, F, N> where
F: UnwindSafe,
T: UnwindSafe, Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> Vimpl<T> LinalgScalar for T where
T: One<Output = T> + Add<T, Output = T> + Sub<T, Output = T> + 'static + Mul<T> + Copy + Div<T, Output = T> + Zero, impl<T, Rhs> NumAssignOps<Rhs> for T where
T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,