Expand description
Taylor mode forward automatic differentiation
§Important Features
- Can automatic differentiate up to 2nd order (
AD0~AD2) - All
ADare in stack (Guarantee high performance) - You can see
ADvia.print()
§Implemented Traits for AD
#[derive(Debug, Copy, Clone, PartialEq)]std::fmt::DisplayIntoIterator<Item = f64>IntoIterator<Item = &f64>IntoIterator<Item = &mut f64>FromIterator<f64>FromIterator<&f64>Index,IndexMutstd::ops::{Neg, Add, Sub, Mul, Div}peroxide_num::{PowOps, ExpLogOps, TrigOps}peroxide::util::print::Printable
§Iterator of AD
There are three iterators.
ADIntoIterADIter<'a>ADIterMut<'a>
Each implements DoubleEndedIterator, ExactSizeIterator also.
§Default Constructor
AD0(f64): just constantAD1(f64, f64): 1st order ADAD2(f64, f64, f64): 2nd order AD
§Methods
empty(&self) -> ADto_order(&self, n: usize) -> ADiter(&self) -> ADIter{i}iter_mut(&self) -> ADIterMut{i}len(&self) -> usizeorder(&self) -> usizefrom_order(n: usize) -> ADx(&self) -> f64dx(&self) -> f64ddx(&self) -> f64
§Implemented Operations
Add, Sub, Mul, Divsin, cos, tansinh, cosh, tanhsin_cos,sinh_coshexp, ln, log, log2, log10powi, powf, sqrt, powasin,acos,atanasinh,acosh,atanh
§Usage
§Construction
extern crate peroxide;
use peroxide::fuga::*;
fn main() {
// Declare x where x = 2
let a = AD1(2f64, 1f64);
// Declare x^2 where x = 2
let b = AD2(4f64, 4f64, 2f64);
// Convert AD1 -> AD2
let c = a.to_order(2);
// Zeros
let d = AD::from_order(2);
assert_eq!(c, AD2(2f64, 1f64, 0f64));
assert_eq!(d, AD2(0f64, 0f64, 0f64));
}§Operation
For every binary operation, it returns higher order AD (ex: AD1 + AD2 = AD2)
extern crate peroxide;
use peroxide::fuga::*;
fn main() {
let a = AD1(2f64, 1f64); // x at x = 2
let b = AD2(4f64, 4f64, 2f64); // x^2 at x = 2
let c = a + b; // x^2 + x at x = 2
let d = a * b; // x^3 at x = 2
let e = a / b; // 1/x at x = 2
assert_eq!(c, AD2(6f64, 5f64, 2f64));
assert_eq!(d, AD2(8f64, 12f64, 12f64));
assert_eq!(e, AD2(0.5, -0.25, 0.25));
}Structs§
- ADFn
- Generic AD functions
- ADInto
Iter - ADIter
- ADIter
Mut