1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MFFM FFTw Wrapper: real2DFFT.H Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
</ul>
</div>
<h1>real2DFFT.H</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* Copyright 2001,2002 Matt Flax <flatmax@ieee.org></span>
<a name="l00002"></a>00002 <span class="comment"> This file is part of the MFFM FFTw Wrapper library.</span>
<a name="l00003"></a>00003 <span class="comment"></span>
<a name="l00004"></a>00004 <span class="comment"> MFFM MFFM FFTw Wrapper library is free software; you can </span>
<a name="l00005"></a>00005 <span class="comment"> redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment"> it under the terms of the GNU General Public License as published by</span>
<a name="l00007"></a>00007 <span class="comment"> the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment"> (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment"> </span>
<a name="l00010"></a>00010 <span class="comment"> MFFM FFTw Wrapper library is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00013"></a>00013 <span class="comment"> GNU General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment"> </span>
<a name="l00015"></a>00015 <span class="comment"> You have received a copy of the GNU General Public License</span>
<a name="l00016"></a>00016 <span class="comment"> along with the MFFM FFTw Wrapper library</span>
<a name="l00017"></a>00017 <span class="comment">*/</span>
<a name="l00018"></a>00018 <span class="preprocessor">#ifndef REAL2DFFT_H_</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span><span class="preprocessor">#define REAL2DFFT_H_</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span>
<a name="l00021"></a>00021 <span class="preprocessor">#include <string.h></span>
<a name="l00022"></a>00022
<a name="l00023"></a>00023 <span class="preprocessor">#include <fftw3.h></span>
<a name="l00024"></a>00024 <span class="preprocessor">#ifndef fftw_real</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span><span class="preprocessor">#define fftw_real double</span>
<a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span><span class="preprocessor">#define c_re(c) ((c)[0])</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#define c_im(c) ((c)[1])</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span>
<a name="l00030"></a>00030 <span class="preprocessor">#include <iomanip></span>
<a name="l00031"></a>00031 <span class="keyword">using namespace </span>std;
<a name="l00032"></a>00032
<a name="l00033"></a>00033 <span class="preprocessor">#define PLANTYPE FFTW_ESTIMATE</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00035"></a>00035 <span class="comment">/// class real2DFFTData controls and manipulates real 2D fft data</span>
<a name="l00036"></a><a class="code" href="classreal2DFFTData.html">00036</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="classreal2DFFTData.html" title="class real2DFFTData controls and manipulates real 2D fft data">real2DFFTData</a> {<span class="comment"></span>
<a name="l00037"></a>00037 <span class="comment"> /// x=row y=column</span>
<a name="l00038"></a>00038 <span class="comment"></span> <span class="keywordtype">int</span> x, y;<span class="comment"></span>
<a name="l00039"></a>00039 <span class="comment"> /// The total memory used by this class</span>
<a name="l00040"></a>00040 <span class="comment"></span> fftw_real *mem;<span class="comment"></span>
<a name="l00041"></a>00041 <span class="comment"> /// Free the memory</span>
<a name="l00042"></a>00042 <span class="comment"></span> <span class="keywordtype">void</span> memDeInit(<span class="keywordtype">void</span>);
<a name="l00043"></a>00043 <span class="keyword">public</span>:<span class="comment"></span>
<a name="l00044"></a>00044 <span class="comment"> /// The input data and power spectrum</span>
<a name="l00045"></a><a class="code" href="classreal2DFFTData.html#aee22ddba7091e4c0a964b7aeb0a7a9d0">00045</a> <span class="comment"></span> fftw_real *<a class="code" href="classreal2DFFTData.html#aee22ddba7091e4c0a964b7aeb0a7a9d0" title="The input data and power spectrum.">in</a>, *power;<span class="comment"></span>
<a name="l00046"></a>00046 <span class="comment"> /// The output data</span>
<a name="l00047"></a><a class="code" href="classreal2DFFTData.html#ad843e1854cbc66973c1d8cec245f89fb">00047</a> <span class="comment"></span> fftw_complex *<a class="code" href="classreal2DFFTData.html#ad843e1854cbc66973c1d8cec245f89fb" title="The output data.">out</a>;<span class="comment"></span>
<a name="l00048"></a>00048 <span class="comment"> /// Arrays which sum across rows (x) and columns (y)</span>
<a name="l00049"></a><a class="code" href="classreal2DFFTData.html#a28a3d5aee1db4d73220ed40e4ea375f3">00049</a> <span class="comment"></span> fftw_real *<a class="code" href="classreal2DFFTData.html#a28a3d5aee1db4d73220ed40e4ea375f3" title="Arrays which sum across rows (x) and columns (y).">xSum</a>, *ySum;<span class="comment"></span>
<a name="l00050"></a>00050 <span class="comment"> /// A sum across the input time signal</span>
<a name="l00051"></a><a class="code" href="classreal2DFFTData.html#af4f6d73d8e8253f3214746924f3c6a76">00051</a> <span class="comment"></span> fftw_real *<a class="code" href="classreal2DFFTData.html#af4f6d73d8e8253f3214746924f3c6a76" title="A sum across the input time signal.">timeXSum</a>;<span class="comment"></span>
<a name="l00052"></a>00052 <span class="comment"> /// Power spectral sums across rows (x) and columns (y)</span>
<a name="l00053"></a><a class="code" href="classreal2DFFTData.html#a63acc55247bb735f33ce8eea2ecdd2d3">00053</a> <span class="comment"></span> fftw_real *<a class="code" href="classreal2DFFTData.html#a63acc55247bb735f33ce8eea2ecdd2d3" title="Power spectral sums across rows (x) and columns (y).">realXSum</a>, *imagXSum;
<a name="l00054"></a>00054 <span class="comment"></span>
<a name="l00055"></a>00055 <span class="comment"> /// The total power in the power spectrum, the maximum and minimum powers too</span>
<a name="l00056"></a><a class="code" href="classreal2DFFTData.html#a3cd2940771fcde698d5f7cfb8253e63b">00056</a> <span class="comment"></span> <span class="keywordtype">double</span> <a class="code" href="classreal2DFFTData.html#a3cd2940771fcde698d5f7cfb8253e63b" title="The total power in the power spectrum, the maximum and minimum powers too.">totalPower</a>, maxPower, minPower;<span class="comment"></span>
<a name="l00057"></a>00057 <span class="comment"> /// The minimum/maximum row (x) and column (y) sums</span>
<a name="l00058"></a><a class="code" href="classreal2DFFTData.html#aa9311c5ec231402c7aa1fff9bdd7036d">00058</a> <span class="comment"></span> <span class="keywordtype">double</span> <a class="code" href="classreal2DFFTData.html#aa9311c5ec231402c7aa1fff9bdd7036d" title="The minimum/maximum row (x) and column (y) sums.">xSumMin</a>, xSumMax, ySumMin, ySumMax;<span class="comment"></span>
<a name="l00059"></a>00059 <span class="comment"> /// Row (x) and Column (y) max sum indexes</span>
<a name="l00060"></a><a class="code" href="classreal2DFFTData.html#aab67a8c32bc2d288d7180c2e5122b84d">00060</a> <span class="comment"></span> <span class="keywordtype">int</span> <a class="code" href="classreal2DFFTData.html#aab67a8c32bc2d288d7180c2e5122b84d" title="Row (x) and Column (y) max sum indexes.">maxXSumIndex</a>, maxYSumIndex;
<a name="l00061"></a>00061 <span class="comment"></span>
<a name="l00062"></a>00062 <span class="comment"> /// Constructor with all memory to be allocated internally</span>
<a name="l00063"></a>00063 <span class="comment"></span> <a class="code" href="classreal2DFFTData.html#ad1c236952306fcead4c74b08a9ecdbbc" title="Constructor with all memory to be allocated internally.">real2DFFTData</a>(<span class="keywordtype">int</span> r, <span class="keywordtype">int</span> c);<span class="comment"></span>
<a name="l00064"></a>00064 <span class="comment"> /// Deconstructor</span>
<a name="l00065"></a>00065 <span class="comment"></span> <a class="code" href="classreal2DFFTData.html#aa31e47d5f92fddb65e1ac79abe564d76" title="Deconstructor.">~real2DFFTData</a>();
<a name="l00066"></a>00066 <span class="comment"></span>
<a name="l00067"></a>00067 <span class="comment"> /// The row count</span>
<a name="l00068"></a><a class="code" href="classreal2DFFTData.html#a0f7050e9cf0270ea0f15f4b8399c2d57">00068</a> <span class="comment"></span> <span class="keywordtype">int</span> <a class="code" href="classreal2DFFTData.html#a0f7050e9cf0270ea0f15f4b8399c2d57" title="The row count.">getXSize</a>(){<span class="keywordflow">return</span> x;}<span class="comment"></span>
<a name="l00069"></a>00069 <span class="comment"> /// The column count</span>
<a name="l00070"></a><a class="code" href="classreal2DFFTData.html#a6cc42bdfe90c9ba98101abf70b378e37">00070</a> <span class="comment"></span> <span class="keywordtype">int</span> <a class="code" href="classreal2DFFTData.html#a6cc42bdfe90c9ba98101abf70b378e37" title="The column count.">getYSize</a>(){<span class="keywordflow">return</span> y;}<span class="comment"></span>
<a name="l00071"></a>00071 <span class="comment"> /// The half row count</span>
<a name="l00072"></a><a class="code" href="classreal2DFFTData.html#acfee72c9266bcda29fe4f0322c0664ff">00072</a> <span class="comment"></span> <span class="keywordtype">int</span> <a class="code" href="classreal2DFFTData.html#acfee72c9266bcda29fe4f0322c0664ff" title="The half row count.">getXHalfSize</a>(){ <span class="keywordflow">if</span> (!(x%2)) <span class="keywordflow">return</span> x/2; <span class="keywordflow">else</span> <span class="keywordflow">return</span> x/2+1;}<span class="comment"></span>
<a name="l00073"></a>00073 <span class="comment"> /// The half column count</span>
<a name="l00074"></a><a class="code" href="classreal2DFFTData.html#ac0ee77426523ff06dc4cdaba91d2f330">00074</a> <span class="comment"></span> <span class="keywordtype">int</span> <a class="code" href="classreal2DFFTData.html#ac0ee77426523ff06dc4cdaba91d2f330" title="The half column count.">getYHalfSize</a>(){ <span class="keywordflow">if</span> (!(y%2)) <span class="keywordflow">return</span> y/2; <span class="keywordflow">else</span> <span class="keywordflow">return</span> y/2+1;}
<a name="l00075"></a>00075 <span class="comment"></span>
<a name="l00076"></a>00076 <span class="comment"> /// Scales the output down by the number of elements</span>
<a name="l00077"></a>00077 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classreal2DFFTData.html#a77b3acac87b8920b1f2700eb85d4e466" title="Scales the output down by the number of elements.">reScale</a>(<span class="keywordtype">void</span>);<span class="comment"></span>
<a name="l00078"></a>00078 <span class="comment"> /// This function computes the power spectrum and updates the totalPower, maxPower and minPower</span>
<a name="l00079"></a>00079 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classreal2DFFTData.html#a8768cf3a25b1b89b5ea6c8727126cf44" title="This function computes the power spectrum and updates the totalPower, maxPower and...">compPowerSpec</a>(); <span class="comment">// Find the power spectrum</span><span class="comment"></span>
<a name="l00080"></a>00080 <span class="comment"> /// Finds 10*log10(power spectrum) and updates the totalPower, maxPower and minPower</span>
<a name="l00081"></a>00081 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classreal2DFFTData.html#ad095e4ce09a821659eec532eb9da5a09" title="Finds 10*log10(power spectrum) and updates the totalPower, maxPower and minPower...">compLogPowerSpec</a>(); <span class="comment">// Find the log power spectrum</span>
<a name="l00082"></a>00082 <span class="comment"></span>
<a name="l00083"></a>00083 <span class="comment"> /// Updates timeXSum</span>
<a name="l00084"></a>00084 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classreal2DFFTData.html#a9b1ecff5d07fb6b7d529562d5a679a3a" title="Updates timeXSum.">timeSpecAverage</a>();<span class="comment"></span>
<a name="l00085"></a>00085 <span class="comment"> /// Updates realXSum and imagXSum</span>
<a name="l00086"></a>00086 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classreal2DFFTData.html#af35d16aa01b5988c90c62dc1380eee8b" title="Updates realXSum and imagXSum.">complexSpecAverage</a>();<span class="comment"></span>
<a name="l00087"></a>00087 <span class="comment"> /// Finds the power Spectrum averages and </span>
<a name="l00088"></a>00088 <span class="comment"> /// updates the xSumMin, xSumMax, ySumMin, ySumMax, xSum, ySum, maxXSumIndex, maxYSumIndex</span>
<a name="l00089"></a>00089 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classreal2DFFTData.html#aaa9e52745862dd84230b3b606f14562a">powerSpecAverage</a>();<span class="comment"></span>
<a name="l00090"></a>00090 <span class="comment"> /// Finds the y-sum between columns start and stop</span>
<a name="l00091"></a>00091 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classreal2DFFTData.html#a9191df160ac56af766edcd35518e94e6" title="Finds the y-sum between columns start and stop.">findYSum</a>(<span class="keywordtype">int</span> start, <span class="keywordtype">int</span> stop);<span class="comment"></span>
<a name="l00092"></a>00092 <span class="comment"> /// Finds the y-max for the ySum array, updates ySumMin, ySumMax, maxYSumIndex</span>
<a name="l00093"></a>00093 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classreal2DFFTData.html#ae1b265e4b8671d81ed00f4d8783a342d" title="Finds the y-max for the ySum array, updates ySumMin, ySumMax, maxYSumIndex.">findYMax</a>(<span class="keywordtype">void</span>);
<a name="l00094"></a>00094 <span class="comment"></span>
<a name="l00095"></a>00095 <span class="comment"> /// Zeros the in array</span>
<a name="l00096"></a><a class="code" href="classreal2DFFTData.html#abb4fbda6a7111741c130f22dede76828">00096</a> <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classreal2DFFTData.html#abb4fbda6a7111741c130f22dede76828" title="Zeros the in array.">clearInput</a>(<span class="keywordtype">void</span>){memset(<a class="code" href="classreal2DFFTData.html#aee22ddba7091e4c0a964b7aeb0a7a9d0" title="The input data and power spectrum.">in</a>, 0, x*2*(y/2+1)*<span class="keyword">sizeof</span>(fftw_real));}<span class="comment"></span>
<a name="l00097"></a>00097 <span class="comment"> /// Zeros the out awway</span>
<a name="l00098"></a><a class="code" href="classreal2DFFTData.html#a7de72cd88625f3f4383beefb869b5fd0">00098</a> <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classreal2DFFTData.html#a7de72cd88625f3f4383beefb869b5fd0" title="Zeros the out awway.">clearOutput</a>(<span class="keywordtype">void</span>){memset(<a class="code" href="classreal2DFFTData.html#ad843e1854cbc66973c1d8cec245f89fb" title="The output data.">out</a>, 0, x*(y/2+1)*<span class="keyword">sizeof</span>(fftw_complex));}
<a name="l00099"></a>00099 };
<a name="l00100"></a>00100 <span class="comment"></span>
<a name="l00101"></a>00101 <span class="comment">///class real2DFFT controls fftw plans and executes fwd/inv transforms</span>
<a name="l00102"></a><a class="code" href="classreal2DFFT.html">00102</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="classreal2DFFT.html" title="class real2DFFT controls fftw plans and executes fwd/inv transforms">real2DFFT</a> {<span class="comment"></span>
<a name="l00103"></a>00103 <span class="comment"> /// The forward and inverse plans</span>
<a name="l00104"></a>00104 <span class="comment"></span> fftw_plan fwdPlan, invPlan;
<a name="l00105"></a>00105 <span class="keyword">protected</span>:<span class="comment"></span>
<a name="l00106"></a>00106 <span class="comment"> /// The pointer to the relevant data</span>
<a name="l00107"></a><a class="code" href="classreal2DFFT.html#adb59e52cfc1afbc9acdf6156da0a96a6">00107</a> <span class="comment"></span> <a class="code" href="classreal2DFFTData.html" title="class real2DFFTData controls and manipulates real 2D fft data">real2DFFTData</a> *<a class="code" href="classreal2DFFT.html#adb59e52cfc1afbc9acdf6156da0a96a6" title="The pointer to the relevant data.">data</a>;
<a name="l00108"></a>00108 <span class="keyword">public</span>:<span class="comment"></span>
<a name="l00109"></a>00109 <span class="comment"> /// fft init ... data pointed to by 'd'</span>
<a name="l00110"></a>00110 <span class="comment"></span> <a class="code" href="classreal2DFFT.html#aa9b8a26d327d07753077ab227344f225" title="fft init ... data pointed to by &#39;d&#39;">real2DFFT</a>(<a class="code" href="classreal2DFFTData.html" title="class real2DFFTData controls and manipulates real 2D fft data">real2DFFTData</a> *d);<span class="comment"></span>
<a name="l00111"></a>00111 <span class="comment"> /// fft deconstructor</span>
<a name="l00112"></a>00112 <span class="comment"></span> <a class="code" href="classreal2DFFT.html#addbf0dd16834d1bcb97dc4c08c01e635" title="fft deconstructor">~real2DFFT</a>();
<a name="l00113"></a>00113 <span class="comment"></span>
<a name="l00114"></a>00114 <span class="comment"> /// Forward transform the data (in to out)</span>
<a name="l00115"></a>00115 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classreal2DFFT.html#a3f4d33763292c212de65dd197f226fdf" title="Forward transform the data (in to out).">fwdTransform</a>(); <span class="comment">// Forward 2D fft</span><span class="comment"></span>
<a name="l00116"></a>00116 <span class="comment"> /// Inverse transform the data (out to in)</span>
<a name="l00117"></a>00117 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classreal2DFFT.html#ad90b1e857721789e73c1ed5a9b4c0017" title="Inverse transform the data (out to in).">invTransform</a>(); <span class="comment">// Inverse 2D fft</span>
<a name="l00118"></a>00118 };<span class="comment"></span>
<a name="l00119"></a>00119 <span class="comment">/** \example real2DFFTExample.cc</span>
<a name="l00120"></a>00120 <span class="comment"> * This is an example of how to use the class.</span>
<a name="l00121"></a>00121 <span class="comment"> */</span>
<a name="l00122"></a>00122 <span class="preprocessor">#endif // REAL2DFFT_H_</span>
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on Thu Dec 17 00:32:35 2009 for MFFM FFTw Wrapper by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>
|