1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! `dorset`, a rust implementation of `Stan Math` library.
//! The project is not intended to be an exact port of `Math`,
//! but as a proof of concept to take advantage of some
//! Rust features in automatic differentiation.
//! Hence the crate is meant to be experimental.
//!
//! Below is how to do the problem example in section 2.1 of
//! 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),
//! using `dorset`.
//! ```
//! #[macro_use]
//! extern crate dorset;
//! use dorset::*;
//!
//! fn main() {
//! let y: Real = 1.3;
//! let s = cstack!();
//! let (mu, sigma) = (var!(s, 0.5), var!(s, 1.2));
//! let mut lp = var!(s);
//! lp = &lp - 0.5 * (2.0 * PI).ln();
//! lp = &lp - ln(&sigma);
//! lp = &lp - 0.5 * pow((y - &mu) / &sigma, 2.0);
//! lp.grad();
//! println!("f(mu, sigma) = {0:.6}", lp.val()); // f(mu, sigma) = -1.323482
//! println!("d.f/d.mu = {0:.6}", mu.adj()); // d.f/d.mu = 0.555556
//! println!("d.f/d.sigma = {0:.6}", sigma.adj()); // d.f/d.sigma = -0.462963
//! }
//!
//! ```
extern crate typed_arena;
extern crate float_cmp;
// pub mod macros;
pub use *;
pub use *;
pub use Rc;
pub use RefCell;