GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
oct-fftw.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2001-2017 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_oct_fftw_h)
24 #define octave_oct_fftw_h 1
25 
26 #include "octave-config.h"
27 
28 #include <cstddef>
29 
30 #include "oct-cmplx.h"
31 #include "dim-vector.h"
32 
33 class
34 OCTAVE_API
36 {
37 protected:
38 
39  octave_fftw_planner (void);
40 
41 public:
42 
43  ~octave_fftw_planner (void);
44 
46  {
47  UNKNOWN = -1,
52  HYBRID
53  };
54 
55  static bool instance_ok (void);
56 
57  static void *
58  create_plan (int dir, const int rank, const dim_vector dims,
59  octave_idx_type howmany, octave_idx_type stride,
60  octave_idx_type dist, const Complex *in,
61  Complex *out)
62  {
63  return instance_ok ()
64  ? instance->do_create_plan (dir, rank, dims, howmany, stride,
65  dist, in, out)
66  : 0;
67  }
68 
69  static void *
70  create_plan (const int rank, const dim_vector dims,
71  octave_idx_type howmany, octave_idx_type stride,
72  octave_idx_type dist, const double *in, Complex *out)
73  {
74  return instance_ok ()
75  ? instance->do_create_plan (rank, dims, howmany, stride, dist,
76  in, out)
77  : 0;
78  }
79 
80  static FftwMethod method (void)
81  {
82  static FftwMethod dummy;
83 
84  return instance_ok () ? instance->do_method () : dummy;
85  }
86 
87  static FftwMethod method (FftwMethod _meth)
88  {
89  static FftwMethod dummy;
90 
91  return instance_ok () ? instance->do_method (_meth) : dummy;
92  }
93 
94  static void threads (int nt);
95 
96  static int threads (void)
97  {
98  return instance_ok () ? instance->nthreads : 0;
99  }
100 
101 private:
102 
103  // No copying!
104 
106 
107  octave_fftw_planner& operator = (const octave_fftw_planner&);
108 
110 
111  static void cleanup_instance (void) { delete instance; instance = 0; }
112 
113  void *
114  do_create_plan (int dir, const int rank, const dim_vector dims,
115  octave_idx_type howmany, octave_idx_type stride,
116  octave_idx_type dist, const Complex *in,
117  Complex *out);
118 
119  void *
120  do_create_plan (const int rank, const dim_vector dims,
121  octave_idx_type howmany, octave_idx_type stride,
122  octave_idx_type dist, const double *in, Complex *out);
123 
124  FftwMethod do_method (void);
125 
126  FftwMethod do_method (FftwMethod _meth);
127 
129 
130  // FIXME: perhaps this should be split into two classes?
131 
132  // Plan for fft and ifft of complex values
133  void *plan[2];
134 
135  // dist
137 
138  // stride
140 
141  // rank
142  int r[2];
143 
144  // howmany
146 
147  // dims
149 
150  bool simd_align[2];
151  bool inplace[2];
152 
153  // Plan for fft of real values
154  void *rplan;
155 
156  // dist
158 
159  // stride
161 
162  // rank
163  int rr;
164 
165  // howmany
167 
168  // dims
170 
172 
173  // number of threads. Always 1 unless compiled with multi-threading
174  // support.
175  int nthreads;
176 };
177 
178 class
179 OCTAVE_API
181 {
182 protected:
183 
185 
186 public:
187 
189 
191  {
192  UNKNOWN = -1,
197  HYBRID
198  };
199 
200  static bool instance_ok (void);
201 
202  static void *
203  create_plan (int dir, const int rank, const dim_vector dims,
204  octave_idx_type howmany, octave_idx_type stride,
205  octave_idx_type dist, const FloatComplex *in,
206  FloatComplex *out)
207  {
208  return instance_ok ()
209  ? instance->do_create_plan (dir, rank, dims, howmany, stride,
210  dist, in, out)
211  : 0;
212  }
213 
214  static void *
215  create_plan (const int rank, const dim_vector dims,
216  octave_idx_type howmany, octave_idx_type stride,
217  octave_idx_type dist, const float *in, FloatComplex *out)
218  {
219  return instance_ok ()
220  ? instance->do_create_plan (rank, dims, howmany, stride, dist,
221  in, out)
222  : 0;
223  }
224 
225  static FftwMethod method (void)
226  {
227  static FftwMethod dummy;
228 
229  return instance_ok () ? instance->do_method () : dummy;
230  }
231 
232  static FftwMethod method (FftwMethod _meth)
233  {
234  static FftwMethod dummy;
235 
236  return instance_ok () ? instance->do_method (_meth) : dummy;
237  }
238 
239  static void threads (int nt);
240 
241  static int threads (void)
242  {
243  return instance_ok () ? instance->nthreads : 0;
244  }
245 
246 private:
247 
248  // No copying!
249 
251 
253 
255 
256  static void cleanup_instance (void) { delete instance; instance = 0; }
257 
258  void *
259  do_create_plan (int dir, const int rank, const dim_vector dims,
260  octave_idx_type howmany, octave_idx_type stride,
261  octave_idx_type dist, const FloatComplex *in,
262  FloatComplex *out);
263 
264  void *
265  do_create_plan (const int rank, const dim_vector dims,
266  octave_idx_type howmany, octave_idx_type stride,
267  octave_idx_type dist, const float *in, FloatComplex *out);
268 
269  FftwMethod do_method (void);
270 
271  FftwMethod do_method (FftwMethod _meth);
272 
274 
275  // FIXME: perhaps this should be split into two classes?
276 
277  // Plan for fft and ifft of complex values
278  void *plan[2];
279 
280  // dist
282 
283  // stride
285 
286  // rank
287  int r[2];
288 
289  // howmany
291 
292  // dims
294 
295  bool simd_align[2];
296  bool inplace[2];
297 
298  // Plan for fft of real values
299  void *rplan;
300 
301  // dist
303 
304  // stride
306 
307  // rank
308  int rr;
309 
310  // howmany
312 
313  // dims
315 
317 
318  // number of threads. Always 1 unless compiled with multi-threading
319  // support.
320  int nthreads;
321 };
322 
323 class
324 OCTAVE_API
326 {
327 public:
328 
329  static int fft (const double *in, Complex *out, size_t npts,
330  size_t nsamples = 1, octave_idx_type stride = 1,
331  octave_idx_type dist = -1);
332  static int fft (const Complex *in, Complex *out, size_t npts,
333  size_t nsamples = 1, octave_idx_type stride = 1,
334  octave_idx_type dist = -1);
335  static int ifft (const Complex *in, Complex *out, size_t npts,
336  size_t nsamples = 1, octave_idx_type stride = 1,
337  octave_idx_type dist = -1);
338 
339  static int fftNd (const double*, Complex*, const int, const dim_vector &);
340  static int fftNd (const Complex*, Complex*, const int,
341  const dim_vector &);
342  static int ifftNd (const Complex*, Complex*, const int,
343  const dim_vector &);
344 
345  static int fft (const float *in, FloatComplex *out, size_t npts,
346  size_t nsamples = 1, octave_idx_type stride = 1,
347  octave_idx_type dist = -1);
348  static int fft (const FloatComplex *in, FloatComplex *out, size_t npts,
349  size_t nsamples = 1, octave_idx_type stride = 1,
350  octave_idx_type dist = -1);
351  static int ifft (const FloatComplex *in, FloatComplex *out, size_t npts,
352  size_t nsamples = 1, octave_idx_type stride = 1,
353  octave_idx_type dist = -1);
354 
355  static int fftNd (const float*, FloatComplex*, const int, const dim_vector &);
356  static int fftNd (const FloatComplex*, FloatComplex*, const int,
357  const dim_vector &);
358  static int ifftNd (const FloatComplex*, FloatComplex*, const int,
359  const dim_vector &);
360 
361 private:
362  octave_fftw (void);
363  octave_fftw (const octave_fftw&);
364  octave_fftw& operator = (const octave_fftw&);
365 };
366 
367 extern OCTAVE_API std::string octave_fftw_version (void);
368 extern OCTAVE_API std::string octave_fftwf_version (void);
369 
370 #endif
static octave_fftw_planner * instance
Definition: oct-fftw.h:109
static FftwMethod method(FftwMethod _meth)
Definition: oct-fftw.h:232
static octave_float_fftw_planner * instance
Definition: oct-fftw.h:254
static void * create_plan(const int rank, const dim_vector dims, octave_idx_type howmany, octave_idx_type stride, octave_idx_type dist, const double *in, Complex *out)
Definition: oct-fftw.h:70
s
Definition: file-io.cc:2682
static int threads(void)
Definition: oct-fftw.h:241
octave_idx_type rs
Definition: oct-fftw.h:160
static FftwMethod method(void)
Definition: oct-fftw.h:80
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
static void * create_plan(int dir, const int rank, const dim_vector dims, octave_idx_type howmany, octave_idx_type stride, octave_idx_type dist, const Complex *in, Complex *out)
Definition: oct-fftw.h:58
double h
Definition: graphics.cc:11205
octave_idx_type rh
Definition: oct-fftw.h:166
static FftwMethod method(void)
Definition: oct-fftw.h:225
static void * create_plan(int dir, const int rank, const dim_vector dims, octave_idx_type howmany, octave_idx_type stride, octave_idx_type dist, const FloatComplex *in, FloatComplex *out)
Definition: oct-fftw.h:203
static int threads(void)
Definition: oct-fftw.h:96
the exceeded dimensions are set to if fewer subscripts than dimensions are the exceeding dimensions are merged into the final requested dimension For consider the following dims
Definition: sub2ind.cc:255
octave_idx_type rs
Definition: oct-fftw.h:305
octave_idx_type rd
Definition: oct-fftw.h:157
static FftwMethod method(FftwMethod _meth)
Definition: oct-fftw.h:87
FftwMethod meth
Definition: oct-fftw.h:128
dim_vector rn
Definition: oct-fftw.h:169
OCTAVE_API std::string octave_fftwf_version(void)
Definition: oct-fftw.cc:1148
static void * create_plan(const int rank, const dim_vector dims, octave_idx_type howmany, octave_idx_type stride, octave_idx_type dist, const float *in, FloatComplex *out)
Definition: oct-fftw.h:215
OCTAVE_API std::string octave_fftw_version(void)
Definition: oct-fftw.cc:1138
std::complex< float > FloatComplex
Definition: oct-cmplx.h:32
std::complex< double > Complex
Definition: oct-cmplx.h:31
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:854
octave_idx_type rh
Definition: oct-fftw.h:311
static void cleanup_instance(void)
Definition: oct-fftw.h:256
octave_idx_type rd
Definition: oct-fftw.h:302
static void cleanup_instance(void)
Definition: oct-fftw.h:111