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