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.
 
 
 

182 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, shrink-to-fit=no">
<meta name="author" content="Christoph Ruegg, Marcus Cuda, Jurgen Van Gael">
<link rel="stylesheet" id="theme_link" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/4.6.0/materia/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<link type="text/css" rel="stylesheet" href="https://numerics.mathdotnet.com/content/navbar-fixed-left.css" />
<link type="text/css" rel="stylesheet" href="https://numerics.mathdotnet.com/content/fsdocs-default.css" />
<link type="text/css" rel="stylesheet" href="https://numerics.mathdotnet.com/content/fsdocs-custom.css" />
<script type="text/javascript" src="https://numerics.mathdotnet.com/content/fsdocs-tips.js"></script>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- BEGIN SEARCH BOX: this adds support for the search box -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/JavaScript-autoComplete/1.0.4/auto-complete.css" />
<!-- END SEARCH BOX: this adds support for the search box -->
</head>
<body>
<nav class="navbar navbar-expand-md navbar-light bg-secondary fixed-left" id="fsdocs-nav">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse navbar-nav-scroll" id="navbarsExampleDefault">
<a href="https://numerics.mathdotnet.com/"><img id="fsdocs-logo" src="/logo.png" /></a>
<!-- BEGIN SEARCH BOX: this adds support for the search box -->
<div id="header">
<div class="searchbox" id="fsdocs-searchbox">
<label for="search-by">
<i class="fas fa-search"></i>
</label>
<input data-search-input="" id="search-by" type="search" placeholder="Search..." />
<span data-search-clear="">
<i class="fas fa-times"></i>
</span>
</div>
</div>
<!-- END SEARCH BOX: this adds support for the search box -->
<ul class="navbar-nav">
<li class="nav-header">Math.NET Numerics</li>
<li class="nav-item"><a class="nav-link" href="Packages.html">NuGet & Binaries</a></li>
<li class="nav-item"><a class="nav-link" href="ReleaseNotes.html">Release Notes</a></li>
<li class="nav-item"><a class="nav-link" href="https://github.com/mathnet/mathnet-numerics/blob/master/LICENSE.md">MIT License</a></li>
<li class="nav-item"><a class="nav-link" href="Compatibility.html">Platform Support</a></li>
<li class="nav-item"><a class="nav-link" href="https://numerics.mathdotnet.com/api/">Class Reference</a></li>
<li class="nav-item"><a class="nav-link" href="https://github.com/mathnet/mathnet-numerics/issues">Issues & Bugs</a></li>
<li class="nav-item"><a class="nav-link" href="Users.html">Who is using Math.NET?</a></li>
<li class="nav-header">Contributing</li>
<li class="nav-item"><a class="nav-link" href="Contributors.html">Contributors</a></li>
<li class="nav-item"><a class="nav-link" href="Contributing.html">Contributing</a></li>
<li class="nav-item"><a class="nav-link" href="Build.html">Build & Tools</a></li>
<li class="nav-item"><a class="nav-link" href="https://github.com/mathnet/mathnet-numerics/discussions/categories/ideas">Your Ideas</a></li>
<li class="nav-header">Getting Help</li>
<li class="nav-item"><a class="nav-link" href="https://discuss.mathdotnet.com/c/numerics">Discuss</a></li>
<li class="nav-item"><a class="nav-link" href="https://stackoverflow.com/questions/tagged/mathdotnet">Stack Overflow</a></li>
<li class="nav-header">Getting Started</li>
<l class="nav-item"i><a class="nav-link" href="/">Getting started</a></li>
<li class="nav-item"><a class="nav-link" href="Constants.html">Constants</a></li>
<li class="nav-item"><a class="nav-link" href="Matrix.html">Matrices and Vectors</a></li>
<li class="nav-item"><a class="nav-link" href="Euclid.html">Euclid & Number Theory</a></li>
<li class="nav-item">Combinatorics</li>
<li class="nav-header">Evaluation</li>
<li class="nav-item"><a class="nav-link" href="Functions.html">Special Functions</a></li>
<li class="nav-item"><a class="nav-link" href="Integration.html">Integration</a></li>
<li class="nav-header">Statistics/Probability</li>
<li class="nav-item"><a class="nav-link" href="DescriptiveStatistics.html">Descriptive Statistics</a></li>
<li class="nav-item"><a class="nav-link" href="Probability.html">Probability Distributions</a></li>
<li class="nav-header">Generation</li>
<li class="nav-item"><a class="nav-link" href="Generate.html">Generating Data</a></li>
<li class="nav-item"><a class="nav-link" href="Random.html">Random Numbers</a></li>
<li class="nav-header">Solving Equations</li>
<li class="nav-item"><a class="nav-link" href="LinearEquations.html">Linear Equation Systems</a></li>
<li class="nav-header">Optimization</li>
<li class="nav-item"><a class="nav-link" href="Distance.html">Distance Metrics</a></li>
<li class="nav-header">Curve Fitting</li>
<li class="nav-item"><a class="nav-link" href="Regression.html">Regression</a></li>
<li class="nav-header">Native Providers</li>
<li class="nav-item"><a class="nav-link" href="MKL.html">Intel MKL</a></li>
<li class="nav-header">Working Together</li>
<li class="nav-item"><a class="nav-link" href="CSV.html">Delimited Text Files (CSV)</a></li>
<li class="nav-item"><a class="nav-link" href="MatrixMarket.html">NIST MatrixMarket</a></li>
<li class="nav-item"><a class="nav-link" href="MatlabFiles.html">MATLAB</a></li>
<li class="nav-item"><a class="nav-link" href="IFSharpNotebook.html">IF# Notebook</a></li>
</ul>
</div>
</nav>
<div class="container">
<div class="masthead">
<h3 class="muted">
<a href="https://numerics.mathdotnet.com">Math.NET Numerics</a> |
<a href="https://www.mathdotnet.com">Math.NET Project</a> |
<a href="https://github.com/mathnet/mathnet-numerics">GitHub</a>
</h3>
</div>
<hr />
<div class="container" id="fsdocs-content">
<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="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>
<!-- BEGIN SEARCH BOX: this adds support for the search box -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/JavaScript-autoComplete/1.0.4/auto-complete.css" />
<script type="text/javascript">var fsdocs_search_baseurl = 'https://numerics.mathdotnet.com/';</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.8/lunr.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/JavaScript-autoComplete/1.0.4/auto-complete.min.js"></script>
<script type="text/javascript" src="https://numerics.mathdotnet.com/content/fsdocs-search.js"></script>
<!-- END SEARCH BOX: this adds support for the search box -->
</div>
</body>
</html>