Rev Author Line No. Line
178 kaklik 1 #include "fourier.h"
2  
3 namespace mimas {
4  
5 template<>
6 void dft_< float >::operator()( int rank, const int *n,
7 const std::complex< float > *in,
8 std::complex< float > *out, int sign )
9 {
10 fftwf_plan plan =
11 fftwf_plan_dft( rank, n, (fftwf_complex *)in, (fftwf_complex *)out,
12 sign, FFTW_ESTIMATE | FFTW_PRESERVE_INPUT );
13  
14 assert( plan != NULL );
15  
16 fftwf_execute( plan );
17 fftwf_destroy_plan( plan );
18 }
19  
20 template<>
21 void dft_< double >::operator()( int rank, const int *n,
22 const std::complex< double > *in,
23 std::complex< double > *out, int sign )
24 {
25 fftw_plan plan =
26 fftw_plan_dft( rank, n, (fftw_complex *)in, (fftw_complex *)out,
27 sign, FFTW_ESTIMATE | FFTW_PRESERVE_INPUT );
28  
29 assert( plan != NULL );
30  
31 fftw_execute( plan );
32 fftw_destroy_plan( plan );
33 }
34  
35 template<>
36 void dft_r2c_< float >::operator()( int rank, const int *n,
37 const float *in,
38 std::complex< float > *out )
39 {
40 fftwf_plan plan =
41 fftwf_plan_dft_r2c( rank, n, (float *)in, (fftwf_complex *)out,
42 FFTW_ESTIMATE | FFTW_PRESERVE_INPUT );
43  
44 assert( plan != NULL );
45  
46 fftwf_execute( plan );
47 fftwf_destroy_plan( plan );
48 }
49  
50 template<>
51 void dft_r2c_< double >::operator()( int rank, const int *n,
52 const double *in,
53 std::complex< double > *out )
54 {
55 assert( sizeof( std::complex< double > ) == sizeof( fftw_complex ) );
56  
57 fftw_plan plan =
58 fftw_plan_dft_r2c( rank, n, (double *)in, (fftw_complex *)out,
59 FFTW_ESTIMATE | FFTW_PRESERVE_INPUT );
60  
61 assert( plan != NULL );
62  
63 fftw_execute( plan );
64 fftw_destroy_plan( plan );
65 }
66  
67 template<>
68 void dft_c2r_< float >::operator()( int rank, const int *n,
69 const std::complex< float > *in,
70 float *out )
71 {
72 assert( sizeof( std::complex< float > ) == sizeof( fftwf_complex ) );
73 fftwf_plan plan =
74 fftwf_plan_dft_c2r( rank, n, (fftwf_complex *)in, (float *)out,
75 FFTW_ESTIMATE );// FFTW_PRESERVE_INPUT
76  
77 assert( plan != NULL );
78  
79 fftwf_execute( plan );
80 fftwf_destroy_plan( plan );
81 }
82  
83 template<>
84 void dft_c2r_< double >::operator()( int rank, const int *n,
85 const std::complex< double > *in,
86 double *out )
87 {
88 assert( sizeof( std::complex< double > ) == sizeof( fftw_complex ) );
89 fftw_plan plan =
90 fftw_plan_dft_c2r( rank, n, (fftw_complex *)in, (double *)out,
91 FFTW_ESTIMATE );// FFTW_PRESERVE_INPUT
92  
93 assert( plan != NULL );
94  
95 fftw_execute( plan );
96 fftw_destroy_plan( plan );
97 }
98  
99 };