QCOSI

Computes parameters needed by QCOSF and QCOSB.

Required Arguments

N — Length of the sequence to be transformed. (Input)

WQCOS — Array of length 3N + 15 containing parameters needed by QCOSF and QCOSB. (Output)

FORTRAN 90 Interface

Generic: CALL QCOSI (N, WQCOS)

Specific: The specific interface names are S_QCOSI and D_QCOSI.

FORTRAN 77 Interface

Single: CALL QCOSI (N, WQCOS)

Double: The double precision name is DQCOSI.

Description

The routine QCOSI initializes the functions QCOSF and QCOSB. An efficient way to make multiple calls for the same N to IMSL routine QCOSF or QCOSB is to use routine QCOSI for initialization. (In this case, replace QCOSF or QCOSB with Q2OSF or Q2OSB , respectively.) The routine QCOSI is based on the routine COSQI in FFTPACK, which was developed by Paul Swarztrauber at the National Center for Atmospheric Research.

Comments

Different WQCOS arrays are needed for different values of N.

Example

In this example, we compute three distinct quarter cosine transforms by calling QCOSI once and then calling Q2OSF three times.

 

USE QCOSI_INT

USE CONST_INT

USE Q2OSF_INT

USE UMACH_INT

 

IMPLICIT NONE

INTEGER N

PARAMETER (N=7)

!

INTEGER I, K, NOUT

REAL COEF(N), COS, FLOAT, PI, WQCOS(36), SEQ(N)

INTRINSIC COS, FLOAT

! Get output unit number

CALL UMACH (2, NOUT)

! Initialize the work vector WQCOS

CALL QCOSI (N, WQCOS)

! Different frequencies of the same

! wave will be transformed

PI = CONST('PI')

DO 20 K=1, 3

! Fill the data vector SEQ

! with a pure cosine wave

DO 10 I=1, N

SEQ(I) = COS(FLOAT((2*K-1)*(I-1))*(PI/2.0)/FLOAT(N))

10 CONTINUE

! Compute the transform of SEQ

CALL Q2OSF (N, SEQ, COEF, WQCOS)

! Print results

WRITE (NOUT,99998)

WRITE (NOUT,99999) (I, SEQ(I), COEF(I), I=1,N)

20 CONTINUE

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

 

INDEX SEQ COEF

1 1.00 0.00

2 0.78 7.00

3 0.22 0.00

4 -0.43 0.00

5 -0.90 0.00

6 -0.97 0.00

7 -0.62 0.00

 

INDEX SEQ COEF

1 1.00 0.00

2 0.43 0.00

3 -0.62 7.00

4 -0.97 0.00

5 -0.22 0.00

6 0.78 0.00

7 0.90 0.00