4 |
4 |
5 use numeric_literals::replace_float_literals; |
5 use numeric_literals::replace_float_literals; |
6 use std::marker::PhantomData; |
6 use std::marker::PhantomData; |
7 use serde::Serialize; |
7 use serde::Serialize; |
8 use crate::types::*; |
8 use crate::types::*; |
9 pub use crate::mapping::{Mapping, Space, Composition}; |
9 pub use crate::mapping::{Mapping, Space, Composition, ArithmeticTrue}; |
10 use crate::direct_product::Pair; |
10 use crate::direct_product::Pair; |
11 use crate::instance::Instance; |
11 use crate::instance::Instance; |
12 use crate::norms::{NormExponent, PairNorm, L1, L2, Linfinity, Norm}; |
12 use crate::norms::{NormExponent, PairNorm, L1, L2, Linfinity, Norm}; |
13 |
13 |
14 /// Trait for linear operators on `X`. |
14 /// Trait for linear operators on `X`. |
202 } |
203 } |
203 } |
204 } |
204 |
205 |
205 impl<'a, F : Num, X : Space, XD, Y : AXPY<F> + Clone> Mapping<X> for ZeroOp<'a, X, XD, Y, F> { |
206 impl<'a, F : Num, X : Space, XD, Y : AXPY<F> + Clone> Mapping<X> for ZeroOp<'a, X, XD, Y, F> { |
206 type Codomain = Y; |
207 type Codomain = Y; |
|
208 type ArithmeticOptIn = ArithmeticTrue; |
207 |
209 |
208 fn apply<I : Instance<X>>(&self, _x : I) -> Y { |
210 fn apply<I : Instance<X>>(&self, _x : I) -> Y { |
209 self.zero.clone() |
211 self.zero.clone() |
210 } |
212 } |
211 } |
213 } |
333 S::Codomain : Add<T::Codomain>, |
335 S::Codomain : Add<T::Codomain>, |
334 <S::Codomain as Add<T::Codomain>>::Output : Space, |
336 <S::Codomain as Add<T::Codomain>>::Output : Space, |
335 |
337 |
336 { |
338 { |
337 type Codomain = <S::Codomain as Add<T::Codomain>>::Output; |
339 type Codomain = <S::Codomain as Add<T::Codomain>>::Output; |
|
340 type ArithmeticOptIn = ArithmeticTrue; |
338 |
341 |
339 fn apply<I : Instance<Pair<A, B>>>(&self, x : I) -> Self::Codomain { |
342 fn apply<I : Instance<Pair<A, B>>>(&self, x : I) -> Self::Codomain { |
340 let Pair(a, b) = x.decompose(); |
343 let Pair(a, b) = x.decompose(); |
341 self.0.apply(a) + self.1.apply(b) |
344 self.0.apply(a) + self.1.apply(b) |
342 } |
345 } |
390 A : Space, |
393 A : Space, |
391 S : Mapping<A>, |
394 S : Mapping<A>, |
392 T : Mapping<A>, |
395 T : Mapping<A>, |
393 { |
396 { |
394 type Codomain = Pair<S::Codomain, T::Codomain>; |
397 type Codomain = Pair<S::Codomain, T::Codomain>; |
|
398 type ArithmeticOptIn = ArithmeticTrue; |
395 |
399 |
396 fn apply<I : Instance<A>>(&self, a : I) -> Self::Codomain { |
400 fn apply<I : Instance<A>>(&self, a : I) -> Self::Codomain { |
397 Pair(self.0.apply(a.ref_instance()), self.1.apply(a)) |
401 Pair(self.0.apply(a.ref_instance()), self.1.apply(a)) |
398 } |
402 } |
399 } |
403 } |
525 B : Space, |
529 B : Space, |
526 S : Mapping<A>, |
530 S : Mapping<A>, |
527 T : Mapping<B>, |
531 T : Mapping<B>, |
528 { |
532 { |
529 type Codomain = Pair<S::Codomain, T::Codomain>; |
533 type Codomain = Pair<S::Codomain, T::Codomain>; |
|
534 type ArithmeticOptIn = ArithmeticTrue; |
530 |
535 |
531 fn apply<I : Instance<Pair<A, B>>>(&self, x : I) -> Self::Codomain { |
536 fn apply<I : Instance<Pair<A, B>>>(&self, x : I) -> Self::Codomain { |
532 let Pair(a, b) = x.decompose(); |
537 let Pair(a, b) = x.decompose(); |
533 Pair(self.0.apply(a), self.1.apply(b)) |
538 Pair(self.0.apply(a), self.1.apply(b)) |
534 } |
539 } |