Documentation for 8b1eab204b

This commit is contained in:
realstealthninja
2024-11-04 12:43:05 +00:00
parent 4fb6e622e9
commit a7bccf7d01
6732 changed files with 153919 additions and 365711 deletions

View File

@@ -1,3 +1,4 @@
<!-- HTML header for doxygen 1.12.0-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
@@ -5,10 +6,15 @@
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C++: numerical_methods/fast_fourier_transform.cpp File Reference</title>
<title>TheAlgorithms/C++: numerical_methods/fast_fourier_transform.cpp File Reference</title>
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
<script type="text/javascript">
DoxygenAwesomeDarkModeToggle.init()
</script>
<script type="text/javascript" src="../../clipboard.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../navtreedata.js"></script>
@@ -18,14 +24,24 @@
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
<script type="text/javascript">
window.MathJax = {
options: {
ignoreHtmlClass: 'tex2jax_ignore',
processHtmlClass: 'tex2jax_process'
},
loader: {
load: ['[tex]/ams']
},
tex: {
macros: {},
packages: ['base','configmacros','ams']
}
};
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
@@ -33,10 +49,11 @@ MathJax.Hub.Config({
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
<td id="projectalign">
<div id="projectname">Algorithms_in_C++<span id="projectnumber">&#160;1.0.0</span>
<div id="projectname">TheAlgorithms/C++<span id="projectnumber">&#160;1.0.0</span>
</div>
<div id="projectbrief">Set of algorithms implemented in C++.</div>
<div id="projectbrief">All the algorithms implemented in C++</div>
</td>
</tr>
</tbody>
@@ -124,7 +141,9 @@ Include dependency graph for fast_fourier_transform.cpp:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d0/d15/fast__fourier__transform_8cpp__incl.svg" width="512" height="126"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div><table class="memberdecls">
</div>
<p><a href="../../d8/d9a/fast__fourier__transform_8cpp_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="namespaces" name="namespaces"></a>
Namespaces</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">namespace &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/de0/namespacenumerical__methods.html">numerical_methods</a></td></tr>
@@ -133,7 +152,7 @@ Namespaces</h2></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a158fd271b9a53e8f3f60b08b18857150" id="r_a158fd271b9a53e8f3f60b08b18857150"><td class="memItemLeft" align="right" valign="top"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/complex.html">std::complex</a>&lt; double &gt; *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/de0/namespacenumerical__methods.html#a158fd271b9a53e8f3f60b08b18857150">numerical_methods::FastFourierTransform</a> (<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/complex.html">std::complex</a>&lt; double &gt; *p, uint8_t n)</td></tr>
<tr class="memitem:a158fd271b9a53e8f3f60b08b18857150" id="r_a158fd271b9a53e8f3f60b08b18857150"><td class="memItemLeft" align="right" valign="top">std::complex&lt; double &gt; *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/de0/namespacenumerical__methods.html#a158fd271b9a53e8f3f60b08b18857150">numerical_methods::FastFourierTransform</a> (std::complex&lt; double &gt; *p, uint8_t n)</td></tr>
<tr class="memdesc:a158fd271b9a53e8f3f60b08b18857150"><td class="mdescLeft">&#160;</td><td class="mdescRight">FastFourierTransform is a recursive function which returns list of complex numbers. <br /></td></tr>
<tr class="separator:a158fd271b9a53e8f3f60b08b18857150"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa8dca7b867074164d5f45b0f3851269d" id="r_aa8dca7b867074164d5f45b0f3851269d"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aa8dca7b867074164d5f45b0f3851269d">test</a> ()</td></tr>
@@ -146,6 +165,8 @@ Functions</h2></td></tr>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p><a href="https://medium.com/@aiswaryamathur/understanding-fast-fouriertransform-from-scratch-to-solve-polynomial-multiplication-8018d511162f" target="_blank">A fast Fourier transform (FFT)</a> is an algorithm that computes the discrete Fourier transform (DFT) of a sequence, or its inverse (IDFT). </p>
<p>This algorithm has application in use case scenario where a user wants to find points of a function in a short time by just using the coefficients of the polynomial function. It can be also used to find inverse fourier transform by just switching the value of omega. Time complexity this algorithm computes the DFT in O(nlogn) time in comparison to traditional O(n^2). </p><dl class="section author"><dt>Author</dt><dd><a href="https://github.com/ameyachawlaggsipu" target="_blank">Ameya Chawla</a> </dd></dl>
<p class="definition">Definition in file <a class="el" href="../../d8/d9a/fast__fourier__transform_8cpp_source.html">fast_fourier_transform.cpp</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="abf9e6b7e6f15df4b525a2e7705ba3089" name="abf9e6b7e6f15df4b525a2e7705ba3089"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abf9e6b7e6f15df4b525a2e7705ba3089">&#9670;&#160;</a></span>main()</h2>
@@ -175,18 +196,15 @@ Functions</h2></td></tr>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
<p class="definition">Definition at line <a class="el" href="../../d8/d9a/fast__fourier__transform_8cpp_source.html#l00163">163</a> of file <a class="el" href="../../d8/d9a/fast__fourier__transform_8cpp_source.html">fast_fourier_transform.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 163</span> {</div>
<div class="line"><span class="lineno"> 164</span> <a class="code hl_function" href="#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// run self-test implementations</span></div>
<div class="line"><span class="lineno"> 165</span> <span class="comment">// with 2 defined test cases</span></div>
<div class="line"><span class="lineno"> 166</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 167</span>}</div>
<div class="ttc" id="afast__fourier__transform_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Self-test implementations.</div><div class="ttdef"><b>Definition</b> fast_fourier_transform.cpp:105</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d8/d9a/fast__fourier__transform_8cpp_abf9e6b7e6f15df4b525a2e7705ba3089_cgraph.svg" width="346" height="175"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
<div class="ttc" id="afast__fourier__transform_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Self-test implementations.</div><div class="ttdef"><b>Definition</b> <a href="../../d8/d9a/fast__fourier__transform_8cpp_source.html#l00105">fast_fourier_transform.cpp:105</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="aa8dca7b867074164d5f45b0f3851269d" name="aa8dca7b867074164d5f45b0f3851269d"></a>
@@ -222,11 +240,13 @@ Here is the call graph for this function:</div>
<p>Temporary variable used to delete memory location of o2</p>
<p>Comparing for both real and imaginary values for test case 1</p>
<p>Comparing for both real and imaginary values for test case 2</p>
<p class="definition">Definition at line <a class="el" href="../../d8/d9a/fast__fourier__transform_8cpp_source.html#l00105">105</a> of file <a class="el" href="../../d8/d9a/fast__fourier__transform_8cpp_source.html">fast_fourier_transform.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 105</span> {</div>
<div class="line"><span class="lineno"> 106</span> <span class="comment">/* descriptions of the following test */</span></div>
<div class="line"><span class="lineno"> 107</span> </div>
<div class="line"><span class="lineno"> 108</span> <span class="keyword">auto</span> *t1 = <span class="keyword">new</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/complex.html">std::complex&lt;double&gt;</a>[2]; <span class="comment">/// Test case 1</span></div>
<div class="line"><span class="lineno"> 109</span> <span class="keyword">auto</span> *t2 = <span class="keyword">new</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/complex.html">std::complex&lt;double&gt;</a>[4]; <span class="comment">/// Test case 2</span></div>
<div class="line"><span class="lineno"> 108</span> <span class="keyword">auto</span> *t1 = <span class="keyword">new</span> std::complex&lt;double&gt;[2]; </div>
<div class="line"><span class="lineno"> 109</span> <span class="keyword">auto</span> *t2 = <span class="keyword">new</span> std::complex&lt;double&gt;[4]; </div>
<div class="line"><span class="lineno"> 110</span> </div>
<div class="line"><span class="lineno"> 111</span> t1[0] = {1, 0};</div>
<div class="line"><span class="lineno"> 112</span> t1[1] = {2, 0};</div>
@@ -237,52 +257,40 @@ Here is the call graph for this function:</div>
<div class="line"><span class="lineno"> 117</span> </div>
<div class="line"><span class="lineno"> 118</span> uint8_t n1 = 2;</div>
<div class="line"><span class="lineno"> 119</span> uint8_t n2 = 4;</div>
<div class="line"><span class="lineno"> 120</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::complex&lt;double&gt;</a>&gt; r1 = {</div>
<div class="line"><span class="lineno"> 121</span> {3, 0}, {-1, 0}}; <span class="comment">/// True Answer for test case 1</span></div>
<div class="line"><span class="lineno"> 120</span> std::vector&lt;std::complex&lt;double&gt;&gt; r1 = {</div>
<div class="line"><span class="lineno"> 121</span> {3, 0}, {-1, 0}}; </div>
<div class="line"><span class="lineno"> 122</span> </div>
<div class="line"><span class="lineno"> 123</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::complex&lt;double&gt;</a>&gt; r2 = {</div>
<div class="line"><span class="lineno"> 124</span> {10, 0}, {-2, -2}, {-2, 0}, {-2, 2}}; <span class="comment">/// True Answer for test case 2</span></div>
<div class="line"><span class="lineno"> 123</span> std::vector&lt;std::complex&lt;double&gt;&gt; r2 = {</div>
<div class="line"><span class="lineno"> 124</span> {10, 0}, {-2, -2}, {-2, 0}, {-2, 2}}; </div>
<div class="line"><span class="lineno"> 125</span> </div>
<div class="line"><span class="lineno"> 126</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/complex.html">std::complex&lt;double&gt;</a> *o1 = <a class="code hl_function" href="../../d1/de0/namespacenumerical__methods.html#a158fd271b9a53e8f3f60b08b18857150">numerical_methods::FastFourierTransform</a>(t1, n1);</div>
<div class="line"><span class="lineno"> 127</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/complex.html">std::complex&lt;double&gt;</a> *t3 =</div>
<div class="line"><span class="lineno"> 128</span> o1; <span class="comment">/// Temporary variable used to delete memory location of o1</span></div>
<div class="line"><span class="lineno"> 129</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/complex.html">std::complex&lt;double&gt;</a> *o2 = <a class="code hl_function" href="../../d1/de0/namespacenumerical__methods.html#a158fd271b9a53e8f3f60b08b18857150">numerical_methods::FastFourierTransform</a>(t2, n2);</div>
<div class="line"><span class="lineno"> 130</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/complex.html">std::complex&lt;double&gt;</a> *t4 =</div>
<div class="line"><span class="lineno"> 131</span> o2; <span class="comment">/// Temporary variable used to delete memory location of o2</span></div>
<div class="line"><span class="lineno"> 126</span> std::complex&lt;double&gt; *o1 = <a class="code hl_function" href="../../d1/de0/namespacenumerical__methods.html#a158fd271b9a53e8f3f60b08b18857150">numerical_methods::FastFourierTransform</a>(t1, n1);</div>
<div class="line"><span class="lineno"> 127</span> std::complex&lt;double&gt; *t3 =</div>
<div class="line"><span class="lineno"> 128</span> o1; </div>
<div class="line"><span class="lineno"> 129</span> std::complex&lt;double&gt; *o2 = <a class="code hl_function" href="../../d1/de0/namespacenumerical__methods.html#a158fd271b9a53e8f3f60b08b18857150">numerical_methods::FastFourierTransform</a>(t2, n2);</div>
<div class="line"><span class="lineno"> 130</span> std::complex&lt;double&gt; *t4 =</div>
<div class="line"><span class="lineno"> 131</span> o2; </div>
<div class="line"><span class="lineno"> 132</span> <span class="keywordflow">for</span> (uint8_t i = 0; i &lt; n1; i++) {</div>
<div class="line"><span class="lineno"> 133</span> assert((r1[i].real() - o1-&gt;<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/complex/real.html">real</a>() &lt; 0.000000000001) &amp;&amp;</div>
<div class="line"><span class="lineno"> 134</span> (r1[i].imag() - o1-&gt;<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/complex/imag.html">imag</a>() &lt;</div>
<div class="line"><span class="lineno"> 135</span> 0.000000000001)); <span class="comment">/// Comparing for both real and imaginary</span><span class="comment"></span></div>
<div class="line"><span class="lineno"> 136</span><span class="comment"> /// values for test case 1</span></div>
<div class="line"><span class="lineno"> 137</span><span class="comment"></span> o1++;</div>
<div class="line"><span class="lineno"> 133</span> assert((r1[i].real() - o1-&gt;real() &lt; 0.000000000001) &amp;&amp;</div>
<div class="line"><span class="lineno"> 134</span> (r1[i].imag() - o1-&gt;imag() &lt;</div>
<div class="line"><span class="lineno"> 135</span> 0.000000000001)); </div>
<div class="line"><span class="lineno"> 137</span> o1++;</div>
<div class="line"><span class="lineno"> 138</span> }</div>
<div class="line"><span class="lineno"> 139</span> </div>
<div class="line"><span class="lineno"> 140</span> <span class="keywordflow">for</span> (uint8_t i = 0; i &lt; n2; i++) {</div>
<div class="line"><span class="lineno"> 141</span> assert((r2[i].real() - o2-&gt;<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/complex/real.html">real</a>() &lt; 0.000000000001) &amp;&amp;</div>
<div class="line"><span class="lineno"> 142</span> (r2[i].imag() - o2-&gt;<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/complex/imag.html">imag</a>() &lt;</div>
<div class="line"><span class="lineno"> 143</span> 0.000000000001)); <span class="comment">/// Comparing for both real and imaginary</span><span class="comment"></span></div>
<div class="line"><span class="lineno"> 144</span><span class="comment"> /// values for test case 2</span></div>
<div class="line"><span class="lineno"> 145</span><span class="comment"></span> o2++;</div>
<div class="line"><span class="lineno"> 141</span> assert((r2[i].real() - o2-&gt;real() &lt; 0.000000000001) &amp;&amp;</div>
<div class="line"><span class="lineno"> 142</span> (r2[i].imag() - o2-&gt;imag() &lt;</div>
<div class="line"><span class="lineno"> 143</span> 0.000000000001)); </div>
<div class="line"><span class="lineno"> 145</span> o2++;</div>
<div class="line"><span class="lineno"> 146</span> }</div>
<div class="line"><span class="lineno"> 147</span> </div>
<div class="line"><span class="lineno"> 148</span> <span class="keyword">delete</span>[] t1;</div>
<div class="line"><span class="lineno"> 149</span> <span class="keyword">delete</span>[] t2;</div>
<div class="line"><span class="lineno"> 150</span> <span class="keyword">delete</span>[] t3;</div>
<div class="line"><span class="lineno"> 151</span> <span class="keyword">delete</span>[] t4;</div>
<div class="line"><span class="lineno"> 152</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;All tests have successfully passed!\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 152</span> std::cout &lt;&lt; <span class="stringliteral">&quot;All tests have successfully passed!\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 153</span>}</div>
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div></div>
<div class="ttc" id="acomplex_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/complex.html">std::complex</a></div></div>
<div class="ttc" id="aimag_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/complex/imag.html">std::complex::imag</a></div><div class="ttdeci">T imag(T... args)</div></div>
<div class="ttc" id="anamespacenumerical__methods_html_a158fd271b9a53e8f3f60b08b18857150"><div class="ttname"><a href="../../d1/de0/namespacenumerical__methods.html#a158fd271b9a53e8f3f60b08b18857150">numerical_methods::FastFourierTransform</a></div><div class="ttdeci">std::complex&lt; double &gt; * FastFourierTransform(std::complex&lt; double &gt; *p, uint8_t n)</div><div class="ttdoc">FastFourierTransform is a recursive function which returns list of complex numbers.</div><div class="ttdef"><b>Definition</b> fast_fourier_transform.cpp:42</div></div>
<div class="ttc" id="areal_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/complex/real.html">std::complex::real</a></div><div class="ttdeci">T real(T... args)</div></div>
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d8/d9a/fast__fourier__transform_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg" width="248" height="175"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
<div class="ttc" id="anamespacenumerical__methods_html_a158fd271b9a53e8f3f60b08b18857150"><div class="ttname"><a href="../../d1/de0/namespacenumerical__methods.html#a158fd271b9a53e8f3f60b08b18857150">numerical_methods::FastFourierTransform</a></div><div class="ttdeci">std::complex&lt; double &gt; * FastFourierTransform(std::complex&lt; double &gt; *p, uint8_t n)</div><div class="ttdoc">FastFourierTransform is a recursive function which returns list of complex numbers.</div><div class="ttdef"><b>Definition</b> <a href="../../d8/d9a/fast__fourier__transform_8cpp_source.html#l00042">fast_fourier_transform.cpp:42</a></div></div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->