src/bisection_tree/either.rs

branch
dev
changeset 59
9226980e45a7
parent 47
a0db98c16ab5
child 80
f802ddbabcfc
child 86
d5b0e496b72f
equal deleted inserted replaced
58:1a38447a89fa 59:9226980e45a7
1 1
2 use std::iter::Chain; 2 use std::iter::Chain;
3 use std::sync::Arc; 3 use std::sync::Arc;
4 4
5 use crate::types::*; 5 use crate::types::*;
6 use crate::mapping::{Apply, Differentiable}; 6 use crate::mapping::{
7 Instance,
8 Mapping,
9 DifferentiableImpl,
10 DifferentiableMapping,
11 Space,
12 };
7 use crate::iter::{Mappable, MapF, MapZ}; 13 use crate::iter::{Mappable, MapF, MapZ};
8 use crate::sets::Cube; 14 use crate::sets::Cube;
9 use crate::loc::Loc; 15 use crate::loc::Loc;
10 16
11 use super::support::*; 17 use super::support::*;
175 EitherSupport::Right(ref b) => b.global_analysis(), 181 EitherSupport::Right(ref b) => b.global_analysis(),
176 } 182 }
177 } 183 }
178 } 184 }
179 185
180 impl<F, S1, S2, X> Apply<X> for EitherSupport<S1, S2> 186 impl<F, S1, S2, X> Mapping<X> for EitherSupport<S1, S2>
181 where S1 : Apply<X, Output=F>, 187 where
182 S2 : Apply<X, Output=F> { 188 F : Space,
183 type Output = F; 189 X : Space,
184 #[inline] 190 S1 : Mapping<X, Codomain=F>,
185 fn apply(&self, x : X) -> F { 191 S2 : Mapping<X, Codomain=F>,
192 {
193 type Codomain = F;
194
195 #[inline]
196 fn apply<I : Instance<X>>(&self, x : I) -> F {
186 match self { 197 match self {
187 EitherSupport::Left(ref a) => a.apply(x), 198 EitherSupport::Left(ref a) => a.apply(x),
188 EitherSupport::Right(ref b) => b.apply(x), 199 EitherSupport::Right(ref b) => b.apply(x),
189 } 200 }
190 } 201 }
191 } 202 }
192 203
193 impl<F, S1, S2, X> Differentiable<X> for EitherSupport<S1, S2> 204 impl<X, S1, S2, O> DifferentiableImpl<X> for EitherSupport<S1, S2>
194 where S1 : Differentiable<X, Derivative=F>, 205 where
195 S2 : Differentiable<X, Derivative=F> { 206 O : Space,
196 type Derivative = F; 207 X : Space,
197 #[inline] 208 S1 : DifferentiableMapping<X, DerivativeDomain=O>,
198 fn differential(&self, x : X) -> F { 209 S2 : DifferentiableMapping<X, DerivativeDomain=O>,
210 {
211 type Derivative = O;
212
213 #[inline]
214 fn differential_impl<I : Instance<X>>(&self, x : I) -> O {
199 match self { 215 match self {
200 EitherSupport::Left(ref a) => a.differential(x), 216 EitherSupport::Left(ref a) => a.differential(x),
201 EitherSupport::Right(ref b) => b.differential(x), 217 EitherSupport::Right(ref b) => b.differential(x),
202 } 218 }
203 } 219 }

mercurial