-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_fft.cpp
More file actions
executable file
·59 lines (44 loc) · 991 Bytes
/
test_fft.cpp
File metadata and controls
executable file
·59 lines (44 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "fft.h"
#include <iostream>
const int W = 8, H = 2; // Dimensions du signal 2D
const int N = W * H; // Dimensions du signal 1D
//(i,j) = i+W*j
// Affichage d'un tableau de complexes.
void print(const complex<float> f[], int n) {
for (int i = 0; i < n; i++)
cout << f[i] << " ";
cout << endl;
}
// Initialisation du tableau f de taille n.
void init(complex<float> f[], int n) {
for (int i = 0; i < n; i++)
f[i] = n - i;
}
// Test FFT.
int main() {
complex<float> f[N], g[N];
init(f, N);
print(f, N);
// DFT
for (int i = 0; i < N; i++) {
g[i] = dft(f, N, i);
}
cout << "Résultat de la DFT" << endl;
print(g, N);
cout << "-- 1D --" << endl;
// FFT.
fft(f, N);
print(f, N);
// IFFT.
ifft(f, N);
print(f, N);
cout << "-- 2D --" << endl;
init(f, N);
// FFT.
fft2(f, W, H);
print(f, N);
// IFFT.
ifft2(f, W, H);
print(f, N);
return 0;
}