forked from rbino/rtos2013
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testFFT.cpp
36 lines (31 loc) · 806 Bytes
/
testFFT.cpp
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
#include <cstdio>
#include <complex>
/*
#include "miosix.h"
#include "miosix/kernel/buffer_queue.h"
#include "miosix/kernel/scheduler/scheduler.h"
#include "util/software_i2c.h"
*/
#include "FFT.cpp"
#define L 16 //lunghezza del segnale (campioni)
int main(){
double d = 1.0/L; //passo di campionamento dummy
complex<double> s[L]; //segnale sinusoidale di lunghezza L
for(int i = 0 ; i < L; i++){
s[i] = polar( 1.*( i % 2 ) * ( (i % 4) - 2 ),0.);
}
FFT(s, L, d);
/*for(int i=0; i<L; i++){
double asd = abs(s[i]);
while(asd>=1){
printf("|");
asd /= 2;
}
printf("\n");
}*/
for(int i = 0; i < L; i++){
double asd = abs(s[i]);
printf("%d : %d", i, asd );
printf("\n");
}
}