25 #include <queso/Fft.h> 
   26 #include <gsl/gsl_fft_real.h> 
   27 #include <gsl/gsl_fft_complex.h> 
   35   const std::vector<double>&                data,
 
   37         std::vector<std::complex<double> >& forwardResult)
 
   39   if (forwardResult.size() != fftSize) {
 
   40     forwardResult.resize(fftSize,std::complex<double>(0.,0.));
 
   41     std::vector<std::complex<double> >(forwardResult).swap(forwardResult);
 
   44   std::vector<double> internalData(fftSize,0.);
 
   45   unsigned int minSize = std::min((
unsigned int) data.size(),fftSize);
 
   46   for (
unsigned int j = 0; j < minSize; ++j) {
 
   47     internalData[j] = data[j];
 
   56   gsl_fft_real_workspace* realWkSpace = gsl_fft_real_workspace_alloc(fftSize);
 
   57   gsl_fft_real_wavetable* realWvTable = gsl_fft_real_wavetable_alloc(fftSize);
 
   59   gsl_fft_real_transform(&internalData[0],
 
   65   gsl_fft_real_wavetable_free(realWvTable);
 
   66   gsl_fft_real_workspace_free(realWkSpace);
 
   74   unsigned int halfFFTSize = fftSize/2;
 
   75   double realPartOfFFT = 0.;
 
   76   double imagPartOfFFT = 0.;
 
   77   for (
unsigned int j = 0; j < internalData.size(); ++j) {
 
   79       realPartOfFFT = internalData[j];
 
   82     else if (j < halfFFTSize) {
 
   83       realPartOfFFT = internalData[2*j-1];
 
   84       imagPartOfFFT = internalData[2*j  ];
 
   86     else if (j == halfFFTSize) {
 
   87       realPartOfFFT = internalData[2*j-1];
 
   91       realPartOfFFT =  internalData[2*(fftSize-j)-1];
 
   92       imagPartOfFFT = -internalData[2*(fftSize-j)  ];
 
   94     forwardResult[j] = std::complex<double>(realPartOfFFT,imagPartOfFFT);
 
  103   const std::vector<double>&                data,
 
  104         unsigned int                        fftSize,
 
  105         std::vector<std::complex<double> >& inverseResult)
 
  107   if (inverseResult.size() != fftSize) {
 
  108     inverseResult.resize(fftSize,std::complex<double>(0.,0.));
 
  109     std::vector<std::complex<double> >(inverseResult).swap(inverseResult);
 
  112   std::vector<double> internalData(2*fftSize,0.); 
 
  113   unsigned int minSize = std::min((
unsigned int) data.size(),fftSize);
 
  114   for (
unsigned int j = 0; j < minSize; ++j) {
 
  115     internalData[2*j] = data[j];
 
  126   gsl_fft_complex_workspace* complexWkSpace = gsl_fft_complex_workspace_alloc(fftSize);
 
  127   gsl_fft_complex_wavetable* complexWvTable = gsl_fft_complex_wavetable_alloc(fftSize);
 
  129   gsl_fft_complex_inverse(&internalData[0],
 
  135   gsl_fft_complex_wavetable_free(complexWvTable);
 
  136   gsl_fft_complex_workspace_free(complexWkSpace);
 
  146   for (
unsigned int j = 0; j < fftSize; ++j) {
 
  147     inverseResult[j] = std::complex<double>(internalData[2*j],internalData[2*j+1]);
 
  157   if (m_fftSize != fftSize) {
 
  158     if (m_fftSize != 0) freeTables();
 
  160     m_realWkSpace = gsl_fft_real_workspace_alloc       (fftSize);
 
  161     m_realWvTable = gsl_fft_real_wavetable_alloc       (fftSize);
 
  172   if (m_fftSize != 0) {
 
  174     gsl_fft_real_wavetable_free       (m_realWvTable);
 
  175     gsl_fft_real_workspace_free       (m_realWkSpace);
 
void forward(const std::vector< T > &data, unsigned int fftSize, std::vector< std::complex< double > > &result)
Calculates the forward Fourier transform (for real data. TODO: complex data). 
 
Class for a Fast Fourier Transform (FFT) algorithm.