#include <stdio.h> #include <math.h> #include <numeric.h> #define N 16 #define M 4 int main() { int i,j,k,retval; array double x1[N]; array double complex y1[N],y2[M],x2[N],x3[M]; int n = M; urand(x1); fft(y1,x1); ifft(x2,y1); printf("FFT number of points by default\n"); printf("Original data FFT result FFT + iFFT result\n"); for (i=0; i<N; i++) printf("%5.3f %5.3f %5.3f\n",x1[i],y1[i],x2[i]); printf("FFT number of points is specified by n=%d\n",n); fft(y2,x1,n); ifft(x3,y2,n); printf("\n\nOriginal data FFT result FFT + iFFT result\n"); for (i=0; i<M; i++) printf("%5.3f %5.3f %5.3f\n",x1[i],y2[i],x3[i]); }
FFT number of points by default Original data FFT result FFT + iFFT result 0.514 complex(0.514,0.000) complex(0.514,0.000) 0.176 complex(0.176,0.000) complex(0.176,0.000) 0.309 complex(0.309,0.000) complex(0.309,0.000) 0.535 complex(0.535,0.000) complex(0.535,0.000) 0.948 complex(0.948,0.000) complex(0.948,0.000) 0.172 complex(0.172,0.000) complex(0.172,0.000) 0.702 complex(0.702,0.000) complex(0.702,0.000) 0.226 complex(0.226,0.000) complex(0.226,0.000) 0.495 complex(0.495,0.000) complex(0.495,0.000) 0.125 complex(0.125,0.000) complex(0.125,0.000) 0.084 complex(0.084,0.000) complex(0.084,0.000) 0.390 complex(0.390,0.000) complex(0.390,0.000) 0.277 complex(0.277,0.000) complex(0.277,0.000) 0.368 complex(0.368,0.000) complex(0.368,0.000) 0.983 complex(0.983,0.000) complex(0.983,0.000) 0.535 complex(0.535,0.000) complex(0.535,0.000) FFT number of points is specified by n=4 Original data FFT result FFT + iFFT result 0.514 complex(0.514,0.000) complex(0.514,0.000) 0.176 complex(0.176,0.000) complex(0.176,0.000) 0.309 complex(0.309,0.000) complex(0.309,0.000) 0.535 complex(0.535,0.000) complex(0.535,0.000)