      implicit real*8(a-h,o-z)
      integer ndim, n
      parameter (ndim=10000)
      real*8 a(4,ndim)
c
c     read dimension of matrix to be solved
c
 10   continue
      read(5,'(i5)') n
      if( n .lt. 0 ) then
         write(6,'(a)')
     $        'n is not negative. Please retry to enter n.'
         go to 10
      end if
c
      call signal(n,a)
c
      end
c======================================================================
      real*8 function wave1(v,t)
      implicit real*8(a-h,o-z)
      real*8 c, pi, v
      parameter(c=2.9979246d10)
c
      pi = atan(1.0)*4.0d0
      wave1 = cos( 2.0d0*pi*c*v*t )
      return
      end
c======================================================================
      subroutine signal(n,a)
      implicit real*8(a-h,o-z)
      real*8 a(4,*)
      real*8 time
      parameter(dtime=1.0d-9)
c
      do i = 1 , n
         time = dtime*i
         a(1,i) = wave1(1000.0d0,time)
         a(2,i) = wave1(1100.0d0,time)*2.0d0
         a(3,i) = wave1(1150.0d0,time)*0.5d0
         a(4,i) = a(1,i) + a(2,i) + a(3,i)
c
c$$$         write(6,'(5f15.10)') time, (a(j,i),j=1,4) 
c
      end do
c
      return
      end
c======================================================================
