15 #ifndef __gfftalgfreq_h
16 #define __gfftalgfreq_h
34 template<
int_t K,
int_t M,
typename T,
int S,
class W1,
int NIter = 1,
class W = W1>
37 typedef typename TempTypeTrait<T>::Result LocalVType;
38 typedef Compute<typename W::Re,2> WR;
39 typedef Compute<typename W::Im,2> WI;
40 static const int_t M2 = M*2;
41 static const int_t N = K*M;
43 typedef typename GetNextRoot<NIter+1,N,W1,W,2>::Result Wnext;
44 IterateInFreq<K,M,T,S,W1,NIter+1,Wnext> next;
45 DFTk_inp<K,M2,T,S> spec_inp;
50 const LocalVType wr = WR::value();
51 const LocalVType wi = WI::value();
53 spec_inp.apply(&wr, &wi, data + (NIter-1)*2);
60 template<
int_t K,
int_t M,
typename T,
int S,
class W1,
class W>
61 class IterateInFreq<K,M,T,S,W1,M,W>
64 typedef typename TempTypeTrait<T>::Result LocalVType;
65 typedef Compute<typename W::Re,2> WR;
66 typedef Compute<typename W::Im,2> WI;
67 static const int_t M2 = M*2;
68 static const int_t N = K*M;
69 DFTk_inp<K,M2,T,S> spec_inp;
76 const LocalVType wr = WR::value();
77 const LocalVType wi = WI::value();
79 spec_inp.apply(&wr, &wi, data + (M-1)*2);
84 template<
int_t K,
int_t M,
typename T,
int S,
class W1,
class W>
85 class IterateInFreq<K,M,T,S,W1,1,W> {
86 static const int_t M2 = M*2;
87 DFTk_inp<K,M2,T,S> spec_inp;
88 IterateInFreq<K,M,T,S,W1,2,W> next;
98 template<
int_t K,
int_t M,
typename T,
int S,
class W,
bool doStaticLoop>
101 template<
int_t K,
int_t M,
typename T,
int S,
class W>
102 class T_DFTk_x_Im<K,M,T,S,W,true>
104 IterateInFreq<K,M,T,S,W> iterate;
112 template<
int_t K,
int_t M,
typename T,
int S,
class W>
113 class T_DFTk_x_Im<K,M,T,S,W,false>
115 typedef typename TempTypeTrait<T>::Result LocalVType;
116 static const int_t N = K*M;
117 static const int_t M2 = M*2;
118 DFTk_inp<K,M2,T,S> spec_inp;
122 spec_inp.apply(data);
124 LocalVType wr[K-1], wi[K-1], wpr[K-1], wpi[K-1], t;
128 wpr[0] = 1 - 2.0*t*t;
132 for (int_t i=0; i<K-2; ++i) {
133 wpr[i+1] = wpr[i]*wpr[0] - wpi[i]*wpi[0];
134 wpi[i+1] = wpr[i]*wpi[0] + wpr[0]*wpi[i];
137 for (int_t i=0; i<K-1; ++i) {
142 for (int_t i=2; i<M2; i+=2) {
143 spec_inp.apply(wr, wi, data+i);
145 for (int_t i=0; i<K-1; ++i) {
147 wr[i] = t*wpr[i] - wi[i]*wpi[i];
148 wi[i] = wi[i]*wpr[i] + t*wpi[i];
154 template<
int_t M,
typename T,
int S,
class W>
155 class T_DFTk_x_Im<3,M,T,S,W,false> {
156 typedef typename TempTypeTrait<T>::Result LocalVType;
157 static const int_t N = 3*M;
158 static const int_t M2 = M*2;
159 DFTk_inp<3,M2,T,S> spec_inp;
163 spec_inp.apply(data);
165 LocalVType wr[2],wi[2],t;
169 const LocalVType wpr1 = 1 - 2.0*t*t;
173 const LocalVType wpr2 = wpr1*wpr1 - wpi1*wpi1;
174 const LocalVType wpi2 = 2*wpr1*wpi1;
180 for (int_t i=2; i<M2; i+=2) {
181 spec_inp.apply(wr, wi, data+i);
184 wr[0] = t*wpr1 - wi[0]*wpi1;
185 wi[0] = wi[0]*wpr1 + t*wpi1;
187 wr[1] = t*wpr2 - wi[1]*wpi2;
188 wi[1] = wi[1]*wpr2 + t*wpi2;
193 template<
int_t M,
typename T,
int S,
class W>
194 class T_DFTk_x_Im<2,M,T,S,W,false>
196 typedef typename TempTypeTrait<T>::Result LocalVType;
197 static const int_t N = 2*M;
198 DFTk_inp<2,N,T,S> spec_inp;
205 spec_inp.apply(data);
209 const LocalVType wpr = -2.0*t*t;
213 for (int_t i=2; i<N; i+=2) {
215 spec_inp.apply(&wr, &wi, data+i);
218 wr += t*wpr - wi*wpi;
219 wi += wi*wpr + t*wpi;
362 template<
int_t N,
typename NFact,
typename T,
int S,
class W1,
int_t LastK = 1>
372 template<
int_t N,
typename Head,
typename T,
int S,
class W1,
int_t LastK>
373 class InFreq<N, Loki::Typelist<Head,Loki::NullType>, T, S, W1, LastK>
375 typedef typename TempTypeTrait<T>::Result LocalVType;
376 static const int_t K = Head::first::value;
377 static const int_t M = N/K;
378 static const int_t M2 = M*2;
379 static const int_t N2 = N*2;
380 static const int_t LastK2 = LastK*2;
383 typedef typename IPowBig<W1,K>::Result WK;
384 typedef Loki::Typelist<Pair<
typename Head::first,
SInt<Head::second::value-1> >, Loki::NullType> NFactNext;
386 T_DFTk_x_Im<K,M,T,S,W1,(N<=StaticLoopLimit)> dft_scaled;
391 dft_scaled.apply(data);
394 for (int_t m = 0; m < N2; m+=M2)
395 dft_str.apply(data + m);
401 template<
int_t N,
int_t K,
typename Tail,
typename T,
int S,
class W1,
int_t LastK>
402 class InFreq<N, Loki::Typelist<Pair<SInt<K>, SInt<0> >,Tail>, T, S, W1, LastK>
403 :
public InFreq<N, Tail, T, S, W1, LastK> {};
407 template<
int_t N,
typename T,
int S,
class W1,
int_t LastK>
408 class InFreq<N, Loki::Typelist<Pair<SInt<N>, SInt<1> >, Loki::NullType>,T,S,W1,LastK> {
409 DFTk_inp<N, 2, T, S> spec_inp;
413 spec_inp.apply(data);