Sub Ex_Rfft1()
Const N = 5
Dim Wsave() As Double, R(N - 1) As Double, R0(N - 1) As Double
Dim LWsave As Long, Info As Long, I As Long
'-- Initialization
LWsave = N + Log(N) / Log(2) + 4
ReDim Wsave(LWsave - 1)
Call Rfft1i(N, Wsave, Info)
If Info <> 0 Then GoTo Err
'-- Generate test data
For I = 0 To N - 1
R(I) = Rnd()
R0(I) = R(I)
Next
'-- Forward transform
Call Rfft1f(N, R(), Wsave(), Info)
If Info <> 0 Then GoTo Err
'-- Backward transform
Call Rfft1b(N, R(), Wsave(), Info)
If Info <> 0 Then GoTo Err
'-- Print result
For I = 0 To N - 1
Debug.Print R0(I), R(I), R(I) - R0(I)
Next
Exit Sub
Err:
Debug.Print "Error in Rfft1i/Rfft1f/Rfft1b: Info =", Info
End Sub