/* Program gslffttry: written to demonstrate the problem arising in the call to gsl_fft_halfcomplex_unpack: !! This is a modification of the example given in the GSL manual for real data fft to obtain the half_complex_coefficients (CmplxCoeff), assign them to a gsl_complex variable (HCmplxCoeff) and to compute the square of thier absolute values (Pwr). !! I have commented out the gsl_complex_packed_array CmplxCoeff[2*n] below and replaced it with double CmplxCoeff[2*n]. Remove the comment to reproduce the "warning" and a resulting error. Explanation of the problem: > When I use gsl_fft_halfcomplex_unpack, The GSL Ref. Manual (first > edition) and also > http://sources.redhat.com/gsl/ref/gsl-ref_15.html#SEC240, describes > it as int gsl_fft_halfcomplex_unpack (const double > halfcomplex_coefficient[], gsl_complex_packed_array > complex_coefficient[], size_t stride, size_t n) > > When I use it based on the above description, I get the following > warning when I compile it (on a Linux PC, with gsl-1.2.90 compiled > from sources) Compilation command: gcc -c -Wall -g > -I. -I/usr/include -I/home/mow/soft/include analyse_freq.c Warning: > analyse_freq.c:190: warning: passing arg 2 of > `gsl_fft_halfcomplex_unpack' from incompatible pointer type Brian Gough suggested: Can you send an example program which reproduces this problem to address@hidden, with the output of gcc -v on your system. Thanks. */ #include #include #include #include #include #include #include #include int main() { int i, n=1000; double data[1000]; double Pwr[1000]; gsl_fft_real_wavetable * real; gsl_fft_halfcomplex_wavetable * hc; gsl_fft_real_workspace * work; // gsl_complex_packed_array CmplxCoeff[2*n]; double CmplxCoeff[2*n]; gsl_complex HCmplxCoeff; /* Creating the square wave */ for (i=0; i < n; i++) { data[i] = 0.0; } for (i = n / 3; i < 2* n / 3; i++) { data[i] = 1.0; } /* Doing the Fast Fourier transform */ work = gsl_fft_real_workspace_alloc (n); real = gsl_fft_real_wavetable_alloc (n); gsl_fft_real_transform (data, 1, n, real, work); gsl_fft_real_wavetable_free (real); /* Deriving the Square of the Complex co-efficients */ gsl_fft_halfcomplex_unpack (data, CmplxCoeff, 1, n); for (i = 0; i < n; i++) { GSL_SET_COMPLEX(&HCmplxCoeff,CmplxCoeff[i],CmplxCoeff[i+1]); Pwr[i] = gsl_complex_abs2(HCmplxCoeff); printf("%d %e\n",i,Pwr[i]); } /* Removing contributions from higher frequencies */ for (i = 11; i < n; i++) { data[i] = 0.0; } /* Carrying out the inverse transform */ hc = gsl_fft_halfcomplex_wavetable_alloc (n); gsl_fft_halfcomplex_inverse (data, 1, n, hc, work); gsl_fft_halfcomplex_wavetable_free (hc); for (i = 0; i < n; i++) { printf("%d %e\n",i, data[i]); } gsl_fft_real_workspace_free (work); exit(0); }