diff -r 962c8e346ab9 -r 4e80fb049dca src/bisection_tree/support.rs --- a/src/bisection_tree/support.rs Sun Apr 27 15:45:40 2025 -0500 +++ b/src/bisection_tree/support.rs Sun Apr 27 15:56:43 2025 -0500 @@ -2,6 +2,7 @@ Traits for representing the support of a [`Mapping`], and analysing the mapping on a [`Cube`]. */ use super::aggregator::Bounds; +pub use crate::bounds::{GlobalAnalysis, LocalAnalysis}; use crate::loc::Loc; use crate::mapping::{DifferentiableImpl, DifferentiableMapping, Instance, Mapping, Space}; use crate::maputil::map2; @@ -52,56 +53,6 @@ } } -/// Trait for globally analysing a property `A` of a [`Mapping`]. -/// -/// Typically `A` is an [`Aggregator`][super::aggregator::Aggregator] such as -/// [`Bounds`][super::aggregator::Bounds]. -pub trait GlobalAnalysis { - /// Perform global analysis of the property `A` of `Self`. - /// - /// As an example, in the case of `A` being [`Bounds`][super::aggregator::Bounds], - /// this function will return global upper and lower bounds for the mapping - /// represented by `self`. - fn global_analysis(&self) -> A; -} - -// default impl GlobalAnalysis for L -// where L : LocalAnalysis { -// #[inline] -// fn global_analysis(&self) -> Bounds { -// self.local_analysis(&self.support_hint()) -// } -// } - -/// Trait for locally analysing a property `A` of a [`Mapping`] (implementing [`Support`]) -/// within a [`Cube`]. -/// -/// Typically `A` is an [`Aggregator`][super::aggregator::Aggregator] such as -/// [`Bounds`][super::aggregator::Bounds]. -pub trait LocalAnalysis: GlobalAnalysis + Support { - /// Perform local analysis of the property `A` of `Self`. - /// - /// As an example, in the case of `A` being [`Bounds`][super::aggregator::Bounds], - /// this function will return upper and lower bounds within `cube` for the mapping - /// represented by `self`. - fn local_analysis(&self, cube: &Cube) -> A; -} - -/// Trait for determining the upper and lower bounds of an float-valued [`Mapping`]. -/// -/// This is a blanket-implemented alias for [`GlobalAnalysis`]`>` -/// [`Mapping`] is not a supertrait to allow flexibility in the implementation of either -/// reference or non-reference arguments. -pub trait Bounded: GlobalAnalysis> { - /// Return lower and upper bounds for the values of of `self`. - #[inline] - fn bounds(&self) -> Bounds { - self.global_analysis() - } -} - -impl>> Bounded for T {} - /// Shift of [`Support`] and [`Mapping`]; output of [`Support::shift`]. #[derive(Copy, Clone, Debug, Serialize)] // Serialize! but not implemented by Loc. pub struct Shift {