Sunday 15 September 2013

gcc - Using fftw in c for harmonic analysis -


So I have a periodic series and I need to get the highest number of the series without harmonic first.

The size of the series is 360

then I have

  f (0) = value1f (1) = value2 ... f (359) Somebody has suggested that to do this I want to do 360-point discrete fourier transfer DFT (F (0), F (1) ... F (35 9) ) - & gt; (F (0), F (1) ... F (35 9)) Then set F (0) and F (35 9) to 0, which will first remove the harmonic. After this I should change the 360-point inverse discrete Fourier to IDFT and then find the highest value in the result.  

To do this, I'm using fft libraries in c but I'm having trouble trying to understand how to use them properly to do this. My periodic series is composed of real numbers, so I do not:

  #include "complex.h" #include "fftw.h" #include "rfftw.h" ... Fftw_real in_r [360]; // Actual number input 1d array fftw_complex out_c [360]; // 1d array of output complex numbers rfftwnd_plan p_DFT; // Plan for calculating DFT RFTWand_Plan p_iDFT; // iDFT p_DFT = rfftwnd_create_plan (1, 360, FFTW_REAL_TO_COMPLEX, FFTW_MEASURE) plan to calculate; 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 of these calls: when incompatible type to assign to type, // "fftw_complexâ" type "complex double" type out_c [0] = 0.0+ 0.0 * _Complex_I; Out_c [35 9] = 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);   

I have many questions i

How can I decide the first and last element of the output array by 0, It's complicated, but do not give me a complex number?

Second, how am I doing this right? Or am I missing something?

The third (this is the follow-up of what I need to do) is the dimension and phase of the first fourth harmonics Can I use FFTW libraries to get it? If so, how?

Thanks for any help.

Update:

I changed

  #include "fftw    for #include" fftw3.h "  

for

P>

  #include "complex.h" #include "fftw3.h" #include "rfftw.h"   

but I'm getting the same error

Update 2:

I am also getting errors like this /usr/include/fftw.h:307:13: Error: The one for the disputed type fftw_destroy_planâ Line

due to fftw3.h included rfftw.h but if I remove rfftw.h I get such errors

  Error: unknown type name â ???? Fftw_real There is a conflict between fftw3.h and rfftw.h, but i can not remove rfftw.h because i can not use the required functions again.   

Reference to:

  fftw_complex out_c [360]; // 1d array of output complex numbers ... // I get an error of both in this call: Incompatible type when assigned to type, // â "??? fftw_complexâ" by type "Complex double" ??? Out_c [0] = 0.0 + 0.0 * _Complex_I; Out_c [35 9] = 0.0 + 0.0 * _Complex_I;   

Create this work in C99 mode on GMC (Option -std = c99 ) you need to include the header in the correct order:

  #include  #include Do & lt; fftw3.h & gt;   

like fftw_complex It should be defined as a complex type.


Otherwise it will be typedef double fftw_complex [2] , so the assignment goes like this: < Pre> out_c [0] [0] = 0.0; // real part out_c [0] [1] = 0.0; // imaginary part ...


Please see if complex numbers are implemented.


rfftw.h is obsolete with Fftw3:

in FFTW 2 Complex and real one- and multi-dimensional changes for fftw_plan, fftwnd_plan, rfftw_plan, and different date for rfftwnd_plan Type was different, and each type was a "destruction of his own" ???? The ceremony In FFTW 3, all plans are fftw_plan type and everyone has been destroyed by fftw_destroy_plan (scheme).

No comments:

Post a Comment