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
|
<!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: complexFFTExample.cc</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><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>complexFFTExample.cc</h1><p>This is an example of how to use the class.</p>
<div class="fragment"><pre class="fragment"><span class="comment">/* Copyright 2001,2002 Matt Flax <flatmax@ieee.org></span>
<span class="comment"> This file is part of the MFFM FFTw Wrapper library.</span>
<span class="comment"></span>
<span class="comment"> MFFM MFFM FFTw Wrapper library is free software; you can </span>
<span class="comment"> redistribute it and/or modify</span>
<span class="comment"> it under the terms of the GNU General Public License as published by</span>
<span class="comment"> the Free Software Foundation; either version 2 of the License, or</span>
<span class="comment"> (at your option) any later version.</span>
<span class="comment"> </span>
<span class="comment"> MFFM FFTw Wrapper library is distributed in the hope that it will be useful,</span>
<span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<span class="comment"> GNU General Public License for more details.</span>
<span class="comment"> </span>
<span class="comment"> You have received a copy of the GNU General Public License</span>
<span class="comment"> along with the MFFM FFTw Wrapper library</span>
<span class="comment">*/</span>
<span class="preprocessor">#include <fstream></span>
<span class="preprocessor">#include <iostream></span>
<span class="keyword">using namespace </span>std;
<span class="preprocessor">#include "complexFFT.H"</span>
<span class="comment">//#include <iomanip.h></span>
<span class="keywordtype">int</span> main (){
<span class="keywordtype">int</span> count =8;
<a name="_a0"></a><a class="code" href="classcomplexFFTData.html" title="class complexFFTData controls and manipulates complex fft data">complexFFTData</a> fftData(count);
<a name="_a1"></a><a class="code" href="classcomplexFFT.html" title="class complexFFT controls fftw plans and executes fwd/inv transforms">complexFFT</a> fft(&fftData);
<span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0;i<count;i++){
c_re(fftData.<a name="a2"></a><a class="code" href="classcomplexFFTData.html#a1d0e919466631bb9c40339a6cb53925e" title="the input and output arrays">in</a>[i])=(double)i;
<span class="comment">// fftData.in[i].im=(double)-i;</span>
c_im(fftData.<a class="code" href="classcomplexFFTData.html#a1d0e919466631bb9c40339a6cb53925e" title="the input and output arrays">in</a>[i])=(double)i+5.0;
}
fftw_real *temp=&c_re(fftData.<a class="code" href="classcomplexFFTData.html#a1d0e919466631bb9c40339a6cb53925e" title="the input and output arrays">in</a>[0]);
<span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i<count; i++)
cout << temp[i]<<endl;
<span class="comment">// forward transform :</span>
fft.<a name="a3"></a><a class="code" href="classcomplexFFT.html#a2cc76318664e524b70aade4d57b5f1a2" title="Forward transform the data (in to out).">fwdTransform</a>();
<span class="comment">// inverse transform :</span>
fft.<a name="a4"></a><a class="code" href="classcomplexFFT.html#ac83e61199195800b7a97ee3e8a9cfa5e" title="Inverse transform the data (out to in).">invTransform</a>();
<span class="comment">// for (int i=0; i<count; i++)</span>
<span class="comment">// cout << fftData.in[i].re<<' '<<fftData.in[i].im<<endl;</span>
<span class="comment">// Find the power spectrum ...</span>
fftData.<a name="a5"></a><a class="code" href="classcomplexFFTData.html#a96f361cf90565d27dbfa7c82527783d6" title="This function computes the power spectrum and returns the max bin.">compPowerSpec</a>();
<span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i<count; i++)
cout << fftData.<a name="a6"></a><a class="code" href="classcomplexFFTData.html#a7a5a433a16ad31e04adee9833da51ebe" title="the power_spectrum array">power_spectrum</a>[i]<<endl;
}
</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>
|