pub type DualSVec<D, F, const N: usize> = DualVec<D, F, Const<N>>;Aliased Type§
pub struct DualSVec<D, F, const N: usize> {
pub re: D,
pub eps: Derivative<D, F, Const<N>, Const<1>>,
/* private fields */
}Fields§
§re: DReal part of the dual number
eps: Derivative<D, F, Const<N>, Const<1>>Derivative part of the dual number
Implementations§
Source§impl<T: DualNum<F>, F, const N: usize> DualSVec<T, F, N>
impl<T: DualNum<F>, F, const N: usize> DualSVec<T, F, N>
Sourcepub fn derivative(self, index: usize) -> Self
pub fn derivative(self, index: usize) -> Self
Set the derivative part of variable index to 1.
For most cases, the gradient function provides a convenient interface
to calculate derivatives. This function exists for the more edge cases
where more control over the variables is required.
let x: DualSVec64<2> = DualSVec64::from_re(5.0).derivative(0);
let y: DualSVec64<2> = DualSVec64::from_re(3.0).derivative(1);
let z = x * x * y;
assert_eq!(z.re, 75.0); // x²y
assert_eq!(z.eps.unwrap_generic(U2, U1), vector![30.0, 25.0]); // [2xy, x²]