fftpack_support.h

00001 /*
00002  *  This file is part of libcxxsupport.
00003  *
00004  *  libcxxsupport is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  libcxxsupport is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with libcxxsupport; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017  */
00018 
00019 /*
00020  *  libcxxsupport is being developed at the Max-Planck-Institut fuer Astrophysik
00021  *  and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
00022  *  (DLR).
00023  */
00024 
00025 /*
00026  *  Copyright (C) 2004-2015 Max-Planck-Society
00027  *  \author Martin Reinecke
00028  */
00029 
00030 #ifndef PLANCK_FFTPACK_SUPPORT_H
00031 #define PLANCK_FFTPACK_SUPPORT_H
00032 
00033 #include "ls_fft.h"
00034 #include "arr.h"
00035 #include "xcomplex.h"
00036 
00037 class cfft
00038   {
00039   private:
00040     tsize n;
00041     complex_plan plan;
00042 
00043   public:
00044     cfft () : n(0), plan(0) {}
00045     cfft (tsize size_)
00046       : n(size_), plan(make_complex_plan(size_)) {}
00047     cfft (const cfft &orig)
00048       : n(orig.n), plan(copy_complex_plan(orig.plan)) {}
00049     ~cfft ()
00050       { if (plan!=0) kill_complex_plan (plan); }
00051     cfft &operator=(const cfft &orig)
00052       {
00053       if (n!=orig.n)
00054         {
00055         if (plan!=0) kill_complex_plan (plan);
00056         n=orig.n;
00057         plan = copy_complex_plan(orig.plan);
00058         }
00059       return *this;
00060       }
00061     void Set (tsize size_)
00062       {
00063       if (n==size_) return;
00064       if (plan!=0) kill_complex_plan (plan);
00065       n=size_;
00066       plan=make_complex_plan(size_);
00067       }
00068 
00069     tsize size() const
00070       { return n; }
00071 
00072     void forward (double *data)
00073       { complex_plan_forward(plan,data); }
00074     void backward (double *data)
00075       { complex_plan_backward(plan,data); }
00076     void forward (dcomplex *data)
00077       { complex_plan_forward(plan,reinterpret_cast<double *>(data)); }
00078     void backward (dcomplex *data)
00079       { complex_plan_backward(plan,reinterpret_cast<double *>(data)); }
00080     void forward (arr<dcomplex> &data)
00081       { forward(reinterpret_cast<double *>(&data[0])); }
00082     void backward (arr<dcomplex> &data)
00083       { backward(reinterpret_cast<double *>(&data[0])); }
00084   };
00085 
00086 class rfft
00087   {
00088   private:
00089     tsize n;
00090     real_plan plan;
00091 
00092   public:
00093     rfft () : n(0), plan(0) {}
00094     rfft (const rfft &orig)
00095       : n(orig.n), plan(copy_real_plan(orig.plan)) {}
00096     rfft (tsize size_)
00097       : n(size_), plan(make_real_plan(size_)) {}
00098     ~rfft ()
00099       { if (plan!=0) kill_real_plan (plan); }
00100     rfft &operator=(const rfft &orig)
00101       {
00102       if (n!=orig.n)
00103         {
00104         if (plan!=0) kill_real_plan (plan);
00105         n=orig.n;
00106         plan = copy_real_plan(orig.plan);
00107         }
00108       return *this;
00109       }
00110     void Set (tsize size_)
00111       {
00112       if (n==size_) return;
00113       if (plan!=0) kill_real_plan (plan);
00114       n=size_;
00115       plan=make_real_plan(size_);
00116       }
00117 
00118     tsize size() const
00119       { return n; }
00120 
00121     void forward_fftpack (double *data)
00122       { real_plan_forward_fftpack(plan,data); }
00123     void backward_fftpack (double *data)
00124       { real_plan_backward_fftpack(plan,data); }
00125     void forward_fftpack (arr<double> &data)
00126       { forward_fftpack(&(data[0])); }
00127     void backward_fftpack (arr<double> &data)
00128       { backward_fftpack(&(data[0])); }
00129     void forward_c (arr<dcomplex> &data)
00130       { real_plan_forward_c(plan,reinterpret_cast<double *>(&data[0])); }
00131     void backward_c (arr<dcomplex> &data)
00132       { real_plan_backward_c(plan,reinterpret_cast<double *>(&data[0])); }
00133   };
00134 
00135 #endif

Generated on Thu Oct 8 14:48:51 2015 for LevelS C++ support library