gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
splint.f
Go to the documentation of this file.
1  subroutine splint ( tau, gtau, t, n, k, q, bcoef, iflag )
2 
3 c*********************************************************************72
4 c
5 cc SPLINT produces the B-spline coefficients BCOEF of an interpolating spline.
6 c
7 c from * a practical guide to splines * by c. de boor
8 calls bsplvb, banfac/slv
9 c
10 c splint produces the b-spline coeff.s bcoef of the spline of order
11 c k with knots t(i), i=1,..., n + k , which takes on the value
12 c gtau(i) at tau(i), i=1,..., n .
13 c
14 c****** i n p u t ******
15 c tau.....array of length n , containing data point abscissae.
16 c a s s u m p t i o n . . . tau is strictly increasing
17 c gtau.....corresponding array of length n , containing data point or-
18 c dinates
19 c t.....knot sequence, of length n+k
20 c n.....number of data points and dimension of spline space s(k,t)
21 c k.....order of spline
22 c
23 c****** o u t p u t ******
24 c q.....array of size (2*k-1)*n , containing the triangular factoriz-
25 c ation of the coefficient matrix of the linear system for the b-
26 c coefficients of the spline interpolant.
27 c the b-coeffs for the interpolant of an additional data set
28 c (tau(i),htau(i)), i=1,...,n with the same data abscissae can
29 c be obtained without going through all the calculations in this
30 c routine, simply by loading htau into bcoef and then execut-
31 c ing the call banslv ( q, 2*k-1, n, k-1, k-1, bcoef )
32 c bcoef.....the b-coefficients of the interpolant, of length n
33 c iflag.....an integer indicating success (= 1) or failure (= 2)
34 c the linear system to be solved is (theoretically) invertible if
35 c and only if
36 c t(i) .lt. tau(i) .lt. t(i+k), all i.
37 c violation of this condition is certain to lead to iflag = 2 .
38 c
39 c****** m e t h o d ******
40 c the i-th equation of the linear system a*bcoef = b for the b-co-
41 c effs of the interpolant enforces interpolation at tau(i), i=1,...,n.
42 c hence, b(i) = gtau(i), all i, and a is a band matrix with 2k-1
43 c bands (if it is invertible).
44 c the matrix a is generated row by row and stored, diagonal by di-
45 c agonal, in the r o w s of the array q , with the main diagonal go-
46 c ing into row k . see comments in the program below.
47 c the banded system is then solved by a call to banfac (which con-
48 c structs the triangular factorization for a and stores it again in
49 c q ), followed by a call to banslv (which then obtains the solution
50 c bcoef by substitution).
51 c banfac does no pivoting, since the total positivity of the matrix
52 c a makes this unnecessary.
53 c
54  implicit none
55 
56  integer iflag,k,n, i,ilp1mx,j,jj,km1,kpkm2,left,lenq,np1
57  double precision bcoef(n),gtau(n),q(1),t(1),tau(n), taui
58 c dimension q(2*k-1,n), t(n+k)
59 current fortran standard makes it impossible to specify precisely the
60 c dimension of q and t without the introduction of otherwise super-
61 c fluous additional arguments.
62  np1 = n + 1
63  km1 = k - 1
64  kpkm2 = 2*km1
65  left = k
66 c zero out all entries of q
67  lenq = n*(k+km1)
68  do 5 i=1,lenq
69  5 q(i) = 0.0d+00
70 c
71 c *** loop over i to construct the n interpolation equations
72  do 30 i=1,n
73  taui = tau(i)
74  ilp1mx = min0(i+k,np1)
75 c *** find left in the closed interval (i,i+k-1) such that
76 c t(left) .le. tau(i) .lt. t(left+1)
77 c matrix is singular if this is not possible
78  left = max0(left,i)
79  if (taui .lt. t(left)) go to 998
80  15 if (taui .lt. t(left+1)) go to 16
81  left = left + 1
82  if (left .lt. ilp1mx) go to 15
83  left = left - 1
84  if (taui .gt. t(left+1)) go to 998
85 c *** the i-th equation enforces interpolation at taui, hence
86 c a(i,j) = b(j,k,t)(taui), all j. only the k entries with j =
87 c left-k+1,...,left actually might be nonzero. these k numbers
88 c are returned, in bcoef (used for temp.storage here), by the
89 c following
90  16 call bsplvb ( t, k, 1, taui, left, bcoef )
91 c we therefore want bcoef(j) = b(left-k+j)(taui) to go into
92 c a(i,left-k+j), i.e., into q(i-(left+j)+2*k,(left+j)-k) since
93 c a(i+j,j) is to go into q(i+k,j), all i,j, if we consider q
94 c as a two-dim. array , with 2*k-1 rows (see comments in
95 c banfac). in the present program, we treat q as an equivalent
96 c one-dimensional array (because of fortran restrictions on
97 c dimension statements) . we therefore want bcoef(j) to go into
98 c entry
99 c i -(left+j) + 2*k + ((left+j) - k-1)*(2*k-1)
100 c = i-left+1 + (left -k)*(2*k-1) + (2*k-2)*j
101 c of q .
102  jj = i-left+1 + (left-k)*(k+km1)
103  do 30 j=1,k
104  jj = jj+kpkm2
105  30 q(jj) = bcoef(j)
106 c
107 c ***obtain factorization of a , stored again in q.
108  call banfac ( q, k+km1, n, km1, km1, iflag )
109  go to (40,999), iflag
110 c *** solve a*bcoef = gtau by backsubstitution
111  40 do 41 i=1,n
112  41 bcoef(i) = gtau(i)
113  call banslv ( q, k+km1, n, km1, km1, bcoef )
114  return
115  998 iflag = 2
116  999 print 699
117  699 format(41h linear system in splint not invertible)
118  return
119  end
subroutine banslv(w, nroww, nrow, nbandl, nbandu, b)
Definition: banslv.f:2
subroutine banfac(w, nroww, nrow, nbandl, nbandu, iflag)
Definition: banfac.f:2
subroutine bsplvb(t, jhigh, index, x, left, biatx)
Definition: bsplvb.f:2
subroutine splint(tau, gtau, t, n, k, q, bcoef, iflag)
Definition: splint.f:2
gtkIOStream: /tmp/gtkiostream/src/deBoor/splint.f Source File
GTK+ IOStream  Beta