      program K1nmKk ! BB Apr 5 2012..
C 1D Knm matrix of the scalar field. Rothe p.30.
      include '../../Libs/Fortran/implicit.sta'
      include '../../Libs/Fortran/constants.par'
      parameter(iuo=6,nt=6,ntm1=nt-1,dkt=tpi/nt)
      parameter(xm=half) ! xm Mass.
      dimension XKnm(nt,nt),XKInm(nt,nt)
      ltest=.true.
      ltest=.false.
      if(ltest) stop "K1nmk: ltest."
      write(iuo,'(/," 1D case Knm matrix Rothe p.30",/)') 
      write(iuo,'(" Use of Fourier transformation nt =",I4,/)') nt
      do n=1,nt
        do m=1,nt
          dt=one*(n-m)
          XKnm(n,m)=zero
          do k=0,ntm1
            tk=dkt*k ! Added term K(k) (in parenthesis).
            XKnm(n,m)=XKnm(n,m)+(four*sin(tk/2)**2+xm**2)*cos(tk*dt)
          enddo
          XKnm(n,m)=XKnm(n,m)/nt ! Normalization.
        enddo
        write(iuo,'(7F10.6)') (XKnm(n,m),m=1,nt)
      enddo
C Inverse matrix:
      write(iuo,'(/," Inverse matrix:",/)') 
      do n=1,nt
        do m=1,nt
          dt=one*(n-m)
          XKInm(n,m)=zero
          do k=0,ntm1
            tk=dkt*k ! Added term K(k) (in parenthesis).
            XKInm(n,m)=XKInm(n,m)+cos(tk*dt)/(four*sin(tk/2)**2+xm**2)
          enddo
          XKInm(n,m)=XKInm(n,m)/nt ! Normalization.
        enddo
        write(iuo,'(7F10.6)') (XKInm(n,m),m=1,nt)
      enddo
      stop
      end
