ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation. |
This module contains procedures and generic interfaces for computing the Discrete Fourier Transform of a real
or complex
sequence using a mixed-radix decimation-in-frequency Fast-Fourier Transform.
More...
Data Types | |
interface | getFactorFFT |
Generate and return the factorization vector factor of the specified input sequence length and the corresponding vector of trigonometric coefficients coef .More... | |
interface | getFFTF |
Generate and return the Forward Fourier Transform (a.k.a. Fourier Analysis) of a periodic sequence of type complex or real of arbitrary kind type parameter. More... | |
interface | getFFTI |
Generate and return the Inverse (normalized) Fourier Transform of a periodic sequence of type complex or real of arbitrary kind type parameter. More... | |
interface | getFFTR |
Generate and return the Reverse (unnormalized) Fourier Transform of a periodic sequence of type complex or real of arbitrary kind type parameter. More... | |
interface | setFFTF |
Return the Forward Fourier Transform (or equivalently, the Fourier coefficients) of a periodic sequence of type complex or real of arbitrary kind type parameter. More... | |
interface | setFFTI |
Return the Inverse (normalized) Fourier Transform of a periodic sequence of type complex or real of arbitrary kind type parameter. More... | |
interface | setFFTR |
Return the Reverse (unnormalized) Fourier Transform of a periodic sequence of type complex or real of arbitrary kind type parameter. More... | |
Variables | |
character(*, SK), parameter | MODULE_NAME = "@pm_fftpack" |
This module contains procedures and generic interfaces for computing the Discrete Fourier Transform of a real
or complex
sequence using a mixed-radix decimation-in-frequency Fast-Fourier Transform.
The discrete Fourier transform (DFT) converts a finite sequence of equally-spaced samples of a function into a same-length sequence of equally-spaced samples of the discrete-time Fourier transform (DTFT), which is a complex-valued function of frequency.
Since DFT deals with a finite amount of data, it can be implemented in computers by numerical algorithms or even dedicated hardware.
These implementations usually employ efficient fast Fourier transform (FFT) algorithms, so much so that the terms FFT and DFT are used interchangeably.
The DFT transforms a sequence of \(N\) complex numbers \(\{ x_j \} := x_0, x_1, \ldots, x_{N − 1}\) into another sequence of complex numbers, \(\{z_k\} := z_0, z_1, \ldots, z_{N - 1}\) which is defined by,
\begin{eqnarray} \large x_k &=& \sum_{j=0}^{N-1} z_j \cdot e^{-\frac {i 2\pi}{N}jk} ~, \\ &=& \sum_{j=0}^{N-1} z_j \cdot \left[\cos\left(\frac{2\pi}{N}jk\right) - i \cdot \sin\left(\frac{2 \pi}{N}jk\right)\right], \end{eqnarray}
where \(i\) represents the imaginary unit.
The naive evaluation of the DFT is a matrix-vector multiplication that costs \(\mathcal{O}(n^2)\) operations for \(N\) data-points.
Fast Fourier Transform (FFT) algorithms use a divide-and-conquer strategy to factorize the matrix into smaller sub-matrices, corresponding to the integer factors of the length \(N\).
If \(N\) can be factorized into a product of integers \(f_1 f_2 \ldots f_m\), then the DFT can be computed in \(\mathcal{O}(n \sum f_i)\) operations.
For a radix-2 FFT this gives an operation count of \(\mathcal{O}(n \log_2 n)\).
For every Forward DFT (setFFTF), which expresses the data sequence in terms of frequency coefficients), there is a corresponding Reverse (Backward) DFT.
The Reverse DFT (setFFTR) takes the output of the Forward DFT and returns the original data sequence given to the Forward DFT, multiplied by the length of the sequence,
\begin{eqnarray} \large N z_j &=& \sum_{k=0}^{N-1} x_k \cdot e^{\frac {i 2\pi}{N}jk} ~, \\ &=& \sum_{k=0}^{N-1} x_k \cdot \left[\cos\left(\frac{2\pi}{N}jk\right) + i \cdot \sin\left(\frac{2 \pi}{N}jk\right)\right], \end{eqnarray}
A third definition, the Inverse DFT (setFFTI), further normalizes the Reverse DFT and returns,
\begin{eqnarray} \large z_j &=& \frac{1}{N} \sum_{k=0}^{N-1} x_k \cdot e^{\frac {i 2\pi}{N}jk} ~, \\ &=& \frac{1}{N} \sum_{k=0}^{N-1} x_k \cdot \left[\cos\left(\frac{2\pi}{N}jk\right) + i \cdot \sin\left(\frac{2 \pi}{N}jk\right)\right], \end{eqnarray}
such that the resulting normalized Reverse (Backward) DFT or Inverse DFT becomes a true inverse of the Forward DFT.
The Reverse DFT becomes relevant when the overall scale of the result is unimportant.
In such cases, it is convenient to use the Reverse (Backward) DFT instead of the Inverse DFT to avoid the redundant divisions in the normalization step.
A 64-bit real
division is typically on the order of \(\sim20\) CPU cycles on the contemporary hardware.
Avoiding the redundant normalizations can therefore become a significant saving if the DFT is to computed repeatedly for an array of millions of elements.
The Cooley–Tukey algorithm, named after J. W. Cooley and John Tukey, is the most common fast Fourier transform (FFT) algorithm.
It re-expresses the discrete Fourier transform (DFT) of an arbitrary composite size \(N = N_{1} N_{2}\) in terms of \(N_1\) smaller DFTs of sizes \(N_2\), recursively, to reduce the computation time to \(\mathcal{O}(N log N)\) for highly composite \(N\) (smooth numbers).
Because of the algorithm importance, specific variants and implementation styles have become known by their own names, as described below.
Because the Cooley–Tukey algorithm breaks the DFT into smaller DFTs, it can be combined arbitrarily with any other algorithm for the DFT.
For example, The Rader or Bluestein algorithm can be used to handle large prime factors that cannot be decomposed by Cooley–Tukey, or the prime-factor algorithm can be exploited for greater efficiency in separating out relatively prime factors.
The algorithm, along with its recursive application, was invented by Carl Friedrich Gauss.
Cooley and Tukey independently rediscovered and popularized it 160 years later.
The Cooley–Tukey algorithms recursively re-express a DFT of a composite size \(N = N_1 N_2\) as:
Typically, either \(N_1\) or \(N_2\) is a small factor (not necessarily prime), called the radix (which can differ between stages of the recursion).
If \(N_1\) is the radix, it is called a decimation in time (DIT) algorithm, whereas if \(N_2\) is the radix, it is decimation in frequency (DIF) algorithm, also called the Sande–Tukey algorithm.
real
and complex
data sequences.radix-2
algorithms at the cost of requiring an extra memory storage of the same length as the input sequence.complex
and real
precision kinds (e.g., any supported by the processor (e.g., RK, RK32, RK64, or RK128), any supported by the processor (e.g., CK, CK32, CK64, or CK128)).complex
and real
actual and dummy arguments,complex
and integer
actual and dummy arguments,goto
statements from the original library.
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
FFTPACK * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * version 4 april 1985 a package of fortran subprograms for the fast fourier transform of periodic and other symmetric sequences by paul n swarztrauber national center for atmospheric research boulder,colorado 80307 which is sponsored by the national science foundation * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
character(*, SK), parameter pm_fftpack::MODULE_NAME = "@pm_fftpack" |
Definition at line 212 of file pm_fftpack.F90.