Previous Next Contents Generated Index Doc Set Home



Cosine Even-Wave Transform

The subroutines described in this section compute the discrete Fourier cosine transform of an even sequence. The transform is defined as:

For i=1,...,n


Note - The xCOST transforms are unnormalized inverses of themselves, so a call of xCOST followed by another call of xCOST will multiply the input sequence by 2 × (N-1). The VxCOST transforms are normalized, so a call of VxCOST followed by a call of VxCOST will return the original sequence.

Calling Sequence

CALL COST 
(N, RX, RWSAVE)
CALL DCOST 
(N, DX, DWSAVE)
CALL VCOST 
(M,N, RX, RXT, MDIMX, RWSAVE)
CALL VDCOST 
(M,N, DX, DXT, MDIMX, DWSAVE)
 



void cost 
(int n, float *rx, float *rwsave)
void dcost 
(int n, double *dx, double *dwsave)
void vcost 
(int m, int n, float *rx, int mdimx, float *rwsave)
void vdcost 
(int m, int n, double *dx, int mdimx, double *dwsave)

Arguments

M

(For vector operations only.)
The number of sequences to be transformed. M 0.

N

Length of the sequence to be transformed. These subroutines are most efficient when N-1 is a product of small primes. N 2.

xX

On entry, an array of length N containing the sequence to be transformed. For VxCOST, a real two-dimensional array with dimensions of (MDIMX × N) whose rows contain the sequences to be transformed. On exit, the cosine transform of the input.

xXT

(For vector operations only.)
A real two-dimensional work array with dimensions of
(MDIMX × (N-1)).

MDIMX

(For vector operations only.)
Leading dimension of the arrays xX and xXT as specified in a dimension or type statement. MDIMX M.

xWSAVE

On entry, an array with dimension of at least (3 × N + 15), initialized by xCOSTI or VxCOSTI.

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER         N
      PARAMETER      (N = 9) 
C
      INTEGER         I
      REAL            PI, X(N), WSAVE(3 * N + 15)
C
      EXTERNAL        COST, COSTI
      INTRINSIC       ACOS, COS
C
C     Initialize the array X to an even sequence, that is, it 
C     can be expanded in terms of a trigonometric series that
C     contains only cosine terms.  
C
      PI = ACOS (-1.0)
      DO 100, I=1, N
        X(I) = COS ((I - 1.0) * 2.0 * PI / (N - 1.0))
  100 CONTINUE
C
      CALL COSTI (N, WSAVE) 
      PRINT 1000 
      PRINT 1010, (X(I), I = 1, N)
      CALL COST (N, X, WSAVE)
      PRINT 1020 
      PRINT 1010, (X(I), I = 1, N)
      CALL COST (N, X, WSAVE)
      PRINT 1030 
      PRINT 1010, (X(I), I = 1, N)
C
 1000 FORMAT (1X, 'Original Sequence: ') 
 1010 FORMAT (1X, 100(F5.1, 1X))
 1020 FORMAT (1X, 'Transformed Sequence: ')
 1030 FORMAT (1X, 'Recovered Sequence: ')
      END
 

Sample Output

 
 Original Sequence: 
   1.0   0.7   0.0  -0.7  -1.0  -0.7   0.0   0.7   1.0
 Transformed Sequence: 
   0.0   0.0   8.0   0.0   0.0   0.0   0.0   0.0   0.0
 Recovered Sequence: 
  16.0  11.3   0.0 -11.3 -16.0 -11.3   0.0  11.3  16.0






Previous Next Contents Generated Index Doc Set Home