FCOSI

Computes parameters needed by FCOST.

Required Arguments

N — Length of the sequence to be transformed. N must be greater than 1. (Input)

WFCOS — Array of length 3N + 15 containing parameters needed by FCOST. (Output)

FORTRAN 90 Interface

Generic: CALL FCOSI (N, WFCOS)

Specific: The specific interface names are S_FCOSI and D_FCOSI.

FORTRAN 77 Interface

Single: CALL FCOSI (N, WFCOS)

Double: The double precision name is DFCOSI.

Description

The routine FCOSI initializes the routine FCOST. An efficient way to make multiple calls for the same N to IMSL routine FCOST is to use routine FCOSI for initialization. (In this case, replace FCOST with F2OST.) The routine FCOSI is based on the routine COSTI in FFTPACK. The package FFTPACK was developed by Paul Swarztrauber at the National Center for Atmospheric Research.

If the IBM Engineering and Scientific Subroutine Library is used, parameters computed by FCOSI are not used. In this case, there is no need to call FCOSI.

Comments

Different WFCOS arrays are needed for different values of N.

Example

In this example, we compute three distinct cosine FFTs by calling FCOSI once and then calling F2OST three times.

USE FCOSI_INT

USE CONST_INT

USE F2OST_INT

USE UMACH_INT

IMPLICIT NONE

INTEGER N

PARAMETER (N=7)

!

INTEGER I, K, NOUT

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

INTRINSIC COS, FLOAT

! Get output unit number

CALL UMACH (2, NOUT)

! Initialize the work vector WFCOS

CALL FCOSI (N, WFCOS)

! 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(K*(I-1))*PI/FLOAT(N-1))

10 CONTINUE

! Compute the transform of SEQ

CALL F2OST (N, SEQ, COEF, WFCOS)

! 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 0.00

2 0.87 6.00

3 0.50 0.00

4 0.00 0.00

5 -0.50 0.00

6 -0.87 0.00

7 -1.00 0.00

INDEX SEQ COEF

1 1.00 0.00

2 0.50 0.00

3 -0.50 6.00

4 -1.00 0.00

5 -0.50 0.00

6 0.50 0.00

7 1.00 0.00

INDEX SEQ COEF

1 1.00 0.00

2 0.00 0.00

3 -1.00 0.00

4 0.00 6.00

5 1.00 0.00

6 0.00 0.00

7 -1.00 0.00