      SUBROUTINE COSTI (N,WSAVE)
      IMPLICIT DOUBLE PRECISION (A-H, O-Z)
      DIMENSION       WSAVE(1)
      DATA PI /3.14159265358979324d0/
      IF (N .LE. 3) RETURN
      NM1 = N-1
      NP1 = N+1
      NS2 = N/2
      DT = PI/DFLOAT(NM1)
      FK = 0.d0
      DO 101 K=2,NS2
         KC = NP1-K
         FK = FK+1.d0
         WSAVE(K) = 2.d0*DSIN(FK*DT)
         WSAVE(KC) = 2.d0*DCOS(FK*DT)
  101 CONTINUE
      CALL RFFTI (NM1,WSAVE(N+1))
      RETURN
      END
