This is FFT program ,i got the error like
1.C2995->'std::complex': use of class template requries template argument list,
2. see the declaration of 'std::complex'...
how to clear this error......
< #include <iostream>
02 #include <complex>
03 #include <cmath>
04 #include <iterator>
05 using namespace std;
06
07 unsigned int bitReverse(unsigned int x, int log2n)
08
09 {
10 int n = 0;
11 int mask = 0x1;
12 for (int i=0; i < log2n; i++)
13
14 {
15 n <<= 1;
16 n |= (x & 1);
17 x >>= 1;
18 }
19 return n;
20 }
21 const double PI = 3.1415926536;
22 template<class Iter_T>
23 void fft(Iter_T a, Iter_T b, int log2n)
24 {
25 typedef typename iterator_traits<iter_t>::value_type complex;
26 const complex J(0, 1);
27 int n = 1 << log2n;
28 for (unsigned int i=0; i < n; ++i) {
29 b[bitReverse(i, log2n)] = a[i];
30 }
31
32 for (int s = 1; s <= log2n; ++s)
33
34 {
35 int m = 1 << s;
36 int m2 = m >> 1;
37 complex w(1, 0);
38 complex wm = exp(-J * (PI / m2));
39 for (int j=0; j < m2; ++j)
40
41 {
42 for (int k=j; k < n; k += m)
43
44 {
45 complex t = w * b[k + m2];
46 complex u = b[k];
47 b[k] = u + t;
48 b[k + m2] = u - t;
49 }
50 w *= wm;
51 }
52 }
53 }
54 int main( )
55
56 {
57 typedef complex cx;
58 cx a[] = { cx(0,0), cx(1,1), cx(3,3), cx(4,4),
59 cx(4, 4), cx(3, 3), cx(1,1), cx(0,0) };
60 cx b[8];
61 fft(a, b, 3);
62 for (int i=0; i<8; ++i)
63 cout << b[i] << "\n";
64
65 }
>
Second, your code contains identifier "complex", but in some contexts it is a typedef an in others resolves to std::complex. That is confusing. The compiler's error messages should state a line-number for each error.