Module autodiff::forward_autodiff[][src]

This module defines forward automatic differentiation. This mode of autodiff is most efficient when computing deriviatives with more inputs than outputs. It is also useful for computing Jacobian products.

Examples

The following exmaple shows how to compute a Jacobian product and evaluate the function at the same time.

use autodiff::*;
// Define a function `f(x,y) = (x*y^2, x/y)`.
let f = |v: &[F1]| vec![v[0] * v[1] * v[1], v[0]/v[1]];

// Compute the Jacobian of `f` at `x = (1,2)` multiplied by a vector `p = (3,4)`.
let xp = vec![
    F1::new(1.0, 3.0),
    F1::new(2.0, 4.0),
];
let jp = f(&xp);
println!("({}, {})", jp[0].value(), jp[1].value()); // prints `(4.0, 0.5)`
println!("({}, {})", jp[0].deriv(), jp[1].deriv()); // prints `(28.0, 0.5)`

Structs

F

A generic forward differentiation Dual number.

Traits

ReduceOrder

A Helper trait to drop the highest order derivative.

Functions

diff

Evaluates the derivative of f at x0

grad

Evaluates the gradient of f at x0

Type Definitions

F1

First order differentiator.

F2

Second order differentiator.

F3

Third order differentiator.