MFFM FFTw Wrapper
Main Page
Classes
Files
Examples
File List
complexFFT.H
1
/* Copyright 2001,2002 Matt Flax <flatmax@ieee.org>
2
This file is part of the MFFM FFTw Wrapper library.
3
4
MFFM MFFM FFTw Wrapper library is free software; you can
5
redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2 of the License, or
8
(at your option) any later version.
9
10
MFFM FFTw Wrapper library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You have received a copy of the GNU General Public License
16
along with the MFFM FFTw Wrapper library
17
*/
18
#ifndef COMPLEXFFT_H_
19
#define COMPLEXFFT_H_
20
21
#include <fftw3.h>
22
23
#ifndef fftw_real
24
#define fftw_real double
25
#endif
26
#define c_re(c) ((c)[0])
27
#define c_im(c) ((c)[1])
28
29
#include <iomanip>
30
using namespace
std;
31
32
#define PLANTYPE FFTW_ESTIMATE
33
34
/// class complexFFTData controls and manipulates complex fft data
35
class
complexFFTData
{
36
public
:
37
/// Specifies the size of the data array
38
int
size
;
39
/// the input and output arrays
40
fftw_complex *
in
, *out;
41
/// the power_spectrum array
42
fftw_real *
power_spectrum
;
43
/// The total power (summed) of the power spectrum as used in the method compPowerSpec
44
double
totalPower
;
45
46
/// Constructor with all memory to be allocated internally
47
complexFFTData
(
int
sz);
48
/// Deconstructor
49
~
complexFFTData
(
void
);
50
51
/// Use this to change associated fft data (for fft'ing)
52
void
switchData(
complexFFTData
*d);
53
54
/// Limits the maximum to 'lim' and returns the last fft bin with max
55
int
limitHalfPowerSpec(
double
lim);
56
57
/// Returns the number of elements in the input and output arrays
58
int
getSize
(){
return
size;}
59
// int getHalfSize(){ if (!(size%2)) return size/2; else return size/2+1;}
60
61
/// This function computes the power spectrum and returns the max bin
62
int
compPowerSpec();
63
// int powerSpecDeriv(); // Find the derivative of the power spectrum
64
};
65
66
///class complexFFT controls fftw plans and executes fwd/inv transforms
67
class
complexFFT
{
68
/// The fwd/inv plans
69
fftw_plan fwdPlan, invPlan;
70
/// Method to create the plans
71
void
createPlan(
void
);
72
/// Method to destroy the plans
73
void
destroyPlan(
void
);
74
protected
:
75
// int size;
76
/// The pointer to the relevant data
77
complexFFTData
*
data
;
78
public
:
79
80
// complexFFT(int sz, char *ws=NULL);
81
/// fft init ... data pointed to by 'd'
82
complexFFT
(
complexFFTData
*d);
83
/// fft deconstructor
84
~
complexFFT
();
85
86
/// Use this to change associated fft data (for fft'ing)
87
void
switchData(
complexFFTData
*d);
88
89
/// Forward transform the data (in to out)
90
void
fwdTransform();
// Forward fft
91
/// Inverse transform the data (out to in)
92
void
invTransform();
// Inverse fft
93
};
94
/** \example complexFFTExample.cc
95
* This is an example of how to use the class.
96
*/
97
#endif // COMPLEXFFT_H_
Generated on Mon Dec 10 2012 18:06:14 for MFFM FFTw Wrapper by
1.8.2