

      subroutine bictanvecs( ijk, ipnt, up, vp, tanv, itantyp )

      include 'ctparm.inc'
      include 'ctgeom_bic.inc'

      integer ijk, ipnt, itantyp
      real up, vp
      real tanv(3), uc(4,1), vc(1,4), ujnk(4,1), vjnk(1,4)
      real r(3)
      real eps
      integer k

      eps = 1.e-7

      if( itantyp .eq. 0 ) then
        call get_uc_vc( up, vp, uc, vc )
      elseif( itantyp .eq. 1 ) then
        call get_uc_vc( up, vp, ujnk, vc )
        uc(1,1) = 3.*up**2
        uc(2,1) = 2.*up
        uc(3,1) = 1.
        uc(4,1) = 0.
        do k=1,4
          if( abs(uc(k,1)) .le. eps ) uc(k,1) = 0.
        end do
      elseif( itantyp .eq. 2 ) then
        call get_uc_vc( up, vp, uc, vjnk )
        vc(1,1) = 3.*vp**2
        vc(1,2) = 2.*vp
        vc(1,3) = 1.
        vc(1,4) = 0.
        do k=1,3
          if( abs(vc(1,k)) .le. eps ) vc(1,k) = 0.
        end do
      elseif( itantyp .eq. 3 ) then
        call get_uc_vc( up, vp, ujnk, vc )
        uc(1,1) = max(6.*up, 0.)
        uc(2,1) = 2.
        uc(3,1) = 0.
        uc(4,1) = 0.
      elseif( itantyp .eq. 4 ) then
        call get_uc_vc( up, vp, uc, vjnk )
        vc(1,1) = max(6.*vp, 0.)
        vc(1,2) = 2.
        vc(1,3) = 0.
        vc(1,4) = 0.
      elseif( itantyp .eq. 5 ) then
        do k=1,2
          uc(k,1) = (4.-k)*up**(3-k)
          vc(1,k) = (4.-k)*vp**(3-k)
          if( abs(uc(k,1)) .lt. eps ) uc(k,1) = 0.
          if( abs(vc(1,k)) .lt. eps ) vc(1,k) = 0.
        end do
        uc(3,1) = 1.
        vc(1,3) = 1.
        uc(4,1) = 0.
        vc(1,4) = 0.
      endif

      call mtx3mul( uc, vc, ipnt, tanv )

      return
      end






      subroutine mtx3mul( uc, vc, ipnt, pt )

      integer ipnt, k
      real uc(4,1), vc(1,4), ptmp(3,1), pt(3), tm(4,1)

      include 'ctparm.inc'
      include 'ctgeom_bic.inc'

      do k=1,3
        call mtxmul( uc, algmtx(1,1,k,ipnt), tm, 4, 1, 4 )
        call mtxmul( tm, vc, ptmp(k,1), 4, 1, 1 )
        pt(k) = ptmp(k,1)
      end do

      return
      end
