diff -r edb95d2b83cc -r d2acaaddd9af src/bisection_tree/bt.rs --- a/src/bisection_tree/bt.rs Sun Nov 10 09:02:57 2024 -0500 +++ b/src/bisection_tree/bt.rs Tue Dec 31 09:12:43 2024 -0500 @@ -243,10 +243,11 @@ /// Creates a new node branching structure, subdividing `domain` based on the /// [hint][Support::support_hint] of `support`. - pub(super) fn new_with>( + pub(super) fn new_with( domain : &Cube, support : &S - ) -> Self { + ) -> Self + where S : Support + LocalAnalysis> { let hint = support.bisection_hint(domain); let branch_at = map2(&hint, domain, |h, r| { h.unwrap_or_else(|| (r[0]+r[1])/F::TWO).max(r[0]).min(r[1]) @@ -321,14 +322,15 @@ /// * `support` is the [`Support`] that is used determine with which subcubes of `domain` /// (at subdivision depth `new_leaf_depth`) the data `d` is to be associated with. /// - pub(super) fn insert<'refs, 'scope, M : Depth, S : LocalAnalysis>( + pub(super) fn insert<'refs, 'scope, M : Depth, S>( &mut self, domain : &Cube, d : D, new_leaf_depth : M, support : &S, task_budget : TaskBudget<'scope, 'refs>, - ) { + ) + where S : Support + LocalAnalysis> { let support_hint = support.support_hint(); self.recurse(domain, task_budget, |_, subcube| support_hint.intersects(&subcube), @@ -348,8 +350,8 @@ domain : &Cube ) -> Branches where ANew : Aggregator, - G : SupportGenerator, - G::SupportType : LocalAnalysis { + G : SupportGenerator, + G::SupportType : LocalAnalysis> { let branch_at = self.branch_at; let subcube_iter = self.iter_subcubes(domain); let new_nodes = self.nodes.into_iter().zip(subcube_iter).map(|(node, subcube)| { @@ -370,8 +372,8 @@ generator : &G, domain : &Cube, task_budget : TaskBudget<'scope, 'refs>, - ) where G : SupportGenerator, - G::SupportType : LocalAnalysis { + ) where G : SupportGenerator, + G::SupportType : LocalAnalysis> { self.recurse(domain, task_budget, |_, _| true, move |node, subcube, new_budget| node.refresh_aggregator(generator, subcube, @@ -434,14 +436,15 @@ /// If `self` is a [`NodeOption::Branches`], the data is passed to branches whose subcubes /// `support` intersects. If an [`NodeOption::Uninitialised`] node is encountered, a new leaf is /// created at a minimum depth of `new_leaf_depth`. - pub(super) fn insert<'refs, 'scope, M : Depth, S : LocalAnalysis >( + pub(super) fn insert<'refs, 'scope, M : Depth, S>( &mut self, domain : &Cube, d : D, new_leaf_depth : M, support : &S, task_budget : TaskBudget<'scope, 'refs>, - ) { + ) + where S : Support + LocalAnalysis> { match &mut self.data { NodeOption::Uninitialised => { // Replace uninitialised node with a leaf or a branch @@ -493,8 +496,8 @@ domain : &Cube ) -> Node where ANew : Aggregator, - G : SupportGenerator, - G::SupportType : LocalAnalysis { + G : SupportGenerator, + G::SupportType : LocalAnalysis> { // The mem::replace is needed due to the [`Drop`] implementation to extract self.data. match std::mem::replace(&mut self.data, NodeOption::Uninitialised) { @@ -537,8 +540,8 @@ generator : &G, domain : &Cube, task_budget : TaskBudget<'scope, 'refs>, - ) where G : SupportGenerator, - G::SupportType : LocalAnalysis { + ) where G : SupportGenerator, + G::SupportType : LocalAnalysis> { match &mut self.data { NodeOption::Uninitialised => { }, NodeOption::Leaf(v) => { @@ -580,7 +583,7 @@ /// Basic interface to a [`BT`] bisection tree. /// /// Further routines are provided by the [`BTSearch`][super::refine::BTSearch] trait. -pub trait BTImpl : std::fmt::Debug + Clone + GlobalAnalysis { +pub trait BTImpl : std::fmt::Debug + Clone + GlobalAnalysis { /// The data type stored in the tree type Data : 'static + Copy + Send + Sync; /// The depth type of the tree @@ -595,11 +598,12 @@ /// /// Every leaf node of the tree that intersects the `support` will contain a copy of /// `d`. - fn insert>( + fn insert( &mut self, d : Self::Data, support : &S - ); + ) + where S: Support + LocalAnalysis>; /// Construct a new instance of the tree for a different aggregator /// @@ -608,8 +612,8 @@ fn convert_aggregator(self, generator : &G) -> Self::Converted where ANew : Aggregator, - G : SupportGenerator, - G::SupportType : LocalAnalysis; + G : SupportGenerator< N, Id=Self::Data, RealField = F>, + G::SupportType : LocalAnalysis>; /// Refreshes the aggregator of the three after possible changes to the support generator. @@ -617,8 +621,8 @@ /// The `generator` is used to convert the data of type [`Self::Data`] contained in the tree /// into corresponding [`Support`]s. fn refresh_aggregator(&mut self, generator : &G) - where G : SupportGenerator, - G::SupportType : LocalAnalysis; + where G : SupportGenerator, + G::SupportType : LocalAnalysis>; /// Returns an iterator over all [`Self::Data`] items at the point `x` of the domain. fn iter_at(&self, x : &Loc) -> std::slice::Iter<'_, Self::Data>; @@ -672,11 +676,12 @@ type Agg = A; type Converted = BT where ANew : Aggregator; - fn insert>( + fn insert( &mut self, d : D, support : &S - ) { + ) + where S : Support<$n, RealField = F> + LocalAnalysis> { with_task_budget(|task_budget| self.topnode.insert( &self.domain, @@ -690,8 +695,8 @@ fn convert_aggregator(self, generator : &G) -> Self::Converted where ANew : Aggregator, - G : SupportGenerator, - G::SupportType : LocalAnalysis { + G : SupportGenerator<$n, Id=D, RealField = F>, + G::SupportType : LocalAnalysis> { let topnode = self.topnode.convert_aggregator(generator, &self.domain); BT { @@ -702,8 +707,8 @@ } fn refresh_aggregator(&mut self, generator : &G) - where G : SupportGenerator, - G::SupportType : LocalAnalysis { + where G : SupportGenerator<$n, Id=Self::Data, RealField = F>, + G::SupportType : LocalAnalysis> { with_task_budget(|task_budget| self.topnode.refresh_aggregator(generator, &self.domain, task_budget) ) @@ -726,7 +731,7 @@ } } - impl GlobalAnalysis for BT + impl GlobalAnalysis for BT where M : Depth, F : Float, D : 'static + Copy + Send + Sync + std::fmt::Debug,