Expand description
Dual numbers as mathematical basis
Fields
val: f64Ordinary (“real”) component
dual: f64Dual component
Implementations
sourceimpl Dual
impl Dual
Utility
sourcepub fn custom<F, D>(&self, func: &F, deriv: &D) -> Self where
F: FloatFunction,
D: FloatFunction,
pub fn custom<F, D>(&self, func: &F, deriv: &D) -> Self where
F: FloatFunction,
D: FloatFunction,
Apply custom function-derivative pair to a dual number. May be used to extend the provided set of functions
trait OpsExtended{
fn powi(self, n: i32) -> Self;
}
use autodj::*;
impl OpsExtended for Dual {
fn powi(self, n: i32) -> Self {
self.custom(
|x : f64| x.powi(n),//
|x : f64| x.powi(n - 1) * (n as f64)
)
}
}
let x = std::f64::consts::PI;
let n = 2;
let f = x.var().powi(n);sourcepub fn derive<DF>(&self, func: &DF) -> Dual where
DF: DualFunction,
pub fn derive<DF>(&self, func: &DF) -> Dual where
DF: DualFunction,
Apply DualFunction to a dual number
Trait Implementations
sourceimpl PartialEq<Dual> for Dual
impl PartialEq<Dual> for Dual
impl Copy for Dual
impl StructuralPartialEq for Dual
Auto Trait Implementations
impl RefUnwindSafe for Dual
impl Send for Dual
impl Sync for Dual
impl Unpin for Dual
impl UnwindSafe for Dual
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more