|
|
◆ Rfft2c()
| Sub Rfft2c |
( |
L As |
Long, |
|
|
M As |
Long, |
|
|
R() As |
Double, |
|
|
C() As |
Complex, |
|
|
Info As |
Long |
|
) |
| |
Full complex data of two-dimensional Fourier transform obtained by Rfft2f
- Purpose
- This routine reconstructs the full complex data from the packed two-dimensional Fourier transform obtained by Rfft2f. Refer to the description of Rfft2f for the details of packed form.
- Parameters
-
| [in] | L | Number of elements to be transformed in the first dimension of the two-dimensional array R(). (L >= 1) |
| [in] | M | Number of elements to be transformed in the second dimension of the two-dimensional array R(). (M >= 1) |
| [in,out] | R() | Array R(LR1 - 1, LR2 - 1) (LR1 >= L, LR2 >= M)
Two dimensional Fourier forward transform data in packed form obtained by Rfft2f. |
| [in] | C() | Array C(LC1 - 1, LC2 - 1) (LC1 >= L, LC2 >= M)
The full complex data reconstructed from the packed two-dimensional Fourier transform in R(). |
| [out] | Info | = 0: Successful exit.
= -1: The argument L had an illegal value. (L < 1)
= -2: The argument M had an illegal value. (M < 1)
= -3: The argument R() is invalid. (Array R() is not big enough)
= -5: The argument C() is invalid. (Array C() is not big enough) |
- Example Program
- Compute the two-dimensional Fourier transform of 4 rows x 4 columns random data sequence by Rfft2f. Reconstruct the full complex data from the obtained packed data by Rfft2c. Then compute the backward transform by Cfft2b and compare with the original data sequence.
Sub Ex_Rfft2c()
Const L = 4, M = 4
Dim Wsave() As Double, R(L - 1, M - 1) As Double, R0(L - 1, M - 1) As Double
Dim C(L - 1, M - 1) As Complex
Dim LWsave As Long, Info As Long, I As Long, J As Long
'-- Initialization
LWsave = L + 3 * M + Log(L) / Log(2) + 2 * Log(M) / Log(2) + 12
ReDim Wsave(LWsave - 1)
Call Rfft2i(L, M, Wsave, Info)
If Info <> 0 Then GoTo Err
'-- Generate test data
For I = 0 To L - 1
For J = 0 To M - 1
R(I, J) = Rnd()
R0(I, J) = R(I, J)
Next
Next
'-- Forward transform
Call Rfft2f(L, M, R(), Wsave(), Info)
If Info <> 0 Then GoTo Err
'-- Convert to full complex data
Call Rfft2c(L, M, R(), C(), Info)
LWsave = 2 * (L + M) + Log(L) / Log(2) + Log(M) / Log(2) + 8
ReDim Wsave(LWsave - 1)
Call Cfft2i(L, M, Wsave, Info)
If Info <> 0 Then GoTo Err
'-- Backward transform by Cfft2b
Call Cfft2b(L, M, C(), Wsave(), Info)
If Info <> 0 Then GoTo Err
'-- Print result
For J = 0 To M - 1
For I = 0 To L - 1
Debug.Print R0(I, J), Creal(C(I, J)), Cimag(C(I, J)), Creal(C(I, J)) - R0(I, J)
Next
Debug.Print
Next
Exit Sub
Err:
End Sub
Function Cimag(A As Complex) As Double Imaginary part of complex number
Function Creal(A As Complex) As Double Real part of complex number
Sub Rfft2c(L As Long, M As Long, R() As Double, C() As Complex, Info As Long) Full complex data of two-dimensional Fourier transform obtained by Rfft2f
Sub Rfft2i(L As Long, M As Long, Wsave() As Double, Info As Long) Initialization of work data for Rfft2f and Rfft2b
Sub Rfft2f(L As Long, M As Long, R() As Double, Wsave() As Double, Info As Long) Two-dimensional real Fourier transform
Sub Cfft2b(L As Long, M As Long, C() As Complex, Wsave() As Double, Info As Long) Two-dimensional complex Fourier backward transform
Sub Cfft2i(L As Long, M As Long, Wsave() As Double, Info As Long) Initialization of work data for Cfft2f and Cfft2b
Sub Rfft2b(L As Long, M As Long, R() As Double, Wsave() As Double, Info As Long) Two-dimensional real Fourier backward transform
- Example Results
0.902888596057892 0.902888596057892 0 0
0.449173510074615 0.449173510074615 0 0
0.91016560792923 0.91016560792923 0 0
0.415564596652985 0.415564596652985 0 0
0.419061899185181 0.419061899185181 0 0
0.52361536026001 0.52361536026001 0 0
0.356703519821167 0.356703519821167 0 0
0.341727256774902 0.341727256774902 0 0
0.614621579647064 0.614621579647064 0 0
0.320736587047577 0.320736587047577 0 0
0.423278748989105 0.423278748989105 0 0
0.214545428752899 0.214545428752899 0 0
0.733203768730164 0.733203768730164 0 0
0.805532574653625 0.805532574653625 0 0
0.942486166954041 0.942486166954041 0 0
0.579672455787659 0.579672455787659 0 0
|