XLPack 6.0
Excel VBA Numerical Library Reference Manual
Loading...
Searching...
No Matches

◆ Sinqmf()

Sub Sinqmf ( Lot As  Long,
Jump As  Long,
N As  Long,
R() As  Double,
Wsave() As  Double,
Info As  Long,
Optional Inc As  Long = 1 
)

One-dimensional quarter sine transform (multiple sequences)

Purpose
This routine computes the one-dimensional Fourier transform of multiple sequences within a real array, where each of a sequence is a sine series with odd wave numbers. This is referred to as the forward transform or Fourier analysis, transforming the sequence from physical to spectral space.
R(l*jump+k) = (2/N)ΣR(l*jump+j)sin(π(j+1)(2k+1)/(2n)) + (-1)^(k+2)R(l*jump+N-1)/N (Σ for j = 0 to N-2) (l = 0 to lot-1, k = 0 to N-1)
This transform is normalized since a call to Sinqmf followed by a call to Sinqmb (or vice-versa) reproduces the original array subject to algorithmic constraints, roundoff error, etc.
Parameters
[in]LotNumber of sequences to be transformed. (Lot >= 1)
[in]JumpIncrement between the locations, in array R(), of the first elements of two consecutive sequences to be transformed. (Jump >= 1)
[in]NLength of the sequence to be transformed. (N >= 1) (The transform is most efficient when N is a product of small primes)
[in,out]R()Array R(LR - 1) (LR >= (Lot - 1)*Jump + Inc*(N - 1) + 1)
[in] The sequences to be transformed.
[out] The Fourier forward transformed sequences of data.
[in]Wsave()Array Wsave(LWsave - 1) (LWsave >= 2*N + ln(N)/ln(2) + 4)
Work data. Its contents must be initialized with a call to Sinqmi before the first call to Sinqmf or Sinqmb for a given transform length N.
[out]Info= 0: Successful exit.
= -1: The argument Lot had an illegal value. (Lot < 1, or, Lot, Jump, N and Inc are inconsistent)
= -2: The argument Jump had an illegal value. (Jump < 1)
= -3: The argument N had an illegal value. (N < 1)
= -4: The argument R() had an illegal value. (Array R() is not big enough)
= -5: The argument Wsave() had an illegal value. (Array Wsave() is not big enough)
= -7: The argument Inc had an illegal value. (Inc < 1)
[in]Inc(Optional)
Integer increment between the locations, in array R(), of two consecutive elements within the sequence. (Inc >= 1) (default = 1)
Reference
FFTPACK
Example Program
Compute the sine transform and backward transform of 2 sequences of 5 random data successively, and compare with the original data sequences.
Sub Ex_Sinqm()
Const N = 5, Lot = 2, Jump = N
Dim Wsave() As Double, R(Lot * N - 1) As Double, R0(Lot * N - 1) As Double
Dim LWsave As Long, Info As Long, I As Long, J As Long, K As Long
'-- Initialization
LWsave = 2 * N + Log(N) / Log(2) + 4
ReDim Wsave(LWsave - 1)
Call Sinqmi(N, Wsave, Info)
If Info <> 0 Then GoTo Err
'-- Generate test data
For I = 0 To Lot * N - 1
R(I) = Rnd()
R0(I) = R(I)
Next
'-- Forward transform
Call Sinqmf(Lot, Jump, N, R(), Wsave(), Info)
If Info <> 0 Then GoTo Err
'-- Backward transform
Call Sinqmb(Lot, Jump, N, R(), Wsave(), Info)
If Info <> 0 Then GoTo Err
'-- Print result
For J = 0 To Lot - 1
For I = 0 To N - 1
K = J * Jump + I
Debug.Print R0(K), R(K), R(K) - R0(K)
Next
Debug.Print
Next
Exit Sub
Err:
Debug.Print "Error in Sinqmi/Sinqmf/Sinqmb: Info =", Info
End Sub
Example Results
0.803530812263489 0.803530812263489 0
0.63199120759964 0.63199120759964 0
4.37657833099365E-02 4.37657833099366E-02 5.55111512312578E-17
0.804474771022797 0.804474771022797 0
0.471749663352966 0.471749663352966 1.11022302462516E-16
0.809219419956207 0.809219419956207 2.22044604925031E-16
0.216426849365234 0.216426849365234 1.11022302462516E-16
0.423454463481903 0.423454463481903 1.11022302462516E-16
0.453921914100647 0.453921914100647 1.66533453693773E-16
0.595368683338165 0.595368683338165 1.11022302462516E-16