C....*...1.........2.........3.........4.........5.........6.........7.*.......8
C     PERFIX  2/4/72
C
C     PURPOSE
C     COMPUTE PX(I)=PFX(I)/(TRANSFER_FUNCTION_OF_W)
C
C     USAGE
C     CALL PERFIX(N,PFX,NP,W,LW,PX)
C
C     ARGUMENTS
C     N   - LENGTH OF FILTERED SERIES FROM WHICH PFX WAS COMPUTED.
C     PFX - INPUT PERIODOGRAM.
C     NP  - LENGTH OF PFX.
C     W   - VECTOR OF WEIGHTS USED TO FILTER THE ORIGINAL SERIES.
C     LW  - LENGTH OF W.  LW MUST BE ODD.
C     PX  - COMPUTED PERIODOGRAM OF LENGTH NP.
C
C     REMARKS
C     LET FX OF LENGTH N BE THE CENTERED MOVING AVERAGE OBTAINED FROM
C     THE STATIONARY SERIES X USING THE WEIGHTS W OF LENGTH LW.  I.E.
C     FX(I)=W(1)*X(I-(LW-1)/2)+...+W(LW)*X(I+(LW-1)/2).
C     LET PFX BE THE PERIODOGRAM OF LENGTH NP RETURNED BY EITHER SLOWF
C     OF FASTF.  PERFIX RETURNS PX OF LENGTH NP WHICH IS (ESSENTIALLY)
C     THE PERIODOGRAM OF X.
C     TYPICAL CALLING SEQUENCE (ORIGINAL SERIES X IS OF LENGTH NX)
C     N=NX-LW+1
C     CALL SMO(X,NX,W,LW,1,FX)
C     DO 10 I=1,N
C  10 FX(I)=FX(I+(LW-1)/2)
C     CALL SLOWF(FX,N,C,PFX,NP)
C     CALL PERFIX(N,PFX,NP,W,LW,PX)
C     THE USAGE
C     CALL PERFIX(N,PFX,NP,W,LW,PFX)
C     IS PERMISSIBLE.  PFX WILL CONTAIN PX ON RETURN.
C
      SUBROUTINE PERFIX(N,PFX,NP,W,LW,PX)
      implicit real*8 (a-h,o-z)
      save
      COMPLEX*16 X,Z
      REAL*8 PFX(1),PX(1),W(1)
      WW=6.283185307179586d0/N
      DO 20 M=1,NP
      FREQ=WW*(M-1)
      LL=LW/2
      Z=W(LL+1)
      DO 10 J=1,LL
      FJ=J
      K1=LL+1-J
      K2=LL+1+J
      Z=Z + W(K1)*EXP( (0.d0,-1.d0)*FREQ*(-FJ) )
     *    + W(K2)*EXP( (0.d0,-1.d0)*FREQ*(FJ)  )
10    CONTINUE
      X=CONJG(Z)*Z
20    PX(M)=PFX(M)/DBLE(X)
      RETURN
      END
