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...
Return the Forward Fourier Transform (or equivalently, the Fourier coefficients) of a periodic sequence of type complex
or real
of arbitrary kind type parameter.
For an input data
sequence of length \(N\) of type complex
, the output coefficients fftf
(either stored in data
or work
) contain the following,
\begin{equation}
\ms{fftf}(k) = \sum_{j = 1}^{N} \ms{data}(j) \exp\left( -i \cdot (k - 1)(j - 1) \frac{2\pi}{N} \right) ~, \\
\end{equation}
where \(i = \sqrt{-1}\).
For an input data
sequence of length \(N\) of type real
, the output coefficients fftf
(either stored in data
or work
) contain the following,
\begin{eqnarray}
\ms{fftf}(1) &=& \sum_{j = 1}^{N} +\ms{data}(j) ~, \\
\ms{fftf}(2k-2) &=& \sum_{j = 1}^{N} +\ms{data}(j) \cos\left((k - 1)(j - 1) \frac{2\pi}{N}\right) ~~~,~~~ k = \left\lceil\frac{N}{2}\right\rceil ~, \\
\ms{fftf}(2k-1) &=& \sum_{j = 1}^{N} -\ms{data}(j) \sin\left((k - 1)(j - 1) \frac{2\pi}{N}\right) ~~~,~~~ k = \left\lceil\frac{N}{2}\right\rceil ~, \\
\ms{fftf}(N) &=& \sum_{j = 1}^{N} +\ms{data}(j) (-1)^{(j - 1)} ~~~,~~~ \ms{iff} ~ \frac{N}{2} = \left\lceil\frac{N}{2}\right\rceil ~,
\end{eqnarray}
A call to setFFTF() followed by a call to setFFTR() will multiply the initial sequence data
by its length \(N\).
A call to setFFTF() followed by a call to setFFTI() will retrieve the initial sequence data
.
See the documentation of pm_fftpack for more details.
- Parameters
-
[in] | factor | : The input contiguous vector of shape (:) of type integer of default kind IK, containing the factorization of the length of the input data sequence whose FFT is to be computed.
This input argument along with coef is the direct output of getFactorFFT.
|
[in] | coef | : The input contiguous vector of shape (1:size(data)) of the same type and kind as the input argument data , containing the trigonometric look up table required for FFT of the specified data sequence.
This input argument along with factor is the direct output of getFactorFFT.
|
[in,out] | data | : The input/output contiguous vector of arbitrary size of,
-
type
complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128),
-
type
real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
containing the periodic sequence whose FFT is to be computed.
On output, data contains the FFT result if inwork == .true. .
Otherwise, the original input data is completely destroyed on return.
|
[out] | work | : The output contiguous vector of the same type, kind, and size as the input data , that is used as a workspace.
On output, work contains the FFT result if inwork == .false. .
|
[out] | inwork | : The output scalar of type logical of default kind LK.
-
If
.true. , the FFT result is stored in the output work argument upon return from the procedure.
-
If
.false. , the FFT result is stored in the output data argument upon return from the procedure.
|
Possible calling interfaces ⛓
call setFFTF(factor(:), coef(
1:
size(data)),
data(:), work(
1:
size(data)), inwork)
Return the Forward Fourier Transform (or equivalently, the Fourier coefficients) of a periodic sequen...
This module contains procedures and generic interfaces for computing the Discrete Fourier Transform o...
- Warning
- The condition
size(data) == size(coef)
must hold for the corresponding input arguments.
The condition size(data) == size(work)
must hold for the corresponding input arguments.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1
.
-
The
pure
procedure(s) documented herein become impure
when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1
.
By default, these procedures are pure
in release
build and impure
in debug
and testing
builds.
- See also
- getFFTF
getFFTR
getFFTI
setFFTF
setFFTR
setFFTI
Example usage ⛓
12 integer(IK),
allocatable :: factor(:)
14 type(display_type) :: disp
19 complex(CKG),
allocatable :: data(:), coef(:), work(:)
21 call disp%show(
"data = [complex(CKG) :: (1., -6.), (2., -5.), (3., -4.), (4., -3.), (5., -2.), (6., -1.)]")
22 data = [
complex(CKG) :: (
1.,
-6.), (
2.,
-5.), (
3.,
-4.), (
4.,
-3.), (
5.,
-2.), (
6.,
-1.)]
23 call disp%show(
"if (allocated(coef)) deallocate(coef); allocate(coef, mold = data)")
24 if (
allocated(coef))
deallocate(coef);
allocate(coef,
mold = data)
25 call disp%show(
"if (allocated(work)) deallocate(work); allocate(work, mold = data)")
26 if (
allocated(work))
deallocate(work);
allocate(work,
mold = data)
27 call disp%show(
"factor = getfactorFFT(data, coef)")
28 factor
= getfactorFFT(data, coef)
33 call disp%show(
"call setFFTF(factor, coef, data, work, inwork)")
34 call setFFTF(factor, coef, data, work, inwork)
35 call disp%show(
"if (inwork) data = work")
36 if (inwork)
data = work
40 call disp%show(
"call setFFTR(factor, coef, data, work, inwork)")
41 call setFFTR(factor, coef, data, work, inwork)
42 call disp%show(
"if (inwork) data = work")
43 if (inwork)
data = work
51 complex(CKG),
allocatable :: data(:), coef(:), work(:)
53 call disp%show(
"data = [complex(CKG) :: (1., -6.), (2., -5.), (3., -4.), (4., -3.), (5., -2.), (6., -1.)]")
54 data = [
complex(CKG) :: (
1.,
-6.), (
2.,
-5.), (
3.,
-4.), (
4.,
-3.), (
5.,
-2.), (
6.,
-1.)]
55 call disp%show(
"if (allocated(coef)) deallocate(coef); allocate(coef, mold = data)")
56 if (
allocated(coef))
deallocate(coef);
allocate(coef,
mold = data)
57 call disp%show(
"if (allocated(work)) deallocate(work); allocate(work, mold = data)")
58 if (
allocated(work))
deallocate(work);
allocate(work,
mold = data)
59 call disp%show(
"factor = getfactorFFT(data, coef)")
60 factor
= getfactorFFT(data, coef)
65 call disp%show(
"call setFFTF(factor, coef, data, work, inwork)")
66 call setFFTF(factor, coef, data, work, inwork)
67 call disp%show(
"if (inwork) data = work")
68 if (inwork)
data = work
72 call disp%show(
"call setFFTR(factor, coef, data, work, inwork)")
73 call setFFTR(factor, coef, data, work, inwork)
74 call disp%show(
"if (inwork) data = work")
75 if (inwork)
data = work
83 complex(CKG),
allocatable :: data(:), coef(:), work(:)
85 call disp%show(
"data = [complex(CKG) :: (1., -6.), (2., -5.), (3., -4.), (4., -3.), (5., -2.), (6., -1.)]")
86 data = [
complex(CKG) :: (
1.,
-6.), (
2.,
-5.), (
3.,
-4.), (
4.,
-3.), (
5.,
-2.), (
6.,
-1.)]
87 call disp%show(
"if (allocated(coef)) deallocate(coef); allocate(coef, mold = data)")
88 if (
allocated(coef))
deallocate(coef);
allocate(coef,
mold = data)
89 call disp%show(
"if (allocated(work)) deallocate(work); allocate(work, mold = data)")
90 if (
allocated(work))
deallocate(work);
allocate(work,
mold = data)
91 call disp%show(
"factor = getfactorFFT(data, coef)")
92 factor
= getfactorFFT(data, coef)
97 call disp%show(
"call setFFTF(factor, coef, data, work, inwork)")
98 call setFFTF(factor, coef, data, work, inwork)
99 call disp%show(
"if (inwork) data = work")
100 if (inwork)
data = work
104 call disp%show(
"call setFFTR(factor, coef, data, work, inwork)")
105 call setFFTR(factor, coef, data, work, inwork)
106 call disp%show(
"if (inwork) data = work")
107 if (inwork)
data = work
115 real(RKG),
allocatable :: data(:), coef(:), work(:)
117 call disp%show(
"data = [real(RKG) :: 1., 2., 3., 4., 5., 6.5]")
118 data = [
real(RKG) ::
1.,
2.,
3.,
4.,
5.,
6.5]
119 call disp%show(
"if (allocated(coef)) deallocate(coef); allocate(coef, mold = data)")
120 if (
allocated(coef))
deallocate(coef);
allocate(coef,
mold = data)
121 call disp%show(
"if (allocated(work)) deallocate(work); allocate(work, mold = data)")
122 if (
allocated(work))
deallocate(work);
allocate(work,
mold = data)
123 call disp%show(
"factor = getfactorFFT(data, coef)")
124 factor
= getfactorFFT(data, coef)
129 call disp%show(
"call setFFTF(factor, coef, data, work, inwork)")
130 call setFFTF(factor, coef, data, work, inwork)
131 call disp%show(
"if (inwork) data = work")
132 if (inwork)
data = work
136 call disp%show(
"call setFFTR(factor, coef, data, work, inwork)")
137 call setFFTR(factor, coef, data, work, inwork)
138 call disp%show(
"if (inwork) data = work")
139 if (inwork)
data = work
147 real(RKG),
allocatable :: data(:), coef(:), work(:)
149 call disp%show(
"data = [real(RKG) :: 1., 2., 3., 4., 5., 6.5]")
150 data = [
real(RKG) ::
1.,
2.,
3.,
4.,
5.,
6.5]
151 call disp%show(
"if (allocated(coef)) deallocate(coef); allocate(coef, mold = data)")
152 if (
allocated(coef))
deallocate(coef);
allocate(coef,
mold = data)
153 call disp%show(
"if (allocated(work)) deallocate(work); allocate(work, mold = data)")
154 if (
allocated(work))
deallocate(work);
allocate(work,
mold = data)
155 call disp%show(
"factor = getfactorFFT(data, coef)")
156 factor
= getfactorFFT(data, coef)
161 call disp%show(
"call setFFTF(factor, coef, data, work, inwork)")
162 call setFFTF(factor, coef, data, work, inwork)
163 call disp%show(
"if (inwork) data = work")
164 if (inwork)
data = work
168 call disp%show(
"call setFFTR(factor, coef, data, work, inwork)")
169 call setFFTR(factor, coef, data, work, inwork)
170 call disp%show(
"if (inwork) data = work")
171 if (inwork)
data = work
179 real(RKG),
allocatable :: data(:), coef(:), work(:)
181 call disp%show(
"data = [real(RKG) :: 1., 2., 3., 4., 5., 6.5]")
182 data = [
real(RKG) ::
1.,
2.,
3.,
4.,
5.,
6.5]
183 call disp%show(
"if (allocated(coef)) deallocate(coef); allocate(coef, mold = data)")
184 if (
allocated(coef))
deallocate(coef);
allocate(coef,
mold = data)
185 call disp%show(
"if (allocated(work)) deallocate(work); allocate(work, mold = data)")
186 if (
allocated(work))
deallocate(work);
allocate(work,
mold = data)
187 call disp%show(
"factor = getfactorFFT(data, coef)")
188 factor
= getfactorFFT(data, coef)
193 call disp%show(
"call setFFTF(factor, coef, data, work, inwork)")
194 call setFFTF(factor, coef, data, work, inwork)
195 call disp%show(
"if (inwork) data = work")
196 if (inwork)
data = work
200 call disp%show(
"call setFFTR(factor, coef, data, work, inwork)")
201 call setFFTR(factor, coef, data, work, inwork)
202 call disp%show(
"if (inwork) data = work")
203 if (inwork)
data = work
Allocate or resize (shrink or expand) an input allocatable scalar string or array of rank 1....
Return the Reverse (unnormalized) Fourier Transform of a periodic sequence of type complex or real of...
This is a generic method of the derived type display_type with pass attribute.
This is a generic method of the derived type display_type with pass attribute.
This module contains procedures and generic interfaces for resizing allocatable arrays of various typ...
This module contains classes and procedures for input/output (IO) or generic display operations on st...
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter CKH
The scalar integer constant of intrinsic default kind, representing the highest-precision complex kin...
integer, parameter CKS
The single-precision complex kind in Fortran mode. On most platforms, this is a 32-bit real kind.
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
integer, parameter CKD
The double precision complex kind in Fortran mode. On most platforms, this is a 64-bit real kind.
integer, parameter RKD
The double precision real kind in Fortran mode. On most platforms, this is an 64-bit real kind.
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
integer, parameter RKH
The scalar integer constant of intrinsic default kind, representing the highest-precision real kind t...
integer, parameter RKS
The single-precision real kind in Fortran mode. On most platforms, this is an 32-bit real kind.
Generate and return an object of type display_type.
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example output ⛓
2data = [
complex(CKG) :: (
1.,
-6.), (
2.,
-5.), (
3.,
-4.), (
4.,
-3.), (
5.,
-2.), (
6.,
-1.)]
3if (
allocated(coef))
deallocate(coef);
allocate(coef,
mold = data)
4if (
allocated(work))
deallocate(work);
allocate(work,
mold = data)
5factor
= getfactorFFT(data, coef)
7(
+1.00000000,
+0.00000000), (
+0.499999970,
+0.866025448), (
-0.500000060,
+0.866025388), (
+1.00000000,
+0.00000000), (
+1.00000000,
+0.00000000), (
-0.499999911,
-0.866025448)
10call setFFTF(factor, coef, data, work, inwork)
11if (inwork)
data = work
13(
+21.0000000,
-21.0000000), (
-8.19615173,
+2.19615269), (
-4.73205090,
-1.26794922), (
-3.00000000,
-2.99999976), (
-1.26794922,
-4.73205090), (
+2.19615221,
-8.19615269)
15call setFFTR(factor, coef, data, work, inwork)
16if (inwork)
data = work
18(
+1.00000000,
-6.00000000), (
+2.00000000,
-5.00000000), (
+3.00000000,
-4.00000000), (
+4.00000000,
-3.00000000), (
+5.00000000,
-2.00000024), (
+6.00000000,
-1.00000000)
21data = [
complex(CKG) :: (
1.,
-6.), (
2.,
-5.), (
3.,
-4.), (
4.,
-3.), (
5.,
-2.), (
6.,
-1.)]
22if (
allocated(coef))
deallocate(coef);
allocate(coef,
mold = data)
23if (
allocated(work))
deallocate(work);
allocate(work,
mold = data)
24factor
= getfactorFFT(data, coef)
26(
+1.0000000000000000,
+0.0000000000000000), (
+0.50000000000000011,
+0.86602540378443860), (
-0.49999999999999978,
+0.86602540378443871), (
+1.0000000000000000,
+0.0000000000000000), (
+1.0000000000000000,
+0.0000000000000000), (
-0.50000000000000044,
-0.86602540378443837)
29call setFFTF(factor, coef, data, work, inwork)
30if (inwork)
data = work
32(
+21.000000000000000,
-21.000000000000000), (
-8.1961524227066320,
+2.1961524227066302), (
-4.7320508075688767,
-1.2679491924311228), (
-2.9999999999999991,
-3.0000000000000000), (
-1.2679491924311228,
-4.7320508075688767), (
+2.1961524227066320,
-8.1961524227066302)
34call setFFTR(factor, coef, data, work, inwork)
35if (inwork)
data = work
37(
+1.0000000000000000,
-6.0000000000000000), (
+2.0000000000000004,
-4.9999999999999991), (
+3.0000000000000004,
-4.0000000000000000), (
+4.0000000000000009,
-3.0000000000000000), (
+4.9999999999999991,
-2.0000000000000000), (
+6.0000000000000000,
-1.0000000000000004)
40data = [
complex(CKG) :: (
1.,
-6.), (
2.,
-5.), (
3.,
-4.), (
4.,
-3.), (
5.,
-2.), (
6.,
-1.)]
41if (
allocated(coef))
deallocate(coef);
allocate(coef,
mold = data)
42if (
allocated(work))
deallocate(work);
allocate(work,
mold = data)
43factor
= getfactorFFT(data, coef)
45(
+1.00000000000000000000000000000000000,
+0.00000000000000000000000000000000000), (
+0.499999999999999999999999999999999952,
+0.866025403784438646763723170752936161), (
-0.500000000000000000000000000000000096,
+0.866025403784438646763723170752936161), (
+1.00000000000000000000000000000000000,
+0.00000000000000000000000000000000000), (
+1.00000000000000000000000000000000000,
+0.00000000000000000000000000000000000), (
-0.499999999999999999999999999999999856,
-0.866025403784438646763723170752936257)
48call setFFTF(factor, coef, data, work, inwork)
49if (inwork)
data = work
51(
+21.0000000000000000000000000000000000,
-21.0000000000000000000000000000000000), (
-8.19615242270663188058233902451761697,
+2.19615242270663188058233902451761774), (
-4.73205080756887729352744634150587232,
-1.26794919243112270647255365849412768), (
-3.00000000000000000000000000000000077,
-3.00000000000000000000000000000000039), (
-1.26794919243112270647255365849412768,
-4.73205080756887729352744634150587232), (
+2.19615242270663188058233902451761774,
-8.19615242270663188058233902451761851)
53call setFFTR(factor, coef, data, work, inwork)
54if (inwork)
data = work
56(
+1.00000000000000000000000000000000000,
-6.00000000000000000000000000000000000), (
+2.00000000000000000000000000000000000,
-5.00000000000000000000000000000000000), (
+3.00000000000000000000000000000000000,
-4.00000000000000000000000000000000000), (
+4.00000000000000000000000000000000000,
-3.00000000000000000000000000000000000), (
+5.00000000000000000000000000000000000,
-2.00000000000000000000000000000000000), (
+6.00000000000000000000000000000000000,
-1.00000000000000000000000000000000000)
59data = [
real(RKG) ::
1.,
2.,
3.,
4.,
5.,
6.5]
60if (
allocated(coef))
deallocate(coef);
allocate(coef,
mold = data)
61if (
allocated(work))
deallocate(work);
allocate(work,
mold = data)
62factor
= getfactorFFT(data, coef)
64+0.499999970,
+0.866025448,
+0.00000000,
+0.00000000,
+0.145802732E-18,
+0.378001102E-38
67call setFFTF(factor, coef, data, work, inwork)
68if (inwork)
data = work
70+21.5000000,
-2.75000000,
+5.62916517,
-3.25000000,
+2.16506338,
-3.50000000
72call setFFTR(factor, coef, data, work, inwork)
73if (inwork)
data = work
75+1.00000000,
+1.99999988,
+3.00000000,
+4.00000000,
+5.00000000,
+6.50000000
78data = [
real(RKG) ::
1.,
2.,
3.,
4.,
5.,
6.5]
79if (
allocated(coef))
deallocate(coef);
allocate(coef,
mold = data)
80if (
allocated(work))
deallocate(work);
allocate(work,
mold = data)
81factor
= getfactorFFT(data, coef)
83+0.50000000000000011,
+0.86602540378443860,
-536871043.12500000,
-67108880.437500000,
-2097154.5151367188,
-8192.0020160675049
86call setFFTF(factor, coef, data, work, inwork)
87if (inwork)
data = work
89+21.500000000000000,
-2.7500000000000009,
+5.6291651245988508,
-3.2499999999999991,
+2.1650635094610968,
-3.5000000000000000
91call setFFTR(factor, coef, data, work, inwork)
92if (inwork)
data = work
94+1.0000000000000000,
+1.9999999999999998,
+3.0000000000000000,
+4.0000000000000000,
+5.0000000000000000,
+6.5000000000000000
97data = [
real(RKG) ::
1.,
2.,
3.,
4.,
5.,
6.5]
98if (
allocated(coef))
deallocate(coef);
allocate(coef,
mold = data)
99if (
allocated(work))
deallocate(work);
allocate(work,
mold = data)
100factor
= getfactorFFT(data, coef)
102+0.499999999999999999999999999999999952,
+0.866025403784438646763723170752936161,
-144115188075856000.390625000000000028,
-2251799813685250.00683593750000000043,
-2199023255552.00196051597595214843708,
-33554432.0000003875502443406730890274
105call setFFTF(factor, coef, data, work, inwork)
106if (inwork)
data = work
108+21.5000000000000000000000000000000000,
-2.75000000000000000000000000000000000,
+5.62916512459885120396420060989408543,
-3.25000000000000000000000000000000000,
+2.16506350946109661690930792688234040,
-3.50000000000000000000000000000000000
110call setFFTR(factor, coef, data, work, inwork)
111if (inwork)
data = work
113+1.00000000000000000000000000000000000,
+2.00000000000000000000000000000000000,
+3.00000000000000000000000000000000000,
+4.00000000000000000000000000000000000,
+5.00000000000000000000000000000000000,
+6.50000000000000000000000000000000000
- Test:
- test_pm_fftpack
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.
-
If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
-
If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.
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.
- Copyright
- Computational Data Science Lab
- Author:
- Fatemeh Bagheri, Tuesday 11:34 PM, August 10, 2021, Dallas, TX
Definition at line 949 of file pm_fftpack.F90.