      subroutine nrlazy(nmax,y,yc,m,eps)
      parameter(im=100,ii=100000000,nx=50000) 
      dimension y(nmax),yc(nmax),jh(0:im*im),jpntr(nx),nlist(nx)

      if(nmax.gt.nx) pause "Make nx larger."
      call base(nmax,y,1,m,jh,jpntr,eps)
      do 10 n=1,nmax
 10     yc(n)=y(n)   
      do 20 n=m,nmax           
        call neigh(nmax,y,n,nmax,1,m,jh,jpntr,eps,nlist,nfound)
        av=0
        do 30 nn=1,nfound            
 30       av=av+y(nlist(nn)-(m-1)/2)                ! average middle coordinate
 20     yc(n-(m-1)/2)=av/nfound
      end
