1      subroutine cualde(idim,t,n,c,nc,k1,u,d,nd,ier)
2c  subroutine cualde evaluates at the point u all the derivatives
3c                     (l)
4c     d(idim*l+j) = sj   (u) ,l=0,1,...,k, j=1,2,...,idim
5c  of a spline curve s(u) of order k1 (degree k=k1-1) and dimension idim
6c  given in its b-spline representation.
7c
8c  calling sequence:
9c     call cualde(idim,t,n,c,nc,k1,u,d,nd,ier)
10c
11c  input parameters:
12c    idim : integer, giving the dimension of the spline curve.
13c    t    : array,length n, which contains the position of the knots.
14c    n    : integer, giving the total number of knots of s(u).
15c    c    : array,length nc, which contains the b-spline coefficients.
16c    nc   : integer, giving the total number of coefficients of s(u).
17c    k1   : integer, giving the order of s(u) (order=degree+1).
18c    u    : real, which contains the point where the derivatives must
19c           be evaluated.
20c    nd   : integer, giving the dimension of the array d. nd >= k1*idim
21c
22c  output parameters:
23c    d    : array,length nd,giving the different curve derivatives.
24c           d(idim*l+j) will contain the j-th coordinate of the l-th
25c           derivative of the curve at the point u.
26c    ier  : error flag
27c      ier = 0 : normal return
28c      ier =10 : invalid input data (see restrictions)
29c
30c  restrictions:
31c    nd >= k1*idim
32c    t(k1) <= u <= t(n-k1+1)
33c
34c  further comments:
35c    if u coincides with a knot, right derivatives are computed
36c    ( left derivatives if u = t(n-k1+1) ).
37c
38c  other subroutines required: fpader.
39c
40c  references :
41c    de boor c : on calculating with b-splines, j. approximation theory
42c                6 (1972) 50-62.
43c    cox m.g.  : the numerical evaluation of b-splines, j. inst. maths
44c                applics 10 (1972) 134-149.
45c    dierckx p. : curve and surface fitting with splines, monographs on
46c                 numerical analysis, oxford university press, 1993.
47c
48c  author :
49c    p.dierckx
50c    dept. computer science, k.u.leuven
51c    celestijnenlaan 200a, b-3001 heverlee, belgium.
52c    e-mail : Paul.Dierckx@cs.kuleuven.ac.be
53c
54c  latest update : march 1987
55c
56c  ..scalar arguments..
57      integer idim,n,nc,k1,nd,ier
58      real*8 u
59c  ..array arguments..
60      real*8 t(n),c(nc),d(nd)
61c  ..local scalars..
62      integer i,j,kk,l,m,nk1
63c  ..local array..
64      real*8 h(6)
65c  ..
66c  before starting computations a data check is made. if the input data
67c  are invalid control is immediately repassed to the calling program.
68      ier = 10
69      if(nd.lt.(k1*idim)) go to 500
70      nk1 = n-k1
71      if(u.lt.t(k1) .or. u.gt.t(nk1+1)) go to 500
72c  search for knot interval t(l) <= u < t(l+1)
73      l = k1
74 100  if(u.lt.t(l+1) .or. l.eq.nk1) go to 200
75      l = l+1
76      go to 100
77 200  if(t(l).ge.t(l+1)) go to 500
78      ier = 0
79c  calculate the derivatives.
80      j = 1
81      do 400 i=1,idim
82        call fpader(t,n,c(j),k1,u,l,h)
83        m = i
84        do 300 kk=1,k1
85          d(m) = h(kk)
86          m = m+idim
87 300    continue
88        j = j+n
89 400  continue
90 500  return
91      end
92