| 1 |
#include <fftw3.h> |
| 2 |
#include "tbl.h" |
| 3 |
|
| 4 |
namespace Lorene { |
| 5 |
|
| 6 |
namespace { |
| 7 |
const int nmax = 50 ; //Maximal number of FFT sizes |
| 8 |
int nworked = 0 ; |
| 9 |
Tbl* tab_tab[nmax] ; |
| 10 |
fftw_plan plan_fft[nmax] ; |
| 11 |
int nb_fft[nmax] ; |
| 12 |
} |
| 13 |
|
| 14 |
fftw_plan prepare_fft(int n, Tbl*& pg) { |
| 15 |
int index = -1 ; |
| 16 |
for (int i=0; ((i<nworked) && (index<0)); i++) |
| 17 |
if (nb_fft[i] == n) index = i ; //Has the plan already been estimated? |
| 18 |
|
| 19 |
if (index <0) { //New plan needed |
| 20 |
index = nworked ; |
| 21 |
if (index >= nmax) { |
| 22 |
cout << "prepare_fft: " << endl ; |
| 23 |
cout << "too many plans!" << endl ; |
| 24 |
abort() ; |
| 25 |
} |
| 26 |
tab_tab[index] = new Tbl(n) ; |
| 27 |
Tbl& tab = (*tab_tab[index]) ; |
| 28 |
tab.set_etat_qcq() ; |
| 29 |
plan_fft[index] = |
| 30 |
fftw_plan_r2r_1d(n, tab.t, tab.t, FFTW_R2HC, FFTW_ESTIMATE) ; |
| 31 |
nb_fft[index] = n ; |
| 32 |
nworked++ ; |
| 33 |
} |
| 34 |
assert((index>=0)&&(index<nmax)) ; |
| 35 |
pg = tab_tab[index] ; |
| 36 |
return plan_fft[index] ; |
| 37 |
} |
| 38 |
|
| 39 |
} |