-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
49 lines (35 loc) · 1.24 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
#include "dftt.h"
//TODO: Plotting?
//TODO: RadixM?
//TODO: Show sampling frequency in output info and use the new bin flag for outputting the bins
int main (int argc, char** argv) {
double* x; // Input data
FILE * ofile; // Output file pointer
double complex* X; // Fourier Transform result
dftt_config_t dftt_conf; // Tool config
/* Set defaults to ensure certain behaviour */
set_defaults(&dftt_conf);
/* Get the options from the CLI */
CHECK_ERR(get_options(&argc, argv, &dftt_conf));
/* Execute the read input function */
CHECK_ERR(dftt_conf.inp(&x, &dftt_conf));
/* Initialise DFT result array */
X = NULL;
/* Set the array sizes to be used in the DFT */
set_transform_size(&dftt_conf, &X, &x);
/* Start the timer */
check_start_timer(&dftt_conf);
/* DFT */
dftt_conf.dft(X, x, &dftt_conf);
/* Check if timer was activated and output time */
check_end_timer_output(&dftt_conf);
/* Calculate power spectrum if selected */
pow_spec(X, &dftt_conf);
/* Initialise outuput buffer and output the DFT array */
ofile = NULL;
dftt_conf.outp(&ofile, &dftt_conf, X);
fclose(ofile);
free(x);
free(X);
return 0;
}