Skip to content

Flarp/oprec

Repository files navigation

OpRec

A giant work in progress crate that can transform functions. It is planned to support inverses (solving for variables), derivatives using operator overloading. It can be only used in the latest Rust nightly due to rust-lang/rust#44851.

extern crate oprec;
use oprec::*;
use std::f64::consts::PI;

fn main() {
  // sin(4x)
  let mut rec = OpRec::new();
  rec *= 4;
  rec = rec.sin();
  let id = rec.id();
  // 4cos(4x)
  let cos_4 = |x: f64| 4.0*((4.0*x).cos());
  let func = rec.differentiate().functify();
  let mut map = HashMap::new();
  map.insert(id, PI);
  
  assert_eq!(cos_4(PI), func(map).ok().unwrap());
}

There is currently no documentation due to docs.rs not using the latest nightly.

About

Symbolic computation with automatic differentiation using operator overloading

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages