Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkFFTWCommon.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkFFTWCommon.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-12-21 19:13:11 $
00007   Version:   $Revision: 1.8 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkFFTWCommon_h
00018 #define __itkFFTWCommon_h
00019 
00020 #if defined(USE_FFTWF) || defined(USE_FFTWD)
00021 #include "fftw3.h"
00022 #endif
00023 
00024 namespace itk
00025 {
00026 namespace fftw
00027 {
00032 template <typename TPixel>
00033 class  Proxy
00034 {
00035   // empty -- only double and float specializations work
00036 protected:
00037   Proxy() {}; 
00038   ~Proxy() {};
00039 };
00041 
00042 #if defined(USE_FFTWF)
00043 
00044 template <>
00045 class Proxy<float>
00046 {
00047 public:
00048   typedef float         PixelType;
00049   typedef fftwf_complex ComplexType;
00050   typedef fftwf_plan    PlanType;
00051 
00052   static PlanType Plan_dft_c2r_1d(int n,
00053                                   ComplexType *in,
00054                                   PixelType *out,
00055                                   unsigned flags)
00056     {
00057     return fftwf_plan_dft_c2r_1d(n,in,out,flags);
00058     }
00059   static PlanType Plan_dft_c2r_2d(int nx, 
00060                                   int ny,
00061                                   ComplexType *in,
00062                                   PixelType *out, 
00063                                   unsigned flags)
00064     {
00065     return fftwf_plan_dft_c2r_2d(nx,ny,in,out,flags);
00066     }
00067   static PlanType Plan_dft_c2r_3d(int nx, 
00068                                   int ny,
00069                                   int nz,
00070                                   ComplexType *in, 
00071                                   PixelType *out, 
00072                                   unsigned flags)
00073     {
00074     return fftwf_plan_dft_c2r_3d(nx,ny,nz,in,out,flags);
00075     }
00076   static PlanType Plan_dft_c2r(int rank, 
00077                                const int *n,
00078                                ComplexType *in, 
00079                                PixelType *out, 
00080                                unsigned flags)
00081     {
00082     return fftwf_plan_dft_c2r(rank,n,in,out,flags);
00083     }
00084 
00085   static PlanType Plan_dft_r2c_1d(int n,
00086                                   PixelType *in,
00087                                   ComplexType *out,
00088                                   unsigned flags)
00089     {
00090     return fftwf_plan_dft_r2c_1d(n,in,out,flags);
00091     }
00092   static PlanType Plan_dft_r2c_2d(int nx, 
00093                                   int ny,
00094                                   PixelType *in,
00095                                   ComplexType *out, 
00096                                   unsigned flags)
00097     {
00098     return fftwf_plan_dft_r2c_2d(nx,ny,in,out,flags);
00099     }
00100   static PlanType Plan_dft_r2c_3d(int nx, 
00101                                   int ny,
00102                                   int nz,
00103                                   PixelType *in, 
00104                                   ComplexType *out, 
00105                                   unsigned flags)
00106     {
00107     return fftwf_plan_dft_r2c_3d(nx,ny,nz,in,out,flags);
00108     }
00109   static PlanType Plan_dft_r2c(int rank, 
00110                                const int *n,
00111                                PixelType *in, 
00112                                ComplexType *out, 
00113                                unsigned flags)
00114     {
00115     return fftwf_plan_dft_r2c(rank,n,in,out,flags);
00116     }
00117 
00118   static void Execute(PlanType p)
00119     {
00120     fftwf_execute(p);
00121     }
00122   static void DestroyPlan(PlanType p)
00123     {
00124     fftwf_destroy_plan(p);
00125     }
00126 };
00127 #endif // USE_FFTWF
00128 #if defined(USE_FFTWD)
00129 template <> 
00130 class Proxy<double>
00131 {
00132 public:
00133   typedef double       PixelType;
00134   typedef fftw_complex ComplexType;
00135   typedef fftw_plan    PlanType;
00136 
00137   static PlanType Plan_dft_c2r_1d(int n,
00138                                   ComplexType *in,
00139                                   PixelType *out,
00140                                   unsigned flags)
00141     {
00142     return fftw_plan_dft_c2r_1d(n,in,out,flags);
00143     }
00144   static PlanType Plan_dft_c2r_2d(int nx, 
00145                                   int ny,
00146                                   ComplexType *in,
00147                                   PixelType *out, 
00148                                   unsigned flags)
00149     {
00150     return fftw_plan_dft_c2r_2d(nx,ny,in,out,flags);
00151     }
00152   static PlanType Plan_dft_c2r_3d(int nx, 
00153                                   int ny,
00154                                   int nz,
00155                                   ComplexType *in, 
00156                                   PixelType *out, 
00157                                   unsigned flags)
00158     {
00159     return fftw_plan_dft_c2r_3d(nx,ny,nz,in,out,flags);
00160     }
00161   static PlanType Plan_dft_c2r(int rank, 
00162                                const int *n,
00163                                ComplexType *in, 
00164                                PixelType *out, 
00165                                unsigned flags)
00166     {
00167     return fftw_plan_dft_c2r(rank,n,in,out,flags);
00168     }
00169 
00170   static PlanType Plan_dft_r2c_1d(int n,
00171                                   PixelType *in,
00172                                   ComplexType *out,
00173                                   unsigned flags)
00174     {
00175     return fftw_plan_dft_r2c_1d(n,in,out,flags);
00176     }
00177   static PlanType Plan_dft_r2c_2d(int nx, 
00178                                   int ny,
00179                                   PixelType *in,
00180                                   ComplexType *out, 
00181                                   unsigned flags)
00182     {
00183     return fftw_plan_dft_r2c_2d(nx,ny,in,out,flags);
00184     }
00185   static PlanType Plan_dft_r2c_3d(int nx, 
00186                                   int ny,
00187                                   int nz,
00188                                   PixelType *in, 
00189                                   ComplexType *out, 
00190                                   unsigned flags)
00191     {
00192     return fftw_plan_dft_r2c_3d(nx,ny,nz,in,out,flags);
00193     }
00194   static PlanType Plan_dft_r2c(int rank, 
00195                                const int *n,
00196                                PixelType *in, 
00197                                ComplexType *out, 
00198                                unsigned flags)
00199     {
00200     return fftw_plan_dft_r2c(rank,n,in,out,flags);
00201     }
00202   static void Execute(PlanType p)
00203     {
00204     fftw_execute(p);
00205     }
00206   static void DestroyPlan(PlanType p)
00207     {
00208     fftw_destroy_plan(p);
00209     }
00210 };
00211 #endif
00212 }
00213 }
00214 #endif
00215 

Generated at Mon Jul 12 2010 18:20:01 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000