Crate hyperdual[−][src]
Expand description
Dual Numbers
Fully-featured Dual Number implementation with features for automatic differentiation of multivariate vectorial functions into gradients.
Usage
extern crate hyperdual; use hyperdual::{Dual, Hyperdual, Float, differentiate}; fn main() { // find partial derivative at x=4.0 let univariate = differentiate(4.0f64, |x| x.sqrt() + Dual::from_real(1.0)); assert!((univariate - 0.25).abs() < 1e-16, "wrong derivative"); // find the partial derivatives of a multivariate function let x: Hyperdual<f64, 3> = Hyperdual::from_slice(&[4.0, 1.0, 0.0]); let y: Hyperdual<f64, 3> = Hyperdual::from_slice(&[5.0, 0.0, 1.0]); let multivariate = x * x + (x * y).sin() + y.powi(3); assert!((multivariate[0] - 141.91294525072763).abs() < 1e-13, "f(4, 5) incorrect"); assert!((multivariate[1] - 10.04041030906696).abs() < 1e-13, "df/dx(4, 5) incorrect"); assert!((multivariate[2] - 76.63232824725357).abs() < 1e-13, "df/dy(4, 5) incorrect"); }
Previous Work
Modules
linalg |
Structs
Const | |
DefaultAllocator | An allocator based on |
Dynamic | Dim of dynamically-sized algebraic entities. |
Hyperdual | Dual Number structure |
Traits
Allocator | A matrix allocator of a memory buffer that may contain |
Dim | Trait implemented by any type that can be used as a dimension. This includes type-level
integers and |
DimAdd | |
DimDiv | |
DimMax | |
DimMin | |
DimMul | |
DimName | Trait implemented exclusively by type-level integers. |
DimNameAdd | |
DimNameDiv | |
DimNameMax | |
DimNameMin | |
DimNameMul | |
DimNameSub | |
DimSub | |
Float | Generic trait for floating point numbers |
FloatConst | |
IsDynamic | Trait implemented by |
IsNotStaticOne | Trait implemented by |
Num | The base trait for numeric types, covering |
One | Defines a multiplicative identity element for |
ToConst | |
ToTypenum | |
Zero | Defines an additive identity element for |
Functions
differentiate | Evaluates the function using dual numbers to get the partial derivative at the input point |
extract_jacobian_and_result | |
hyperspace_from_vector | |
vector_from_hyperspace |