gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
bvalue.f
Go to the documentation of this file.
1  double precision function bvalue ( t, bcoef, n, k, x, jderiv )
2 
3 c*********************************************************************72
4 c
5 cc BVALUE evaluates a derivative of a spline from its B-spline representation.
6 c
7 c from * a practical guide to splines * by c. de boor
8 calls interv
9 c
10 calculates value at x of jderiv-th derivative of spline from b-repr.
11 c the spline is taken to be continuous from the right, EXCEPT at the
12 c rightmost knot, where it is taken to be continuous from the left.
13 c
14 c****** i n p u t ******
15 c t, bcoef, n, k......forms the b-representation of the spline f to
16 c be evaluated. specifically,
17 c t.....knot sequence, of length n+k, assumed nondecreasing.
18 c bcoef.....b-coefficient sequence, of length n .
19 c n.....length of bcoef and dimension of spline(k,t),
20 c a s s u m e d positive .
21 c k.....order of the spline .
22 c
23 c w a r n i n g . . . the restriction k .le. kmax (=20) is imposed
24 c arbitrarily by the dimension statement for aj, dl, dr below,
25 c but is n o w h e r e c h e c k e d for.
26 c
27 c x.....the point at which to evaluate .
28 c jderiv.....integer giving the order of the derivative to be evaluated
29 c a s s u m e d to be zero or positive.
30 c
31 c****** o u t p u t ******
32 c bvalue.....the value of the (jderiv)-th derivative of f at x .
33 c
34 c****** m e t h o d ******
35 c The nontrivial knot interval (t(i),t(i+1)) containing x is lo-
36 c cated with the aid of interv . The k b-coeffs of f relevant for
37 c this interval are then obtained from bcoef (or taken to be zero if
38 c not explicitly available) and are then differenced jderiv times to
39 c obtain the b-coeffs of (d**jderiv)f relevant for that interval.
40 c Precisely, with j = jderiv, we have from x.(12) of the text that
41 c
42 c (d**j)f = sum ( bcoef(.,j)*b(.,k-j,t) )
43 c
44 c where
45 c / bcoef(.), , j .eq. 0
46 c /
47 c bcoef(.,j) = / bcoef(.,j-1) - bcoef(.-1,j-1)
48 c / ----------------------------- , j .gt. 0
49 c / (t(.+k-j) - t(.))/(k-j)
50 c
51 c Then, we use repeatedly the fact that
52 c
53 c sum ( a(.)*b(.,m,t)(x) ) = sum ( a(.,x)*b(.,m-1,t)(x) )
54 c with
55 c (x - t(.))*a(.) + (t(.+m-1) - x)*a(.-1)
56 c a(.,x) = ---------------------------------------
57 c (x - t(.)) + (t(.+m-1) - x)
58 c
59 c to write (d**j)f(x) eventually as a linear combination of b-splines
60 c of order 1 , and the coefficient for b(i,1,t)(x) must then be the
61 c desired number (d**j)f(x). (see x.(17)-(19) of text).
62 c
63  implicit none
64 
65  integer jderiv,k,n, i,ilo,imk,j,jc,jcmin,jcmax,jj,kmax,kmj,km1
66  & ,mflag,nmi,jdrvp1
67  parameter(kmax = 20)
68  double precision bcoef(n),t(n+k),x,
69  & aj(kmax),dl(kmax),dr(kmax),fkmj
70  bvalue = 0.0d+00
71  if (jderiv .ge. k) go to 99
72 c
73 c *** Find i s.t. 1 .le. i .lt. n+k and t(i) .lt. t(i+1) and
74 c t(i) .le. x .lt. t(i+1) . If no such i can be found, x lies
75 c outside the support of the spline f , hence bvalue = 0.
76 c (The asymmetry in this choice of i makes f rightcontinuous, except
77 c at t(n+k) where it is leftcontinuous.)
78  call interv ( t, n+k, x, i, mflag )
79  if (mflag .ne. 0) go to 99
80 c *** if k = 1 (and jderiv = 0), bvalue = bcoef(i).
81  km1 = k - 1
82  if (km1 .gt. 0) go to 1
83  bvalue = bcoef(i)
84  go to 99
85 c
86 c *** store the k b-spline coefficients relevant for the knot interval
87 c (t(i),t(i+1)) in aj(1),...,aj(k) and compute dl(j) = x - t(i+1-j),
88 c dr(j) = t(i+j) - x, j=1,...,k-1 . set any of the aj not obtainable
89 c from input to zero. set any t.s not obtainable equal to t(1) or
90 c to t(n+k) appropriately.
91  1 jcmin = 1
92  imk = i - k
93  if (imk .ge. 0) go to 8
94  jcmin = 1 - imk
95  do 5 j=1,i
96  5 dl(j) = x - t(i+1-j)
97  do 6 j=i,km1
98  aj(k-j) = 0.0d+00
99  6 dl(j) = dl(i)
100  go to 10
101  8 do 9 j=1,km1
102  9 dl(j) = x - t(i+1-j)
103 c
104  10 jcmax = k
105  nmi = n - i
106  if (nmi .ge. 0) go to 18
107  jcmax = k + nmi
108  do 15 j=1,jcmax
109  15 dr(j) = t(i+j) - x
110  do 16 j=jcmax,km1
111  aj(j+1) = 0.0d+00
112  16 dr(j) = dr(jcmax)
113  go to 20
114  18 do 19 j=1,km1
115  19 dr(j) = t(i+j) - x
116 c
117  20 do 21 jc=jcmin,jcmax
118  21 aj(jc) = bcoef(imk + jc)
119 c
120 c *** difference the coefficients jderiv times.
121  if (jderiv .eq. 0) go to 30
122  do 23 j=1,jderiv
123  kmj = k-j
124  fkmj = dble(kmj)
125  ilo = kmj
126  do 23 jj=1,kmj
127  aj(jj) = ((aj(jj+1) - aj(jj))/(dl(ilo) + dr(jj)))*fkmj
128  23 ilo = ilo - 1
129 c
130 c *** compute value at x in (t(i),t(i+1)) of jderiv-th derivative,
131 c given its relevant b-spline coeffs in aj(1),...,aj(k-jderiv).
132  30 if (jderiv .eq. km1) go to 39
133  jdrvp1 = jderiv + 1
134  do 33 j=jdrvp1,km1
135  kmj = k-j
136  ilo = kmj
137  do 33 jj=1,kmj
138  aj(jj) = (aj(jj+1)*dl(ilo) + aj(jj)*dr(jj))/(dl(ilo)+dr(jj))
139  33 ilo = ilo - 1
140  39 bvalue = aj(1)
141 c
142  99 return
143  end
double precision function bvalue(t, bcoef, n, k, x, jderiv)
Definition: bvalue.f:2
subroutine interv(xt, lxt, x, left, mflag)
Definition: interv.f:2
gtkIOStream: /tmp/gtkiostream/src/deBoor/bvalue.f Source File
GTK+ IOStream  Beta