So I have a periodic series and I need to get the highest number of that series without the first harmonic.
The series is of size 360
So I have
f(0)=value1
f(1)=value2
...
f(359)=value360
Someone suggested that to do this I must get the 360-point discrete fourier transform DFT (f(0), f(1)... f(359)) --> (F(0), F(1)... F(359)) then set F(0) and F(359) to 0 which will remove the first harmonic. After this I should do the 360-point inverse discrete fourier transform iDFT and then search for the highest value among the result.
To do this I'm using the fft libraries in c but I'm having some trouble trying to figure it out how to use them properly to do this. My periodic series is made up of real numbers not complex so I do this:
#include "complex.h"
#include "fftw.h"
#include "rfftw.h"
...
fftw_real in_r[360]; //input 1d array of real numbers
fftw_complex out_c[360]; //output 1d array of complex numbers
rfftwnd_plan p_DFT; //plan to calculate the DFT
rfftwnd_plan p_iDFT; //plan to calculate the iDFT
p_DFT = rfftwnd_create_plan(1, 360, FFTW_REAL_TO_COMPLEX, FFTW_MEASURE);
p_iDFT = rfftwnd_create_plan(1, 360, FFTW_COMPLEX_TO_REAL, FFTW_MEASURE);
rffftwnd_one_real_to_complex(p_DFT,in_r,out_c);
//I GET AN ERROR IN BOTH THIS CALLS: incompatible types when assigning to type
//‘fftw_complex’ from type ‘complex double’
out_c[0]=0.0 + 0.0*_Complex_I;
out_c[359]=0.0 + 0.0*_Complex_I;
rfftwnd_one_complex_to_real(p_iDFT,out_c,in_r);
for(i=0;i<360;i++)
max=fmaxf(in_r[i],max);
So I have several questions.
First how can I set the first and last element of the output array to 0 considering it is complex but doesn't let me asign a complex number to it?
Second, is how I'm doing this correct? or am I missing something?
Third (this is a follow up of what I need to do next). Can I use the FFTW libraries to get the amplitude and phase of the first to fourth harmonics of the series? If so, how?
Thanks for any help.
UPDATE:
I changed
#include "fftw.h"
for
#include "fftw3.h"
So on my includes I have
#include "complex.h"
#include "fftw3.h"
#include "rfftw.h"
But I'm getting the same error
UPDATE 2:
I'm also getting errors like this
/usr/include/fftw.h:307:13: error: conflicting types for ‘fftw_destroy_plan’
Because of including rfftw.h after fftw3.h. But if I delete rfftw.h then I get errors like this
error: unknown type name ‘fftw_real’
There seems to be a conflict between fftw3.h and rfftw.h but I can't delete rfftw.h because then I can't use the functions I need.