[][src]Function autodiff::forward_autodiff::grad

pub fn grad<G>(f: G, x0: &[f64]) -> Vec<f64> where
    G: Fn(&[F1]) -> F1

Evaluates the gradient of f at x0

Examples

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

// Differentiate `f` at `(1,2)`.
let g = grad(f, &vec![1.0, 2.0]);
println!("({}, {})", g[0], g[1]); // prints `(4, 4)`