forked from xiahouzuoxin/fft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
59 lines (46 loc) · 1.08 KB
/
main.c
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
/*
* FileName : main.c
* Author : xiahouzuoxin @163.com
* Version : v1.0
* Date : 2014/4/9 22:27:55
* Brief :
*
* Copyright (C) MICL,USTB
*/
#include "zx_fft.h"
#define SAMPLE_NODES (128)
COMPLEX x[SAMPLE_NODES];
static void MakeInput()
{
int i;
for ( i=0;i<SAMPLE_NODES;i++ )
{
x[i].real = sin(PI*8*i/SAMPLE_NODES);
x[i].imag = 0.0f;
}
}
int main(void)
{
int i = 0;
/* TEST FFT */
MakeInput();
fft(x,SAMPLE_NODES);
for (i=0; i<SAMPLE_NODES; i++) {
printf("%.5f %.5f\n", x[i].real, x[i].imag);
}
ifft(x,SAMPLE_NODES);
for (i=0; i<SAMPLE_NODES; i++) {
printf("%.5f %.5f\n", x[i].real, x[i].imag);
}
/* TEST FFT with REAL INPUTS */
MakeInput();
fft_real(x,SAMPLE_NODES);
for (i=0; i<SAMPLE_NODES; i++) {
printf("%.5f %.5f\n", x[i].real, x[i].imag);
}
ifft_real(x,SAMPLE_NODES);
for (i=0; i<SAMPLE_NODES; i++) {
printf("%.5f %.5f\n", x[i].real, x[i].imag);
}
return 0;
}