Sub Ex_Cosq1()
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 = 2 * N + Log(N) / Log(2) + 4
ReDim Wsave(LWsave - 1)
Call Cosq1i(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 Cosq1f(N, R(), Wsave(), Info)
If Info <> 0 Then GoTo Err
'-- Backward transform
Call Cosq1b(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 Cosq1i/Cosq1f/Cosq1b: Info =", Info
End Sub