Skip to content

Files

Latest commit

 

History

History

peroxide-ad

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Peroxide-ad

Automatic differentiation toolbox for Peroxide

Usage

Modify your Cargo.toml as follows.

[dependencies]
peroxide = "0.30"

Useful macros

  • #[ad_function] macro generates {}_grad, {}_hess from Fn(f64) -> f64 automatically.
    • {}_grad : gradient of function {}
    • {}_hess : hessian of function {}
use peroxide::fuga::*;

fn main() {
    f(2f64).print();        // x^3     = 8
    f_grad(2f64).print();   // 3 * x^2 = 12
    f_hess(2f64).print();   // 6 * x   = 12
}

#[ad_function]              // generates f_grad, f_hess
fn f(x: f64) -> f64 {
    x.powi(3)               // x^3
}