QCOSF
Computes the coefficients of the cosine Fourier transform with only odd wave numbers.
Required Arguments
N — Length of the sequence to be transformed. (Input)
SEQ — Array of length N containing the sequence. (Input)
COEF — Array of length N containing the Fourier coefficients. (Output)
FORTRAN 90 Interface
Generic: CALL QCOSF (N, SEQ, COEF [])
Specific: The specific interface names are S_QCOSF and D_QCOSF.
FORTRAN 77 Interface
Single: CALL QCOSF (N, SEQ, COEF)
Double: The double precision name is DQCOSF.
Description
The routine QCOSF computes the discrete Fourier quarter cosine transform of a real vector of size N. The method used is a variant of the Cooley-Tukey algorithm, which is most efficient when N is a product of small prime factors. If N satisfies this condition, then the computational effort is proportional to N log N.
Specifically, given an N-vector s = SEQ, QCOSF returns in c = COEF
Finally, note that the Fourier quarter cosine transform has an (unnormalized) inverse which is implemented in QCOSB. The routine QCOSF is based on the quarter cosine FFT in FFTPACK. The package FFTPACK was developed by Paul Swarztrauber at the National Center for Atmospheric Research.
Comments
1. Workspace may be explicitly provided, if desired, by use of Q2OSF/DQ2OSF. The reference is:
CALL Q2OSF (N, SEQ, COEF, WQCOS)
The additional argument is:
WQCOS — Array of length 3 * N + 15 initialized by QCOSI. The initialization depends on N. (Input)
2. The routine QCOSF is most efficient when N is the product of small primes.
3. The arrays COEF and SEQ may be the same.
4. If QCOSF/QCOSB is used repeatedly with the same value of N, then call QCOSI followed by repeated calls to Q2OSF/Q2OSB. This is more efficient than repeated calls to QCOSF/QCOSB.
Example
In this example, we input a pure quarter cosine wave as a data vector and recover its Fourier quarter cosine series.
 
USE QCOSF_INT
USE CONST_INT
USE UMACH_INT
 
IMPLICIT NONE
INTEGER N
PARAMETER (N=7)
!
INTEGER I, NOUT
REAL COEF(N), COS, FLOAT, PI, SEQ(N)
INTRINSIC COS, FLOAT
! Get output unit number
CALL UMACH (2, NOUT)
! Fill the data vector SEQ
! with a pure cosine wave
PI = CONST('PI')
DO 10 I=1, N
SEQ(I) = COS(FLOAT(I-1)*(PI/2.0)/FLOAT(N))
10 CONTINUE
 
! Compute the transform of SEQ
Call QCOSF (N, SEQ, COEF)
! Print results
WRITE (NOUT,99998)
WRITE (NOUT,99999) (I, SEQ(I), COEF(I), I=1,N)
99998 FORMAT (9X, 'INDEX', 6X, 'SEQ', 7X, 'COEF')
99999 FORMAT (1X, I11, 5X, F6.2, 5X, F6.2)
END
Output
 
INDEX SEQ COEF
1 1.00 7.00
2 0.97 0.00
3 0.90 0.00
4 0.78 0.00
5 0.62 0.00
6 0.43 0.00
7 0.22 0.00
Published date: 03/19/2020
Last modified date: 03/19/2020