diff -r d14c877e14b7 -r b3c35d16affe src/bisection_tree/either.rs --- a/src/bisection_tree/either.rs Tue Feb 20 12:33:16 2024 -0500 +++ b/src/bisection_tree/either.rs Mon Feb 03 19:22:16 2025 -0500 @@ -3,8 +3,14 @@ use std::sync::Arc; use crate::types::*; -use crate::mapping::Apply; -use crate::iter::{Mappable,MapF,MapZ}; +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 Apply for EitherSupport -where S1 : Apply, - S2 : Apply { - type Output = F; +impl Mapping for EitherSupport +where + F : Space, + X : Space, + S1 : Mapping, + S2 : Mapping, +{ + type Codomain = F; + #[inline] - fn apply(&self, x : X) -> F { + fn apply>(&self, x : I) -> F { match self { EitherSupport::Left(ref a) => a.apply(x), EitherSupport::Right(ref b) => b.apply(x), @@ -190,6 +201,24 @@ } } +impl DifferentiableImpl for EitherSupport +where + O : Space, + X : Space, + S1 : DifferentiableMapping, + S2 : DifferentiableMapping, +{ + type Derivative = O; + + #[inline] + fn differential_impl>(&self, x : I) -> O { + match self { + EitherSupport::Left(ref a) => a.differential(x), + EitherSupport::Right(ref b) => b.differential(x), + } + } +} + macro_rules! make_either_scalarop_rhs { ($trait:ident, $fn:ident, $trait_assign:ident, $fn_assign:ident) => { impl