FNLMath : Transforms : FAST_3DFT
FAST_3DFT

   more...
Computes the Discrete Fourier Transform (3DFT) of a rank-3 complex array.
Required Arguments
No required arguments; pairs of optional arguments are required. These pairs are forward_in and forward_out or inverse_in and inverse_out.
Optional Arguments
forward_in = x (Input)
Stores the input complex array of rank-3 to be transformed.
forward_out = y (Output)
Stores the output complex array of rank-3 resulting from the transform.
inverse_in = y (Input)
Stores the input complex array of rank-3 to be inverted.
inverse_out = x (Output)Stores the output complex array of rank-3 resulting from the inverse transform.
mdata = m (Input)
Uses the sub-array in first dimension of size m for the numbers.
Default value: m = size(x,1).
ndata = n (Input)
Uses the sub-array in the second dimension of size n for the numbers.
Default value: n = size(x,2).
kdata = k (Input)
Uses the sub-array in the third dimension of size k for the numbers.
Default value: k = size(x,3).
ido = ido (Input/Output)
Integer flag that directs user action. Normally, this argument is used only when the working variables required for the transform and its inverse are saved in the calling program unit. Computing the working variables and saving them in internal arrays within fast_3dft is the default. This initialization step is expensive.
There is a two-step process to compute the working variables just once. The general algorithm for this usage is to enter fast_3dft with ido = 0. A return occurs thereafter with ido < 0. The optional rank-1 complex array w(:) with size(w) >= –ido must be re-allocated. Then, re-enter fast_3dft. The next return from fast_3dft has the output value ido = 1. The variables required for the transform and its inverse are saved in w(:). Thereafter, when the routine is entered with ido = 1 and for the same values of m and n, the contents of w(:) will be used for the working variables. The expensive initialization step is avoided. The optional arguments “ido=” and “work_array=” must be used together.
work_array = w(:) (Output/Input)
Complex array of rank-1 used to store working variables and values between calls to fast_3dft. The value for size(w) must be at least as large as the value ‑ido for the value of ido < 0.
iopt = iopt(:) (Input/Output)Derived type array with the same precision as the input array; used for passing optional data to fast_3dft. The options are as follows:
Packaged Options for FAST_3DFT
Option Prefix = ?
Option Name
Option Value
C_, z_
fast_3dft_scan_for_NaN
1
C_, z_
fast_3dft_near_power_of_2
2
C_, z_
fast_3dft_scale_forward
3
C_, z_
fast_3dft_scale_inverse
4
iopt(IO) = ?_options(?_fast_3dft_scan_for_NaN, ?_dummy)
Examines each input array entry to find the first value such that isNaN(x(i,j,k)) ==.true.
See the isNaN() function, Chapter 10.
Default: Does not scan for NaNs.
iopt(IO) = ?_options(?_fast_3dft_near_power_of_2, ?_dummy)
Nearest powers of 2 ≥ m,  ≥ n, and  ≥ k are returned as an outputs in iopt(IO+1)%idummy , iopt(IO+2)%idummy and iopt(IO+3)%idummy
iopt(IO) = ?_options(?_fast_3dft_scale_forward, real_part_of_scale)
iopt(IO+1) = ?_options(?_dummy, imaginary_part_of_scale)
Complex number defined by the factor cmplx(real_part_of_scale, imaginary_part_of_scale) is multiplied by the forward transformed array.
Default value is 1.
iopt(IO) = ?_options(?_fast_3dft_scale_inverse, real_part_of_scale)
iopt(IO+1) = ?_options(?_dummy, imaginary_part_of_scale)
Complex number defined by the factor cmplx(real_part_of_scale, imaginary_part_of_scale) is multiplied by the inverse transformed array.
Default value is 1.
FORTRAN 90 Interface
Generic: None
Specific: The specific interface names are S_FAST_3DFT, D_FAST_3DFT, C_FAST_3DFT, and Z_FAST_3DFT.
Description
The fast_3dft routine is a Fortran 90 version of the FFT suite of IMSL (1994, pp. 772-776).
Fatal and Terminal Messages
See the messages.gls file for error messages for FAST_3DFT. These error messages are numbered 685–695; 740–750.
Example
An array of random complex numbers is obtained. The transform of the numbers is inverted and the final results are compared with the input array.
 
use fast_3dft_int
implicit none
! This is Example 1 for FAST_3DFT.
integer i, j, k
integer, parameter :: n=64
real(kind(1e0)), parameter :: one=1e0, zero=0e0
real(kind(1e0)) r(n,n,n), err
complex(kind(1e0)) a(n,n,n), b(n,n,n), c(n,n,n)
! Fill in value one for points inside the sphere
! with radius=16.
a = zero
do i=1,n
do j=1,n
do k=1,n
r(i,j,k) = (i-n/2)**2+(j-n/2)**2+(k-n/2)**2
end do
end do
end do
where (r <= (n/4)**2) a = one
c = a
! Transform the image and then invert it back.
call c_fast_3dft(forward_in=a, &
forward_out=b)
call c_fast_3dft(inverse_in=b, &
inverse_out=a)
! Check that inverse(transform(image)) = image.
err = maxval(abs(c-a))/maxval(abs(c))
if (err <= sqrt(epsilon(one))) then
write (*,*) 'Example 1 for FAST_3DFT is correct.'
end if
end
Output
 
Example 1 for FAST_3DFT is correct.
Published date: 03/19/2020
Last modified date: 03/19/2020