41 } |
41 } |
42 |
42 |
43 /// Node of a [`BT`] bisection tree. |
43 /// Node of a [`BT`] bisection tree. |
44 /// |
44 /// |
45 /// For the type and const parameteres, see the [module level documentation][super]. |
45 /// For the type and const parameteres, see the [module level documentation][super]. |
46 #[derive(Clone, Debug)] |
46 #[derive(Clone, Debug, Serialize, Deserialize)] |
|
47 #[serde(bound( |
|
48 serialize = "NodeOption<F, D, A, N, P> : Serialize, |
|
49 A : Serialize,", |
|
50 deserialize = "NodeOption<F, D, A, N, P> : for<'a> Deserialize<'a>, |
|
51 A : for<'a> Deserialize<'a>," |
|
52 ))] |
47 pub struct Node<F : Num, D, A : Aggregator, const N : usize, const P : usize> { |
53 pub struct Node<F : Num, D, A : Aggregator, const N : usize, const P : usize> { |
48 /// The data or branches under the node. |
54 /// The data or branches under the node. |
49 pub(super) data : NodeOption<F, D, A, N, P>, |
55 pub(super) data : NodeOption<F, D, A, N, P>, |
50 /// Aggregator for `data`. |
56 /// Aggregator for `data`. |
51 pub(super) aggregator : A, |
57 pub(super) aggregator : A, |
52 } |
58 } |
53 |
59 |
54 /// Branching information of a [`Node`] of a [`BT`] bisection tree into `P` subnodes. |
60 /// Branching information of a [`Node`] of a [`BT`] bisection tree into `P` subnodes. |
55 /// |
61 /// |
56 /// For the type and const parameters, see the [module level documentation][super]. |
62 /// For the type and const parameters, see the [module level documentation][super]. |
57 #[derive(Clone, Debug)] |
63 #[derive(Clone, Debug, Serialize, Deserialize)] |
|
64 #[serde(bound( |
|
65 serialize = "[Node<F, D, A, N, P>; P] : Serialize, |
|
66 Loc<F, N> : Serialize,", |
|
67 deserialize = "[Node<F, D, A, N, P>; P] : for<'a> Deserialize<'a>, |
|
68 Loc<F, N> : for<'a> Deserialize<'a>," |
|
69 ))] |
58 pub(super) struct Branches<F : Num, D, A : Aggregator, const N : usize, const P : usize> { |
70 pub(super) struct Branches<F : Num, D, A : Aggregator, const N : usize, const P : usize> { |
59 /// Point for subdivision of the (unstored) [`Cube`] corresponding to the node. |
71 /// Point for subdivision of the (unstored) [`Cube`] corresponding to the node. |
60 pub(super) branch_at : Loc<F, N>, |
72 pub(super) branch_at : Loc<F, N>, |
61 /// Subnodes |
73 /// Subnodes |
62 pub(super) nodes : [Node<F, D, A, N, P>; P], |
74 pub(super) nodes : [Node<F, D, A, N, P>; P], |
196 &self.nodes[self.get_node_index(x)] |
208 &self.nodes[self.get_node_index(x)] |
197 } |
209 } |
198 } |
210 } |
199 |
211 |
200 /// An iterator over the $P=2^N$ subcubes of a [`Cube`] subdivided at a point `d`. |
212 /// An iterator over the $P=2^N$ subcubes of a [`Cube`] subdivided at a point `d`. |
|
213 #[derive(Debug, Clone)] |
201 pub(super) struct SubcubeIter<'b, F : Float, const N : usize, const P : usize> { |
214 pub(super) struct SubcubeIter<'b, F : Float, const N : usize, const P : usize> { |
202 domain : &'b Cube<F, N>, |
215 domain : &'b Cube<F, N>, |
203 branch_at : Loc<F, N>, |
216 branch_at : Loc<F, N>, |
204 index : usize, |
217 index : usize, |
205 } |
218 } |
635 /// The main bisection tree structure. |
648 /// The main bisection tree structure. |
636 /// |
649 /// |
637 /// It should be accessed via the [`BTImpl`] trait to hide the `const P : usize` parameter until |
650 /// It should be accessed via the [`BTImpl`] trait to hide the `const P : usize` parameter until |
638 /// const generics are flexible enough to fix `P=pow(2, N)` and thus also get rid of |
651 /// const generics are flexible enough to fix `P=pow(2, N)` and thus also get rid of |
639 /// the `BTNodeLookup : BTNode<F, D, A, N>` trait bound. |
652 /// the `BTNodeLookup : BTNode<F, D, A, N>` trait bound. |
640 #[derive(Clone,Debug)] |
653 #[derive(Clone,Debug,Serialize,Deserialize)] |
|
654 #[serde(bound( |
|
655 serialize = "Cube<F, N> : Serialize, |
|
656 M : Serialize, |
|
657 <BTNodeLookup as BTNode<F, D, A, N>>::Node : Serialize,", |
|
658 deserialize = "Cube<F, N> : for<'a> Deserialize<'a>, |
|
659 M : for<'a> Deserialize<'a>, |
|
660 <BTNodeLookup as BTNode<F, D, A, N>>::Node : for<'a> Deserialize<'a>," |
|
661 ))] |
641 pub struct BT< |
662 pub struct BT< |
642 M : Depth, |
663 M : Depth, |
643 F : Float, |
664 F : Float, |
644 D : 'static + Copy, |
665 D : 'static + Copy, |
645 A : Aggregator, |
666 A : Aggregator, |