XLPack 7.0
XLPack Numerical Library (Excel VBA) Reference Manual
Loading...
Searching...
No Matches

◆ Sintmf()

Sub Sintmf ( 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 sine transform (multiple sequences)

Purpose
This routine computes the one-dimensional Fourier transform of multiple odd sequences within a real array. 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+1))ΣR(l*jump+j)sin(π(j+1)(k+1)/(N+1)) (Σ for j = 0 to N-1) (l = 0 to lot-1, k = 0 to N-1)
This transform is normalized since a call to Sintmf followed by a call to Sintmb (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+1 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 >= N/2 + N + ln(N)/ln(2) + 4)
Work data. Its contents must be initialized with a call to Sintmi before the first call to Sintmf or Sintmb 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_Sintm()
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 = N / 2 + N + Log(N) / Log(2) + 4
ReDim Wsave(LWsave - 1)
Call Sintmi(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 Sintmf(Lot, Jump, N, R(), Wsave(), Info)
If Info <> 0 Then GoTo Err
'-- Backward transform
Call Sintmb(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 Sintmi/Sintmf/Sintmb: Info =", Info
End Sub
Sub Sintmi(N As Long, Wsave() As Double, Info As Long)
Initialization of work data for Sintmf and Sintmb
Sub Sintmb(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 sine backward transform (multiple sequences)
Sub Sintmf(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 sine transform (multiple sequences)
Example Results
0.347031235694885 0.347031235694886 2.77555756156289E-16
0.72561103105545 0.72561103105545 0
9.05430316925049E-02 0.090543031692505 1.66533453693773E-16
0.181232869625092 0.181232869625091 -1.66533453693773E-16
0.290205836296082 0.290205836296082 2.22044604925031E-16
7.65949487686157E-03 7.65949487686185E-03 2.77555756156289E-16
0.159680843353271 0.159680843353271 -5.55111512312578E-17
0.477969825267792 0.477969825267792 -5.55111512312578E-17
0.137543797492981 0.137543797492981 0
0.502999126911163 0.502999126911163 -5.55111512312578E-16