gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
ComplexFFT.H
Go to the documentation of this file.
1 /* Copyright 2000-2018 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream 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  GTK+ IOStream 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 have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16 */
17 #ifndef COMPLEXFFT_H_
18 #define COMPLEXFFT_H_
19 
20 #include "fft/FFTCommon.H"
21 #include "fft/ComplexFFTData.H"
22 
23 //class ComplexFFTData;
24 
26 class ComplexFFT {
28  fftw_plan fwdPlan, invPlan;
30  void createPlan(void){
31  if (data){
32  //fftw3
33  fwdPlan = fftw_plan_dft_1d(data->getSize(), data->in, data->out, FFTW_FORWARD, PLANTYPE);
34  invPlan = fftw_plan_dft_1d(data->getSize(), data->out, data->in, FFTW_BACKWARD, PLANTYPE);
35  }
36 }
37 
39  void destroyPlan(void){
40  if (data){
41  fftw_destroy_plan(fwdPlan);
42  fftw_destroy_plan(invPlan);
43  }
44 }
45 
46 protected:
47  // int size;
50 public:
51 
54  // std::cout <<"ComplexFFT init:"<<this<<std::endl;
55  data=d;
56  createPlan();
57 }
58 
60  virtual ~ComplexFFT(){
61  destroyPlan();
62 }
63 
64 
67  //fftw_cleanup();
68  destroyPlan();
69  data=d;
70  createPlan();
71 }
72 
73 
75  void fwdTransform(){
76  if (!data)
77  printf("ComplexFFT::fwdTransform : data not present, please switch data\n");
78  else
79  fftw_execute(fwdPlan);
80  /*fftw_execute_dft(
81  fwdPlan,
82  data->in, data->out);
83 
84  }*/
85 }
86 
87 
89  void invTransform(){
90  if (!data)
91  printf("ComplexFFT::invTransform : data not present, please switch data\n");
92  else
93  fftw_execute(invPlan);
94  /*fftw_execute_dft(
95  invPlan,
96  data->in, data->out);
97 
98  }*/
99 }
100 
101 };
105 #endif // COMPLEXFFT_H_
#define PLANTYPE
Definition: FFTCommon.H:20
fftw_complex * out
void destroyPlan(void)
Method to destroy the plans.
Definition: ComplexFFT.H:39
ComplexFFT(ComplexFFTData *d)
fft init ... data pointed to by &#39;d&#39;
Definition: ComplexFFT.H:53
ComplexFFTData * data
The pointer to the relevant data.
Definition: ComplexFFT.H:49
class ComplexFFT controls fftw plans and executes fwd/inv transforms
Definition: ComplexFFT.H:26
virtual ~ComplexFFT()
fft deconstructor
Definition: ComplexFFT.H:60
fftw_plan invPlan
Definition: ComplexFFT.H:28
void invTransform()
Inverse transform the data (out to in)
Definition: ComplexFFT.H:89
fftw_complex * in
the input and output arrays
void switchData(ComplexFFTData *d)
Use this to change associated fft data (for fft&#39;ing)
Definition: ComplexFFT.H:66
int getSize()
Returns the number of elements in the input and output arrays.
void createPlan(void)
Method to create the plans.
Definition: ComplexFFT.H:30
void fwdTransform()
Forward transform the data (in to out)
Definition: ComplexFFT.H:75
fftw_plan fwdPlan
The fwd/inv plans.
Definition: ComplexFFT.H:28
class ComplexFFTData controls and manipulates complex fft data
gtkIOStream: /tmp/gtkiostream/include/fft/ComplexFFT.H Source File
GTK+ IOStream  Beta