Math.NET Numerics
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

201 lines
14 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Fourier and related linear integral transforms
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="Math.NET Numerics, providing methods and algorithms for numerical computations in science, engineering and every day use. .Net 4, .Net 3.5, SL5, Win8, WP8, PCL 47 and 136, Mono, Xamarin Android/iOS."/>
<meta name="author" content="Christoph Ruegg, Marcus Cuda, Jurgen Van Gael"/>
<script src="https://code.jquery.com/jquery-1.8.0.js"></script>
<script src="https://code.jquery.com/ui/1.8.23/jquery-ui.js"></script>
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css" rel="stylesheet"/>
<link type="text/css" rel="stylesheet" href="https://numerics.mathdotnet.com/content/style.css" />
<style>
#main table:not(.pre) {
border: 1px solid #dddddd;
max-width: 100%;
border-style: solid;
border-width: 1px;
border-color: gray;
border-collapse: collapse;
border-right-width: 1px;
border-bottom-width: 1px;
margin-top: 15px;
margin-bottom: 25px;
}
#main table:not(.pre) th, #main table:not(.pre) td {
border: 1px solid #dddddd;
padding: 6px;
}
#main table:not(.pre) th p, #main table:not(.pre) td p {
margin-bottom: 5px;
}
</style>
<script type="text/javascript" src="https://numerics.mathdotnet.com/content/tips.js"></script>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</head>
<body>
<div class="container">
<div class="masthead">
<ul class="nav nav-pills pull-right">
<li><a href="https://www.mathdotnet.com">Math.NET Project</a></li>
<li><a href="https://numerics.mathdotnet.com">Math.NET Numerics</a></li>
<li><a href="https://github.com/mathnet/mathnet-numerics">GitHub</a></li>
</ul>
<h3 class="muted">Math.NET Numerics</h3>
</div>
<hr />
<div class="row">
<div class="span9" id="main">
<h1><a name="Fourier-and-related-linear-integral-transforms" class="anchor" href="#Fourier-and-related-linear-integral-transforms">Fourier and related linear integral transforms</a></h1>
<p>Math.NET Numerics currently supports two linear integral transforms: The discrete Fourier
transform and the discrete Hartley transform. Both are strongly localized in the frequency
spectrum, but while the Fourier transform operates on complex values, the Hartley transform
operates on real values only.</p>
<p>The transforms implement a separate forward and inverse transform method.
How the forward and inverse methods are related to each other and what exact definition
is to be used can be specified by an additional <em>options</em> parameter.</p>
<h2><a name="Fourier-Space-Discrete-Fourier-Transform-and-FFT" class="anchor" href="#Fourier-Space-Discrete-Fourier-Transform-and-FFT">Fourier Space: Discrete Fourier Transform and FFT</a></h2>
<p>Wikipedia has an extensive <a href="https://en.wikipedia.org/wiki/Discrete_Fourier_transform">article on the discrete Fourier transform (DFT)</a>.
We provide implementations of the following algorithms:</p>
<ul>
<li><p><em>Naive Discrete Fourier Transform (DFT):</em> Out-place transform for arbitrary vector lengths. Mainly intended for verifying faster algorithms: <em><a href="https://numerics.mathdotnet.com/api/MathNet.Numerics.IntegralTransforms/Fourier.htm#NaiveForward">NaiveForward</a></em>, <em><a href="https://numerics.mathdotnet.com/api/MathNet.Numerics.IntegralTransforms/Fourier.htm#NaiveInverse">NaiveInverse</a></em></p></li>
<li><p><em>Radix-2 Fast Fourier Transform (FFT):</em> In-place fast Fourier transform for vectors with a power-of-two length (Radix-2): <em><a href="https://numerics.mathdotnet.com/api/MathNet.Numerics.IntegralTransforms/Fourier.htm#Radix2Forward">Radix2Forward</a></em>, <em><a href="https://numerics.mathdotnet.com/api/MathNet.Numerics.IntegralTransforms/Fourier.htm#Radix2Inverse">url:Radix2Inverse</a></em></p></li>
<li><p><em>Bluestein Fast Fourier Transform (FFT):</em> In-place fast Fourier transform for arbitrary vector lengths: <em><a href="https://numerics.mathdotnet.com/api/MathNet.Numerics.IntegralTransforms/Fourier.htm#BluesteinForward">BluesteinForward</a></em>, <em><a href="https://numerics.mathdotnet.com/api/MathNet.Numerics.IntegralTransforms/Fourier.htm#BluesteinInverse">url:BluesteinInverse</a></em></p></li>
</ul>
<p>Furthermore, the <em><a href="https://numerics.mathdotnet.com/api/MathNet.Numerics.IntegralTransforms/Fourier.htm">Transform</a></em> class provides a shortcut for the Bluestein FFT using static methods which are even easier to use: <em><a href="https://numerics.mathdotnet.com/api/MathNet.Numerics.IntegralTransforms/Transform.htm#FourierForward">FourierForward</a></em>, <em><a href="https://numerics.mathdotnet.com/api/MathNet.Numerics.IntegralTransforms/Transform.htm#FourierInverse">FourierInverse</a></em>.</p>
<p>Code Sample using the Transform class:</p>
<table class="pre"><tr><td class="lines"><pre class="fssnip"><span class="l">1: </span>
<span class="l">2: </span>
<span class="l">3: </span>
<span class="l">4: </span>
<span class="l">5: </span>
<span class="l">6: </span>
<span class="l">7: </span>
</pre></td>
<td class="snippet"><pre class="fssnip highlighted"><code lang="csharp"><span class="c">// create a complex sample vector of length 96</span>
Complex[] samples <span class="o">=</span> SignalGenerator.EquidistantInterval(
t <span class="o">=</span><span class="o">&gt;</span> <span class="k">new</span> Complex(<span class="n">1.0</span> <span class="o">/</span> (t <span class="o">*</span> t <span class="o">+</span> <span class="n">1.0</span>), t <span class="o">/</span> (t <span class="o">*</span> t <span class="o">+</span> <span class="n">1.0</span>)),
<span class="n">-16</span>, <span class="n">16</span>, <span class="n">96</span>);
<span class="c">// inplace bluestein FFT with default options</span>
Transform.FourierForward(samples);
</code></pre></td></tr></table>
<p>Fourier Options:</p>
<ul>
<li><em>Default:</em> Uses a negative exponent sign in forward transformations, and symmetric scaling (that is, sqrt(1/N) for both forward and inverse transformation). This is the convention used in Maple and is widely accepted in the educational sector (due to the symmetry).</li>
<li><em>AsymmetricScaling:</em> Set this flag to suppress scaling on the forward transformation but scale the inverse transform with 1/N.</li>
<li><em>NoScaling:</em> Set this flag to suppress scaling for both forward and inverse transformation. Note that in this case if you apply first the forward and then inverse transformation you won't get back the original signal (by factor N/2).</li>
<li><em>InverseExponent:</em> Uses the positive instead of the negative sign in the forward exponent, and the negative (instead of positive) exponent in the inverse transformation.</li>
<li><em>Matlab:</em> Use this flag if you need MATLAB compatibility. Equals to setting the <em>AsymmetricScaling</em> flag. This matches the definition used in the [url:wikipedia article|<a href="https://en.wikipedia.org/wiki/Discrete_Fourier_transform">https://en.wikipedia.org/wiki/Discrete_Fourier_transform</a>].</li>
<li><em>NumericalRecipes:</em> Use this flag if you need Numerical Recipes compatibility. Equal to setting both the <em>InverseExponent</em> and the <em>NoScaling</em> flags.</li>
</ul>
<p>Useful symmetries of the Fourier transform:</p>
<ul>
<li>h(t) is real valued <=> real part of H(f) is even, imaginary part of H(f) is odd</li>
<li>h(t) is imaginary valued <=> real part of H(f) is odd, imaginary part of H(f) is even</li>
<li>h(t) is even <=> H(f) is even</li>
<li>h(t) is odd <=> H(f) is odd</li>
<li>h(t) is real-valued even <=> H(f) is real-valued even</li>
<li>h(t) is real-valued odd <=> H(f) is imaginary-valued odd</li>
<li>h(t) is imaginary-valued even <=> H(f) is imaginary-valued even</li>
<li>h(t) is imaginary-valued odd <=> H(f) is real-valued odd</li>
</ul>
<h2><a name="Hartley-Space-Discrete-Hartley-Transform" class="anchor" href="#Hartley-Space-Discrete-Hartley-Transform">Hartley Space: Discrete Hartley Transform</a></h2>
<p>...</p>
</div>
<div class="span3">
<ul class="nav nav-list" id="menu">
<li class="nav-header">Math.NET Numerics</li>
<li><a href="https://numerics.mathdotnet.com/Packages.html">NuGet & Binaries</a></li>
<li><a href="https://numerics.mathdotnet.com/ReleaseNotes.html">Release Notes</a></li>
<li><a href="https://numerics.mathdotnet.com/License.html">MIT/X11 License</a></li>
<li><a href="https://numerics.mathdotnet.com/Compatibility.html">Platform Support</a></li>
<li><a href="https://numerics.mathdotnet.com/api/">Class Reference</a></li>
<li><a href="https://github.com/mathnet/mathnet-numerics/issues">Issues & Bugs</a></li>
<li><a href="https://numerics.mathdotnet.com/Users.html">Who is using Math.NET?</a></li>
<li class="nav-header">Contributing</li>
<li><a href="https://numerics.mathdotnet.com/Contributors.html">Contributors</a></li>
<li><a href="https://numerics.mathdotnet.com/Contributing.html">Contributing</a></li>
<li><a href="https://numerics.mathdotnet.com/Build.html">Build & Tools</a></li>
<li><a href="http://feedback.mathdotnet.com/forums/2060-math-net-numerics">Your Ideas</a></li>
<li class="nav-header">Getting Help</li>
<li><a href="https://discuss.mathdotnet.com/c/numerics">Discuss</a></li>
<li><a href="https://stackoverflow.com/questions/tagged/mathdotnet">Stack Overflow</a></li>
<li class="nav-header">Getting Started</li>
<li><a href="https://numerics.mathdotnet.com/">Getting started</a></li>
<li><a href="https://numerics.mathdotnet.com/Constants.html">Constants</a></li>
<li>Floating-Point Numbers</li>
<li>Arbitrary Precision Numbers</li>
<li>Complex Numbers</li>
<li><a href="https://numerics.mathdotnet.com/Matrix.html">Matrices and Vectors</a></li>
<li><a href="https://numerics.mathdotnet.com/Euclid.html">Euclid & Number Theory</a></li>
<li>Combinatorics</li>
<li class="nav-header">Evaluation</li>
<li><a href="https://numerics.mathdotnet.com/Functions.html">Special Functions</a></li>
<li>Differentiation</li>
<li><a href="https://numerics.mathdotnet.com/Integration.html">Integration</a></li>
<li class="nav-header">Statistics/Probability</li>
<li><a href="https://numerics.mathdotnet.com/DescriptiveStatistics.html">Descriptive Statistics</a></li>
<li><a href="https://numerics.mathdotnet.com/Probability.html">Probability Distributions</a></li>
<li class="nav-header">Generation</li>
<li><a href="https://numerics.mathdotnet.com/Generate.html">Generating Data</a></li>
<li><a href="https://numerics.mathdotnet.com/Random.html">Random Numbers</a></li>
<li class="nav-header">Transformation</li>
<li>Fourier Transform (FFT)</li>
<li>Filtering & DSP</li>
<li>Window Functions</li>
<li class="nav-header">Solving Equations</li>
<li><a href="https://numerics.mathdotnet.com/LinearEquations.html">Linear Equation Systems</a></li>
<li>Nonlinear Root Finding</li>
<li class="nav-header">Optimization</li>
<li>Linear Least Squares</li>
<li>Nonlinear Optimization</li>
<li><a href="https://numerics.mathdotnet.com/Distance.html">Distance Metrics</a></li>
<li class="nav-header">Curve Fitting</li>
<li><a href="https://numerics.mathdotnet.com/Regression.html">Regression</a></li>
<li>Interpolation</li>
<li>Fourier Approximation</li>
<li class="nav-header">Native Providers</li>
<li><a href="https://numerics.mathdotnet.com/MKL.html">Intel MKL</a></li>
<li class="nav-header">Working Together</li>
<li><a href="https://numerics.mathdotnet.com/CSV.html">Delimited Text Files (CSV)</a></li>
<li><a href="https://numerics.mathdotnet.com/MatrixMarket.html">NIST MatrixMarket</a></li>
<li><a href="https://numerics.mathdotnet.com/MatlabFiles.html">MATLAB</a></li>
<li><a href="https://numerics.mathdotnet.com/IFSharpNotebook.html">IF# Notebook</a></li>
<li>FsLab & Deedle</li>
<li>Microsoft Excel</li>
<li>numl.net machine learning</li>
<li>R-project</li>
</ul>
</div>
</div>
</div>
</body>
</html>