casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
FFTW.h
Go to the documentation of this file.
00001 //# Copyright (C) 1993,1994,1995,1997,1999,2000,2001
00002 //# Associated Universities, Inc. Washington DC, USA.
00003 //#
00004 //# This library is free software; you can redistribute it and/or modify it
00005 //# under the terms of the GNU Library General Public License as published by
00006 //# the Free Software Foundation; either version 2 of the License, or (at your
00007 //# option) any later version.
00008 //#
00009 //# This library is distributed in the hope that it will be useful, but WITHOUT
00010 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012 //# License for more details.
00013 //#
00014 //# You should have received a copy of the GNU Library General Public License
00015 //# along with this library; if not, write to the Free Software Foundation,
00016 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00017 //#
00018 //# Correspondence concerning AIPS++ should be addressed as follows:
00019 //#        Internet email: aips2-request@nrao.edu.
00020 //#        Postal address: AIPS++ Project Office
00021 //#                        National Radio Astronomy Observatory
00022 //#                        520 Edgemont Road
00023 //#                        Charlottesville, VA 22903-2475 USA
00024 //#
00025 
00026 //# $Id: FFTW.h 21069 2011-05-06 13:59:44Z gervandiepen $
00027 
00028 #ifndef SCIMATH_FFTW_H
00029 #define SCIMATH_FFTW_H
00030 
00031 #include <casa/Arrays/Array.h>
00032 #include <casa/Arrays/ArrayLogical.h>
00033 #include <casa/Arrays/VectorIter.h>
00034 #include <casa/Arrays/Matrix.h>
00035 #include <casa/OS/Mutex.h>
00036 
00037 namespace casa {
00038 
00039 //# Forward Declarations.
00040 class FFTWPlan;
00041 class FFTWPlanf;
00042 
00043 // <summary> C++ interface to the FFTWw library </summary>
00044 // <reviewed reviewer="NONE" date="" tests="" demos="">
00045 // </reviewed>
00046 // <synopsis>
00047 // This is a wrapper of FFTW3.
00048 // It is only active if FFTW3 was found during the build.
00049 // If not found, all functions won't do anything at all.
00050 // 
00051 // The interface is such that the presence of FFTW3 is only visible
00052 // in the implementation. The header file does not need to know.
00053 // In this way external code using this class does not need to set HAVE_FFTW.
00054 // </synopsis>
00055 
00056 class FFTW
00057 {
00058 public:
00059   FFTW() ;
00060   
00061   ~FFTW() ;
00062 
00063   // polymorphic interface to fftw[f]_plan...
00064   void plan_r2c(const IPosition &size, Float *in, Complex *out) ;
00065   void plan_r2c(const IPosition &size, Double *in, DComplex *out) ;
00066   void plan_c2r(const IPosition &size, Complex *in, Float *out) ;
00067   void plan_c2r(const IPosition &size, DComplex *in, Double *out) ;
00068   void plan_c2c_forward(const IPosition &size, DComplex *in) ;
00069   void plan_c2c_forward(const IPosition &size, Complex *in) ;
00070   void plan_c2c_backward(const IPosition &size, DComplex *in) ;
00071   void plan_c2c_backward(const IPosition &size, Complex *in) ;
00072   
00073   // polymorphic interface to fftw[f]_execute...
00074   void r2c(const IPosition &size, Float *in, Complex *out) ;
00075   void r2c(const IPosition &size, Double *in, DComplex *out) ;
00076   void c2r(const IPosition &size, Complex *in, Float *out);
00077   void c2r(const IPosition &size, DComplex *in, Double *out);
00078   void c2c(const IPosition &size, Complex *in, Bool forward);
00079   void c2c(const IPosition &size, DComplex *in, Bool forward);
00080 
00081 private:
00082   FFTWPlanf* itsPlanR2Cf;
00083   FFTWPlan*  itsPlanR2C;
00084   
00085   FFTWPlanf* itsPlanC2Rf;
00086   FFTWPlan*  itsPlanC2R;
00087   
00088   FFTWPlanf* itsPlanC2CFf;   // forward
00089   FFTWPlan*  itsPlanC2CF;
00090   
00091   FFTWPlanf* itsPlanC2CBf;   // backward
00092   FFTWPlan*  itsPlanC2CB;
00093   
00094   unsigned flags;
00095 
00096   static volatile Bool is_initialized_fftw;  // FFTW needs initialization
00097                                              // only once per process,
00098                                              // not once per object
00099   static Mutex theirMutex;          // Initialization mutex
00100 };    
00101     
00102 } //# NAMESPACE CASA - END
00103 
00104 #endif