      PROGRAM fourier

      integer i,j
      real x(8), h(8)
      complex f(8),y(8)
      real PI
      I = (-1)**(1/2)
      PI=3.14159265
      
      open(1, file = 'data.txt')
      read(1,*) x(1),x(2),x(3),x(4),x(5),x(6),x(7),x(8)
      write(*,*) x(1),x(2),x(3),x(4),x(5),x(6),x(7),x(8)
     
      DO 10 i = 1, 8
         DO 20 j = 1, 8
            f(i) = x(j)*EXP(-0.25*PI*I*(i-1)*(j-1))+f(i-1)
 20      CONTINUE
 10   CONTINUE
      
      write(*,*) f(1),f(2),f(3),f(4),f(5),f(6),f(7),f(8)
      write(1,*) f(1),f(2),f(3),f(4),f(5),f(6),f(7),f(8)

      DO 30 j = 0, 8
         y(j) = f(j)
         h(j) = x(j)
 30   CONTINUE
      
      write(1,*) y(1),y(2),y(3),y(4),y(5),y(6),y(7),y(8)
      write(*,*) y(1),y(2),y(3),y(4),y(5),y(6),y(7),y(8)
      
      DO 40 i = 1, 8
         DO 50 j = 1, 8
            h(i) = (y(j)*EXP(-0.25*PI*I*(i-1)*(j-1))+h(i-1))/8
 50      CONTINUE
 40   CONTINUE
      write(*,*) h(1),h(2),h(3),h(4),h(5),h(6),h(7),h(8)
      write(1,*) h(1),h(2),h(3),h(4),h(5),h(6),h(7),h(8)
      close (1)
      stop
      end
