src/fourier.rs

branch
dev
changeset 61
4f468d35fa29
parent 35
b087e3eab191
equal deleted inserted replaced
60:9738b51d90d7 61:4f468d35fa29
1 /*! 1 /*!
2 Fourier transform traits 2 Fourier transform traits
3 */ 3 */
4 4
5 use alg_tools::types::{Num, Float};
6 use alg_tools::mapping::{RealMapping, Mapping, Space};
7 use alg_tools::bisection_tree::Weighted; 5 use alg_tools::bisection_tree::Weighted;
8 use alg_tools::loc::Loc; 6 use alg_tools::loc::Loc;
7 use alg_tools::mapping::{Mapping, RealMapping, Space};
8 use alg_tools::types::{Float, Num};
9 9
10 /// Trait for Fourier transforms. When F is a non-complex number, the transform 10 /// Trait for Fourier transforms. When F is a non-complex number, the transform
11 /// also has to be non-complex, i.e., the function itself symmetric. 11 /// also has to be non-complex, i.e., the function itself symmetric.
12 pub trait Fourier<F : Num> : Mapping<Self::Domain, Codomain=F> { 12 pub trait Fourier<F: Num>: Mapping<Self::Domain, Codomain = F> {
13 type Domain : Space; 13 type Domain: Space;
14 type Transformed : Mapping<Self::Domain, Codomain=F>; 14 type Transformed: Mapping<Self::Domain, Codomain = F>;
15 15
16 fn fourier(&self) -> Self::Transformed; 16 fn fourier(&self) -> Self::Transformed;
17 } 17 }
18 18
19 impl<F : Float, T, const N : usize> Fourier<F> 19 impl<F: Float, T, const N: usize> Fourier<F> for Weighted<T, F>
20 for Weighted<T, F> 20 where
21 where T : Fourier<F, Domain = Loc<F, N>> + RealMapping<F, N> { 21 T: Fourier<F, Domain = Loc<N, F>> + RealMapping<N, F>,
22 {
22 type Domain = T::Domain; 23 type Domain = T::Domain;
23 type Transformed = Weighted<T::Transformed, F>; 24 type Transformed = Weighted<T::Transformed, F>;
24 25
25 #[inline] 26 #[inline]
26 fn fourier(&self) -> Self::Transformed { 27 fn fourier(&self) -> Self::Transformed {
27 Weighted { 28 Weighted {
28 base_fn : self.base_fn.fourier(), 29 base_fn: self.base_fn.fourier(),
29 weight : self.weight 30 weight: self.weight,
30 } 31 }
31 } 32 }
32 } 33 }

mercurial