FFT2D

   more...
Computes Fourier coefficients of a complex periodic two-dimensional array.
Required Arguments
ANRA by NCA complex matrix containing the periodic data to be transformed. (Input)
COEFNRA by NCA complex matrix containing the Fourier coefficients of A. (Output)
Optional Arguments
NRA — The number of rows of A. (Input)
Default: NRA = size (A,1).
NCA — The number of columns of A. (Input)
Default: NCA = size (A,2).
LDA — Leading dimension of A exactly as specified in the dimension statement of the calling program. (Input)
Default: LDA = size (A,1).
LDCOEF — Leading dimension of COEF exactly as specified in the dimension statement of the calling program. (Input)
Default: LDCOEF = size (COEF,1).
FORTRAN 90 Interface
Generic: CALL FFT2D (A, COEF [])
Specific: The specific interface names are S_FFT2D and D_FFT2D.
FORTRAN 77 Interface
Single: CALL FFT2D (NRA, NCA, A, LDA, COEF, LDCOEF)
Double: The double precision name is DFFT2D.
Description
The routine FFT2D computes the discrete complex Fourier transform of a complex two dimensional array of size (NRA = N× (NCA = M). It uses the Intel® Math Kernel Library, Sun Performance Library or IBM Engineering and Scientific Subroutine Library for the computation, if available. Otherwise, the method used is a variant of the Cooley-Tukey algorithm , which is most efficient when N and M are each products of small prime factors. If N and M satisfy this condition, then the computational effort is proportional to N M log N M. This considerable savings has historically led people to refer to this algorithm as the “fast Fourier transform” or FFT.
Specifically, given an N × M array a, FFT2D returns in c = COEF
Furthermore, a vector of Euclidean norm S is mapped into a vector of norm
Finally, note that an unnormalized inverse is implemented in FFT2B. The routine FFT2D is based on the complex FFT in FFTPACK. The package FFTPACK was developed by Paul Swarztrauber at the National Center for Atmospheric Research.
Comments
1. Workspace may be explicitly provided, if desired, by use of F2T2D/DF2T2D. The reference is:
CALL F2T2D (NRA, NCA, A, LDA, COEF, LDCOEF, WFF1, WFF2, CWK, CPY)
The additional arguments are as follows:
WFF1 — Real array of length 4 * NRA + 15 initialized by FFTCI. The initialization depends on NRA. (Input)
WFF2 — Real array of length 4 * NCA + 15 initialized by FFTCI. The initialization depends on NCA. (Input)
CWK — Complex array of length 1. (Workspace)
CPY — Real array of length 2 * MAX(NRA, NCA). (Workspace)
If the Intel® Math Kernel Library, Sun Performance Library or IBM Engineering and Scientific Subroutine Library is used, WFFT1, WFF2, CWK, and CPY are not referenced.
2. The routine FFT2D is most efficient when NRA and NCA are the product of small primes.
3. The arrays COEF and A may be the same.
4. If FFT2D/FFT2B is used repeatedly, with the same values for NRA and NCA, then use FFTCI to fill WFF1(N = NRA) and WFF2(N = NCA). Follow this with repeated calls to F2T2D/F2T2B. This is more efficient than repeated calls to FFT2D/FFT2B.
If the Intel® Math Kernel Library, Sun Performance Library or IBM Engineering and Scientific Subroutine Library is used, parameters computed by FFTCI are not used. In this case, there is no need to call FFTCI.
Example
In this example, we compute the Fourier transform of the pure frequency input for a 5 × 4 array
for 1  n  5 and 1  m  4 using the IMSL routine FFT2D. The result
has all zeros except in the (3, 4) position.
 
USE FFT2D_INT
USE CONST_INT
USE WRCRN_INT
 
IMPLICIT NONE
INTEGER I, IR, IS, J, NCA, NRA
REAL FLOAT, TWOPI
COMPLEX A(5,4), C, CEXP, CMPLX, COEF(5,4), H
CHARACTER TITLE1*26, TITLE2*26
INTRINSIC CEXP, CMPLX, FLOAT
!
TITLE1 = 'The input matrix is below '
TITLE2 = 'The output matrix is below'
NRA = 5
NCA = 4
IR = 3
IS = 4
! Fill A with initial data
TWOPI = CONST('PI')
TWOPI = 2.0*TWOPI
C = CMPLX(0.0,1.0)
H = CEXP(TWOPI*C)
DO 10 I=1, NRA
DO 10 J=1, NCA
A(I,J) = CEXP(TWOPI*C*((FLOAT((I-1)*(IR-1))/FLOAT(NRA)+ &
FLOAT((J-1)*(IS-1))/FLOAT(NCA))))
10 CONTINUE
!
CALL WRCRN (TITLE1, A)
!
CALL FFT2D (A, COEF)
!
CALL WRCRN (TITLE2, COEF)
!
END
Output
The input matrix is below
1 2 3 4
1 ( 1.000, 0.000) ( 0.000,-1.000) (-1.000, 0.000) ( 0.000, 1.000)
2 (-0.809, 0.588) ( 0.588, 0.809) ( 0.809,-0.588) (-0.588,-0.809)
3 ( 0.309,-0.951) (-0.951,-0.309) (-0.309, 0.951) ( 0.951, 0.309)
4 ( 0.309, 0.951) ( 0.951,-0.309) (-0.309,-0.951) (-0.951, 0.309)
5 (-0.809,-0.588) (-0.588, 0.809) ( 0.809, 0.588) ( 0.588,-0.809)
 
The Output matrix is below
1 2 3 4
1 ( 0.00, 0.00) ( 0.00, 0.00) ( 0.00, 0.00) ( 0.00, 0.00)
2 ( 0.00, 0.00) ( 0.00, 0.00) ( 0.00, 0.00) ( 0.00, 0.00)
3 ( 0.00, 0.00) ( 0.00, 0.00) ( 0.00, 0.00) ( 20.00, 0.00)
4 ( 0.00, 0.00) ( 0.00, 0.00) ( 0.00, 0.00) ( 0.00, 0.00)
5 ( 0.00, 0.00) ( 0.00, 0.00) ( 0.00, 0.00) ( 0.00, 0.00)
Published date: 03/19/2020
Last modified date: 03/19/2020