File: fftw_ini.C

package info (click to toggle)
lorene 0.0.0~cvs20161116%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,472 kB
  • sloc: cpp: 212,946; fortran: 21,645; makefile: 1,750; sh: 4
file content (39 lines) | stat: -rw-r--r-- 915 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <fftw3.h>
#include "tbl.h"

namespace Lorene {

namespace {
  const int nmax = 50 ; //Maximal number of FFT sizes 
  int nworked = 0 ;
  Tbl* tab_tab[nmax] ;
  fftw_plan plan_fft[nmax] ;
  int nb_fft[nmax] ;
}

fftw_plan prepare_fft(int n, Tbl*& pg) {
  int index = -1 ;
  for (int i=0; ((i<nworked) && (index<0)); i++) 
    if (nb_fft[i] == n) index = i ; //Has the plan already been estimated?

  if (index <0) { //New plan needed
    index = nworked ;
    if (index >= nmax) {
      cout << "prepare_fft: " << endl ;
      cout << "too many plans!" << endl ;
      abort() ;
    }
    tab_tab[index] = new Tbl(n) ;
    Tbl& tab = (*tab_tab[index]) ;
    tab.set_etat_qcq() ;
    plan_fft[index] = 
      fftw_plan_r2r_1d(n, tab.t, tab.t, FFTW_R2HC, FFTW_ESTIMATE) ;
    nb_fft[index] = n ;
    nworked++ ;
  }
  assert((index>=0)&&(index<nmax)) ;
  pg = tab_tab[index] ;
  return plan_fft[index] ;
}

}