00001 #ifndef __FFTW_H 00002 #define __FFTW_H 00003 00004 #include "mimasconfig.h" 00005 00006 #ifdef HAVE_LIBFFTW3 00007 00008 #include <boost/multi_array.hpp> 00009 #include <complex> 00010 #include <functional> 00011 00012 namespace mimas { 00013 00042 template< typename Real, std::size_t Dim, typename TPtr > 00043 struct fft_t: 00044 public std::unary_function< boost::const_multi_array_ref< std::complex< Real >, Dim, TPtr >, 00045 boost::multi_array< std::complex< Real >, Dim > > 00046 { 00048 boost::multi_array< std::complex< Real >, Dim > operator() 00049 ( const boost::const_multi_array_ref< std::complex< Real >, Dim, TPtr > &field ); 00050 }; 00051 00054 template< typename Real, std::size_t Dim, typename TPtr > 00055 boost::multi_array< std::complex< Real >, Dim > 00056 fft( const boost::const_multi_array_ref< std::complex< Real >, Dim, TPtr > &field ) 00057 { 00058 return fft_t< Real, Dim, TPtr >()( field ); 00059 } 00060 00063 template< typename Real, std::size_t Dim, typename TPtr > 00064 struct invfft_t: 00065 public std::unary_function< boost::const_multi_array_ref< std::complex< Real >, Dim, TPtr >, 00066 boost::multi_array< std::complex< Real >, Dim > > 00067 { 00068 boost::multi_array< std::complex< Real >, Dim > operator() 00069 ( const boost::const_multi_array_ref< std::complex< Real >, Dim, TPtr > &field ); 00070 }; 00071 00074 template< typename Real, std::size_t Dim, typename TPtr > 00075 boost::multi_array< std::complex< Real >, Dim > 00076 invfft( const boost::const_multi_array_ref< std::complex< Real >, Dim, TPtr > &field ) 00077 { 00078 return invfft_t< Real, Dim, TPtr >()( field ); 00079 } 00080 00093 template< typename Real, std::size_t Dim, typename TPtr > 00094 struct rfft_t: 00095 public std::unary_function< boost::const_multi_array_ref< Real, Dim, TPtr >, 00096 boost::multi_array< std::complex< Real >, Dim > > 00097 { 00099 boost::multi_array< std::complex< Real >, Dim > operator() 00100 ( const boost::const_multi_array_ref< Real, Dim, TPtr > &field ); 00101 }; 00102 00105 template< typename Real, std::size_t Dim, typename TPtr > 00106 boost::multi_array< std::complex< Real >, Dim > 00107 rfft( const boost::const_multi_array_ref< Real, Dim, TPtr > &field ) 00108 { 00109 return rfft_t< Real, Dim, TPtr >()( field ); 00110 } 00111 00112 00125 template< typename Real, std::size_t Dim, typename TPtr > 00126 struct invrfft_t: 00127 public std::unary_function< boost::const_multi_array_ref< std::complex< Real >, Dim, TPtr >, 00128 boost::multi_array< Real, Dim > > 00129 { 00130 boost::multi_array< Real, Dim > operator() 00131 ( const boost::const_multi_array_ref< std::complex< Real >, Dim, TPtr > &field ); 00132 }; 00133 00136 template< typename Real, std::size_t Dim, typename TPtr > 00137 boost::multi_array< Real, Dim > 00138 invrfft( const boost::const_multi_array_ref< std::complex< Real >, Dim, TPtr > &field ) 00139 { 00140 return invrfft_t< Real, Dim, TPtr >()( field ); 00141 } 00142 00144 00145 }; 00146 00147 #include "fourier.tcc" 00148 00149 #endif 00150 00151 #endif