00001 #include <fftw3.h>
00002 #include "tbl.h"
00003
00004 namespace {
00005 const int nmax = 50 ;
00006 int nworked = 0 ;
00007 Tbl* tab_tab[nmax] ;
00008 fftw_plan plan_fft[nmax] ;
00009 int nb_fft[nmax] ;
00010 }
00011
00012 fftw_plan prepare_fft(int n, Tbl*& pg) {
00013 int index = -1 ;
00014 for (int i=0; ((i<nworked) && (index<0)); i++)
00015 if (nb_fft[i] == n) index = i ;
00016
00017 if (index <0) {
00018 index = nworked ;
00019 if (index >= nmax) {
00020 cout << "prepare_fft: " << endl ;
00021 cout << "too many plans!" << endl ;
00022 abort() ;
00023 }
00024 tab_tab[index] = new Tbl(n) ;
00025 Tbl& tab = (*tab_tab[index]) ;
00026 tab.set_etat_qcq() ;
00027 plan_fft[index] =
00028 fftw_plan_r2r_1d(n, tab.t, tab.t, FFTW_R2HC, FFTW_ESTIMATE) ;
00029 nb_fft[index] = n ;
00030 nworked++ ;
00031 }
00032 assert((index>=0)&&(index<nmax)) ;
00033 pg = tab_tab[index] ;
00034 return plan_fft[index] ;
00035 }
00036