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
//! Tree interface for single-factor lattices.
//!
//! Port of `ql/methods/lattices/tree.hpp`. In C++ `Tree<T>` is a CRTP base
//! (`tree.hpp:50`) that stores only `columns_`; the node interface
//! (`underlying`/`size`/`descendant`/`probability` plus the `branches`
//! enumeration) is a *documentation* contract (`tree.hpp:34-46`), realised by
//! each derived class rather than by virtuals. Here that contract is a real
//! [`Tree`] trait, so `TreeLattice` (#462) can consume any tree generically.
//!
//! [`Tree::BRANCHES`] is an associated const (`2` binomial, `3` trinomial),
//! mirroring the C++ `enum { branches = N }`. An associated const makes the
//! trait not `dyn`-compatible; consumers take `T: Tree` generically, matching
//! the C++ template `TreeLattice<Impl>`.
use crate;
/// A tree approximating a single-factor diffusion.
///
/// The lattice has [`columns`](Tree::columns) time slices; slice `i` holds
/// [`size(i)`](Tree::size) nodes. Each node has [`BRANCHES`](Tree::BRANCHES)
/// descendants in the next slice, reached through
/// [`descendant`](Tree::descendant) with the transition weights given by
/// [`probability`](Tree::probability).