8个版本
0.3.0 | 2021年1月25日 |
---|---|
0.2.1 | 2021年1月12日 |
0.1.4 | 2020年8月1日 |
0.1.3 | 2020年7月31日 |
#43 in #numerical
46,965 每月下载量
用于 17 个crate(通过 过氧化物)
42KB
138 行
过氧化物-ad
过氧化物自动微分工具箱
用法
按照以下方式修改您的 Cargo.toml
。
[dependencies]
peroxide = "0.30"
有用的宏
#[ad_function]
宏会从{}
自动生成{}_grad
和{}
_hess。{}_grad
: 函数{}
的梯度{}_hess
: 函数{}
的Hessian矩阵
#[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
}
依赖
~1.5MB
~35K SLoC