************************************************************************
      SUBROUTINE FTCTPR(N,IT,T)
 
      IMPLICIT REAL  (A-H,O-Z)
      DIMENSION IT(5),T(0:N-1,6)

      DATA PI/3.1415926535897932385D0/

      CALL FTRLPR(N,IT,T)
 
      N4=N*4
 
      DO 10 I=0,N-1
      T(I,5)=SIN(2*PI*(2*I+1)/N4)
      T(I,6)=COS(2*PI*(2*I+1)/N4)
   10 CONTINUE
 
      END
************************************************************************
      SUBROUTINE FTCTMN(X,Y,M,N,IT,T,ISN)
 
      IMPLICIT REAL  (A-H,O-Z)
      DIMENSION IT(5),T(0:N-1,6)
      DIMENSION X(M,0:2*N),Y(M,0:2*N-1)
 
      N2=N*2
 
      DO 10 J=0,N-1
      J1=2*J
      J2=N2-J1
      J3=2*J+1
      J4=N2-J3
      DO 10 I=1,M
      Y(I,J)=X(I,J1)+X(I,J2)+2*T(J,4)*(X(I,J1)-X(I,J2))
      Y(I,N+J)=X(I,J3)+X(I,J4)+2*T(J,5)*(X(I,J3)-X(I,J4))
   10 CONTINUE
 
      F=1D0/N2
      DO 20 I=1,M
      X(I,N2)=(X(I,0)-X(I,N2)+2*X(I,1)*T(0,6))*F
   20 CONTINUE 

      F=1D0/N
      DO 30 J=1,N-1
      DO 30 I=1,M
      X(I,N2)=X(I,N2)+(X(I,2*J)*T(J,3)+X(I,2*J+1)*T(J,6))*F
   30 CONTINUE 

      CALL FTRLFW(Y,X,M,N,N,IT,T)
 
      DO 40 I=1,M
      X(I,0)=Y(I,0)
      X(I,1)=X(I,N2)
      X(I,N2)=Y(I,N)
   40 CONTINUE
 
      DO 50 J=1,N-1
      DO 50 I=1,M
      X(I,2*J)=Y(I,J)
      X(I,2*J+1)=X(I,2*J-1)+Y(I,N+J)
   50 CONTINUE

      IF(ISN.EQ.-1) THEN
      DO 60 J=0,N2
      DO 60 I=1,M
      X(I,J)=N*X(I,J)
   60 CONTINUE
      END IF
 
      END
