forked from ycshu/110_Fast_Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5_practice.c
More file actions
40 lines (20 loc) · 664 Bytes
/
5_practice.c
File metadata and controls
40 lines (20 loc) · 664 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
#include <stdio.h> // for printf function
#include <stdlib.h> // for memory allocation
#include <time.h> // for time calculation
#include <math.h> // for sine and cosine functions
int main() {
// Declare all the variables
int k, n, N;
double *x, *yr, *yi;
time_t t;
// Input the number N
// Locate the memory for x, yr, yi;
// Initial setting for x, for example, x[k] = k
t = clock();
// yr[n]+i*yi[n] = sum(exp(-i 2 Pi k n / N)*x[k], k=0..N-1), n=0..N-1
// output the results
t = clock() - t;
printf("%d ms for discrete Fourier Transform of %d elements\n", t, N);
// free the memory located by x, yr, yi
return 100;
}