--- a/src/bisection_tree/either.rs Sat Dec 14 09:31:27 2024 -0500 +++ b/src/bisection_tree/either.rs Tue Dec 31 08:30:02 2024 -0500 @@ -3,7 +3,13 @@ use std::sync::Arc; use crate::types::*; -use crate::mapping::{Apply, Differentiable}; +use crate::mapping::{ + Instance, + Mapping, + DifferentiableImpl, + DifferentiableMapping, + Space, +}; use crate::iter::{Mappable, MapF, MapZ}; use crate::sets::Cube; use crate::loc::Loc; @@ -177,12 +183,17 @@ } } -impl<F, S1, S2, X> Apply<X> for EitherSupport<S1, S2> -where S1 : Apply<X, Output=F>, - S2 : Apply<X, Output=F> { - type Output = F; +impl<F, S1, S2, X> Mapping<X> for EitherSupport<S1, S2> +where + F : Space, + X : Space, + S1 : Mapping<X, Codomain=F>, + S2 : Mapping<X, Codomain=F>, +{ + type Codomain = F; + #[inline] - fn apply(&self, x : X) -> F { + fn apply<I : Instance<X>>(&self, x : I) -> F { match self { EitherSupport::Left(ref a) => a.apply(x), EitherSupport::Right(ref b) => b.apply(x), @@ -190,12 +201,17 @@ } } -impl<F, S1, S2, X> Differentiable<X> for EitherSupport<S1, S2> -where S1 : Differentiable<X, Derivative=F>, - S2 : Differentiable<X, Derivative=F> { - type Derivative = F; +impl<X, S1, S2, O> DifferentiableImpl<X> for EitherSupport<S1, S2> +where + O : Space, + X : Space, + S1 : DifferentiableMapping<X, DerivativeDomain=O>, + S2 : DifferentiableMapping<X, DerivativeDomain=O>, +{ + type Derivative = O; + #[inline] - fn differential(&self, x : X) -> F { + fn differential_impl<I : Instance<X>>(&self, x : I) -> O { match self { EitherSupport::Left(ref a) => a.differential(x), EitherSupport::Right(ref b) => b.differential(x),