dxpr
Differentiable expression templates in Rust.
Examples
At runtime:
use ;
let x = 4;
let a = var;
let expression = -a;
let value = expression.eval;
assert_eq!;
At compile time:
use ;
const X: i32 = 4;
const A: = var;
const EXPRESSION: = -A;
const VALUE: i32 = EXPRESSION.eval;
assert_eq!;
Automatic differentiation:
use ;
let a = 4;
let b = 4;
let ga = .grad;
let gb = .grad;
assert_eq!;
assert_eq!;
We can reuse an expression without copying (e.g. for machine learning) by calling eval on a reference:
use ;
let x = 4;
let expression = -var;
assert_eq!;
assert_eq!;
assert_eq!;
// still movable the last time:
assert_eq!;
// can't use it again: ------ `expression` moved due to this method call
// /* bad! */ assert_eq!(-4, expression.eval());
// ^^^^^^^^^^ value used here after move
To do:
- Differentiation on arbitrary expressions
IndexandRangeBoundoperators (i.e.a[b]anda..b)