      program weighted
      implicit double precision (a-h,o-z)
      dimension t(50),wcoef(49)
      dimension dbiatx(4,3)   !polje za derivacije B-splineova
      dimension dgiatx(4,3)   !polje za derivacije G-splineova
      dimension values(200,3)
      real*8 tau(100)
c=======================================================
c     DEFAULTS
c=======================================================
      data npoint /11/
      data n /11/
      do, i=1,4
            t(i)=0.d0
            t(n-4+i)=4.d0
      enddo
      t(5)=1.d0
      t(6)=2.d0
      t(7)=3.d0
      do, i=1,2*n-9
            wcoef(i)=1.d0
      enddo
c=======================================================
      write(*,*) 'NUMBER OF KNOTS: (11)'
      read(*,*) n
      write(*,*) 'KNOTS: (4*0,1,2,3,4*4):'
      read(*,*) ( t(i),i=1,n)
      write(*,*) 'KNOTS:'
      write(*,*) (t(i),i=1,n)
      do i=1,2*n-9,2
            tau(i)  = t( (i+5)/2 )
            tau(i+1)= t( (i+5)/2 )
      enddo
      write(*,*) 'npoint: (11)'
      read(*,*) npoint
      deltax=(t(n)-t(1))/dble(npoint-1)
      write(*,*) 'w-coeffs (10*1):'
      read(*,*) (wcoef(i),i=1,n-1)
      write(*,10)
      write(*,*) ' Classical (>0) or generalized derivatives (0):'
      read(*,*) index
10    format(2x,'X',20x,'GIATX',25x,'SUMA'/60('-') )
      do, jot=1,npoint-1
      x=t(4)+(jot-1)*deltax
      call interv (tau,2*n-8,x,ileft,mflag)
c
c     calculating all nontrivial local B-splines and their deriv's
c     on refined knot sequence TAU (dimension 2*n-8)
c
      call bsplvd(tau,4,x,ileft,a,dbiatx,3)
c
c     calculating all nontrivial  T-splines and their deriv's
c     as linear combinations of local B-splines
c
      call interv (t,n,x,left,mflag)
      call GSPLVD(t,n,wcoef,left,index,dbiatx,dgiatx)
      suma=0.d0
      do, i=1,4
            suma=suma+dgiatx(i,1)
      enddo
      write(*,'(1x,f5.2,5(f10.5,1x))' )  x,(dgiatx(i,1),i=1,4),suma
      do, ka=1,4
            values(left-4+ka,1)=dgiatx(ka,1)
            values(left-4+ka,2)=dgiatx(ka,2)
            values(left-4+ka,3)=dgiatx(ka,3)
      enddo
      write(11,'(1x,f7.3,7f10.5)' ) x,(values(j,1),j=1,7)
      write(12,'(1x,f7.3,7f10.5)' ) x,(values(j,2),j=1,7)
      write(13,'(1x,f7.3,7f10.5)' ) x,(values(j,3),j=1,7)
      do, jot1=1,3
          do, kapa=1,7
              values(kapa,jot1)=0.d0
          enddo
      enddo
c
      enddo
      end
