LevelS C++ support library  3.50
fftpack_support.h
1 /*
2  * This file is part of libcxxsupport.
3  *
4  * libcxxsupport is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * libcxxsupport is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with libcxxsupport; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /*
20  * libcxxsupport is being developed at the Max-Planck-Institut fuer Astrophysik
21  * and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
22  * (DLR).
23  */
24 
25 /*
26  * Copyright (C) 2004-2015 Max-Planck-Society
27  * \author Martin Reinecke
28  */
29 
30 #ifndef PLANCK_FFTPACK_SUPPORT_H
31 #define PLANCK_FFTPACK_SUPPORT_H
32 
33 #include "ls_fft.h"
34 #include "arr.h"
35 #include "xcomplex.h"
36 
37 class cfft
38  {
39  private:
40  tsize n;
41  complex_plan plan;
42 
43  public:
44  cfft () : n(0), plan(0) {}
45  cfft (tsize size_)
46  : n(size_), plan(make_complex_plan(size_)) {}
47  cfft (const cfft &orig)
48  : n(orig.n), plan(copy_complex_plan(orig.plan)) {}
49  ~cfft ()
50  { if (plan!=0) kill_complex_plan (plan); }
51  cfft &operator=(const cfft &orig)
52  {
53  if (n!=orig.n)
54  {
55  if (plan!=0) kill_complex_plan (plan);
56  n=orig.n;
57  plan = copy_complex_plan(orig.plan);
58  }
59  return *this;
60  }
61  void Set (tsize size_)
62  {
63  if (n==size_) return;
64  if (plan!=0) kill_complex_plan (plan);
65  n=size_;
66  plan=make_complex_plan(size_);
67  }
68 
69  tsize size() const
70  { return n; }
71 
72  void forward (double *data)
73  { complex_plan_forward(plan,data); }
74  void backward (double *data)
75  { complex_plan_backward(plan,data); }
76  void forward (dcomplex *data)
77  { complex_plan_forward(plan,reinterpret_cast<double *>(data)); }
78  void backward (dcomplex *data)
79  { complex_plan_backward(plan,reinterpret_cast<double *>(data)); }
80  void forward (arr<dcomplex> &data)
81  { forward(reinterpret_cast<double *>(&data[0])); }
82  void backward (arr<dcomplex> &data)
83  { backward(reinterpret_cast<double *>(&data[0])); }
84  };
85 
86 class rfft
87  {
88  private:
89  tsize n;
90  real_plan plan;
91 
92  public:
93  rfft () : n(0), plan(0) {}
94  rfft (const rfft &orig)
95  : n(orig.n), plan(copy_real_plan(orig.plan)) {}
96  rfft (tsize size_)
97  : n(size_), plan(make_real_plan(size_)) {}
98  ~rfft ()
99  { if (plan!=0) kill_real_plan (plan); }
100  rfft &operator=(const rfft &orig)
101  {
102  if (n!=orig.n)
103  {
104  if (plan!=0) kill_real_plan (plan);
105  n=orig.n;
106  plan = copy_real_plan(orig.plan);
107  }
108  return *this;
109  }
110  void Set (tsize size_)
111  {
112  if (n==size_) return;
113  if (plan!=0) kill_real_plan (plan);
114  n=size_;
115  plan=make_real_plan(size_);
116  }
117 
118  tsize size() const
119  { return n; }
120 
121  void forward_fftpack (double *data)
122  { real_plan_forward_fftpack(plan,data); }
123  void backward_fftpack (double *data)
124  { real_plan_backward_fftpack(plan,data); }
125  void forward_fftpack (arr<double> &data)
126  { forward_fftpack(&(data[0])); }
127  void backward_fftpack (arr<double> &data)
128  { backward_fftpack(&(data[0])); }
129  void forward_c (arr<dcomplex> &data)
130  { real_plan_forward_c(plan,reinterpret_cast<double *>(&data[0])); }
131  void backward_c (arr<dcomplex> &data)
132  { real_plan_backward_c(plan,reinterpret_cast<double *>(&data[0])); }
133  };
134 
135 #endif
std::size_t tsize
Definition: datatypes.h:116
Definition: arr.h:300

Generated on Mon Dec 10 2018 10:24:20 for LevelS C++ support library