From f21c09ccf01ed230c1fe7e388a6208432251cbf1 Mon Sep 17 00:00:00 2001 From: Arturs Artamonovs Date: Wed, 11 Aug 2021 07:24:29 +0100 Subject: working dft --- NaiveFFT/main.c | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 185 insertions(+), 1 deletion(-) (limited to 'NaiveFFT') diff --git a/NaiveFFT/main.c b/NaiveFFT/main.c index c43c48b..fec893b 100644 --- a/NaiveFFT/main.c +++ b/NaiveFFT/main.c @@ -6,9 +6,193 @@ // #include +#include +#include +#include +#include +#include + +//data array +#define DATA_SIZE (8) +double data_i[DATA_SIZE] = {1.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f}; +double data_q[DATA_SIZE] = {0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f}; +//calc the fft +void fft_if(double *x_i, double *x_q, int n, int inv) { + + int i=0,j=0,k=0,m=0, irem=0, sign; + double tq,ti; + + printf("FFT\n"); + k=n/2; + for (j=1,i=1;i1) { + irem = irem/2; + m = m+1; + } + + + //FFT or IFFT + if (inv==1) { + sign = 1; + } else { + sign = -1; + } + + // transform + for (i=0; i