dorset/
lib.rs

1//! `dorset`, a rust implementation of `Stan Math` library.
2//!  The project is not intended to be an exact port of `Math`,
3//!  but as a proof of concept to take advantage of some
4//!  Rust features in automatic differentiation.
5//!  Hence the crate is meant to be experimental.
6//!
7//! Below is how to do the problem example in section 2.1 of
8//! the Stan Math paper(Bob Carpenter, Matthew D. Hoffman, Marcus Brubaker, Daniel Lee, Peter Li, and Michael J. Betancourt. 2015. The Stan Math Library: Reverse-Mode Automatic Differentiation in C++. arXiv 1509.07164),
9//! using `dorset`.
10//! ```
11//! #[macro_use]
12//! extern crate dorset;
13//! use dorset::*;
14//!
15//! fn main() {
16//!     let y: Real = 1.3;
17//!     let s = cstack!();
18//!     let (mu, sigma) = (var!(s, 0.5), var!(s, 1.2));
19//!     let mut lp = var!(s);
20//!     lp = &lp - 0.5 * (2.0 * PI).ln();
21//!     lp = &lp - ln(&sigma);
22//!     lp = &lp - 0.5 * pow((y - &mu) / &sigma, 2.0);
23//!     lp.grad();
24//!     println!("f(mu, sigma) = {0:.6}", lp.val()); // f(mu, sigma) = -1.323482
25//!     println!("d.f/d.mu = {0:.6}", mu.adj());     // d.f/d.mu = 0.555556
26//!     println!("d.f/d.sigma = {0:.6}", sigma.adj()); // d.f/d.sigma = -0.462963
27//! }
28//!
29//! ```
30
31extern crate typed_arena;
32
33extern crate float_cmp;
34
35
36
37
38
39#[allow(unused_macros)]
40#[macro_use]
41pub mod macros;
42// pub mod macros;
43
44#[macro_use]
45pub mod core;
46pub use core::*;
47
48#[allow(unused_imports)]
49#[macro_use]
50pub mod operations;
51pub use operations::*;
52
53pub use std::rc::Rc;
54pub use std::cell::RefCell;