| Crates.io | peroxide-ad |
| lib.rs | peroxide-ad |
| version | 0.3.0 |
| created_at | 2020-07-15 05:12:35.521869+00 |
| updated_at | 2021-01-25 15:48:11.451481+00 |
| description | Proc macro for automatic differenitation of Peroxide |
| homepage | |
| repository | https://github.com/Axect/Peroxide |
| max_upload_size | |
| id | 265333 |
| size | 41,567 |
Automatic differentiation toolbox for Peroxide
Modify your Cargo.toml as follows.
[dependencies]
peroxide = "0.30"
#[ad_function] macro generates {}_grad, {}_hess from Fn(f64) -> f64 automatically.
{}_grad : gradient of function {}{}_hess : hessian of function {}#[macro_use]
extern crate peroxide;
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
}