gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
colloc.f
Go to the documentation of this file.
1  subroutine colloc(aleft,aright,lbegin,iorder,ntimes,addbrk,relerr)
2 
3 c*********************************************************************72
4 c
5 cc COLLOC solves an ordinary differential equation by collocation.
6 c
7 c from * a practical guide to splines * by c. de boor
8 chapter xv, example. solution of an ode by collocation.
9 calls colpnt, difequ(ppvalu(interv)), knots, eqblok(putit(difequ*,
10 c bsplvd(bsplvb)))), slvblk(various subprograms), bsplpp(bsplvb*),
11 c newnot
12 c
13 c****** i n p u t ******
14 c aleft, aright endpoints of interval of approximation
15 c lbegin initial number of polynomial pieces in the approximation.
16 c a uniform breakpoint sequence is chosen.
17 c iorder order of polynomial pieces in the approximation
18 c ntimes number of passes through n e w n o t to be made
19 c addbrk the number (possibly fractional) of breaks to be added per
20 c pass through newnot. e.g., if addbrk = .33334, then a break-
21 c point will be added at every third pass through newnot.
22 c relerr a tolerance. newton iteration is stopped if the difference
23 c between the b-coeffs of two successive iterates is no more
24 c than relerr*(absol.largest b-coefficient).
25 c
26 c****** p r i n t e d o u t p u t ******
27 c consists of the pp-representation of the approximate solution,
28 c and of the error at selected points.
29 c
30 c****** m e t h o d ******
31 c the m-th order ordinary differential equation with m side condit-
32 c ions, to be specified in subroutine d i f e q u , is solved approx-
33 c imately by collocation.
34 c the approximation f to the solution g is pp of order k+m with
35 c l pieces and m-1 continuous derivatives. f is determined by the
36 c requirement that it satisfy the d.e. at k points per interval (to
37 c be specified in c o l p n t ) and the m side conditions.
38 c this usually nonlinear system of equations for f is solved by
39 c newton's method. the resulting linear system for the b-coeffs of an
40 c iterate is constructed appropriately in e q b l o k and then solved
41 c in s l v b l k , a program designed to solve a l m o s t b l o c k
42 c d i a g o n a l linear systems efficiently.
43 c there is an opportunity to attempt improvement of the breakpoint
44 c sequence (both in number and location) through use of n e w n o t .
45 c
46  implicit none
47 
48  integer npiece
49  parameter(npiece=100)
50  integer iorder,lbegin,ntimes, i,iflag,ii,integs(3,npiece),iside
51  & ,iter,itermx,j,k,kmax,kpm,l,lenblk,lnew,m,n,nbloks
52  & ,ndim,ncoef,nncoef,nt
53  parameter(ndim=200,kmax=20,ncoef=npiece*kmax,lenblk=ncoef)
54  double precision addbrk,aleft,aright,relerr,
55  & a(ndim),amax,asave(ndim)
56  & ,b(ndim),bloks(lenblk),break,coef,dx,err,rho,t(ndim)
57  & ,templ(lenblk),temps(ndim),xside
58  equivalence(bloks,templ)
59  common /approx/ break(npiece), coef(ncoef), l,kpm
60  common /side/ m, iside, xside(10)
61  common /other/ itermx,k,rho(kmax-1)
62 c
63  kpm = iorder
64  if (lbegin*kpm .gt. ncoef) go to 999
65 c *** set the various parameters concerning the particular dif.equ.
66 c including a first approx. in case the de is to be solved by
67 c iteration ( itermx .gt. 0) .
68  call difequ (1, temps(1), temps )
69 c *** obtain the k collocation points for the standard interval.
70  k = kpm - m
71  call colpnt ( k, rho )
72 c *** the following five statements could be replaced by a read in or-
73 c der to obtain a specific (nonuniform) spacing of the breakpnts.
74  dx = (aright - aleft)/dble(lbegin)
75  temps(1) = aleft
76  do 4 i=2,lbegin
77  4 temps(i) = temps(i-1) + dx
78  temps(lbegin+1) = aright
79 c *** generate, in knots, the required knots t(1),...,t(n+kpm).
80  call knots ( temps, lbegin, kpm, t, n )
81  nt = 1
82 c *** generate the almost block diagonal coefficient matrix bloks and
83 c right side b from collocation equations and side conditions.
84 c then solve via slvblk , obtaining the b-representation of the ap-
85 c proximation in t , a , n , kpm .
86  10 call eqblok(t,n,kpm,temps,a,bloks,lenblk,integs,nbloks,b)
87  call slvblk(bloks,integs,nbloks,b,temps,a,iflag)
88  iter = 1
89  if (itermx .le. 1) go to 30
90 c *** save b-spline coeff. of current approx. in asave , then get new
91 c approx. and compare with old. if coeff. are more than relerr
92 c apart (relatively) or if no. of iterations is less than itermx ,
93 c continue iterating.
94  20 call bsplpp(t,a,n,kpm,templ,break,coef,l)
95  do 25 i=1,n
96  25 asave(i) = a(i)
97  call eqblok(t,n,kpm,temps,a,bloks,lenblk,integs,nbloks,b)
98  call slvblk(bloks,integs,nbloks,b,temps,a,iflag)
99  err = 0.0d+00
100  amax = 0.0d+00
101  do 26 i=1,n
102  amax = dmax1(amax,dabs(a(i)))
103  26 err = dmax1(err,dabs(a(i)-asave(i)))
104  if (err .le. relerr*amax) go to 30
105  iter = iter+1
106  if (iter .lt. itermx) go to 20
107 c *** iteration (if any) completed. print out approx. based on current
108 c breakpoint sequence, then try to improve the sequence.
109  30 print 630,kpm,l,n,(break(i),i=2,l)
110  630 format(47h approximation from a space of splines of order,i3
111  & ,4h on ,i3,11h intervals,/13h of dimension,i4
112  & ,16h. breakpoints -/(5e20.10))
113  if (itermx .gt. 0) print 635,iter,itermx
114  635 format(6h after,i3,3h of,i3,20h allowed iterations,)
115  call bsplpp(t,a,n,kpm,templ,break,coef,l)
116  print 637
117  637 format(46h the pp representation of the approximation is)
118  do 38 i=1,l
119  ii = (i-1)*kpm
120  38 print 638, break(i),(coef(ii+j),j=1,kpm)
121  638 format(f9.3,e13.6,10e11.3)
122 c *** the following call is provided here for possible further analysis
123 c of the approximation specific to the problem being solved.
124 c it is, of course, easily omitted.
125  call difequ ( 4, temps(1), temps )
126 c
127  if (nt .gt. ntimes) return
128 c *** from the pp-rep. of the current approx., obtain in newnot a new
129 c (and possibly better) sequence of breakpoints, adding (on the ave-
130 c rage) a d d b r k breakpoints per pass through newnot.
131  lnew = lbegin + int(dble(nt)*addbrk)
132  if (lnew*kpm .gt. ncoef) go to 999
133  call newnot(break,coef,l,kpm,temps,lnew,templ)
134  call knots(temps,lnew,kpm,t,n)
135  nt = nt + 1
136  go to 10
137  999 nncoef = ncoef
138  print 699,nncoef
139  699 format(11h **********/23h the assigned dimension,i5
140  & ,25h for coef is too small.)
141  return
142  end
subroutine bsplpp(t, bcoef, n, k, scrtch, break, coef, l)
Definition: bsplpp.f:2
subroutine colpnt(k, rho)
Definition: colpnt.f:2
subroutine newnot(break, coef, l, k, brknew, lnew, coefg)
Definition: newnot.f:2
subroutine slvblk(bloks, integs, nbloks, b, ipivot, x, iflag)
Definition: slvblk.f:2
subroutine colloc(aleft, aright, lbegin, iorder, ntimes, addbrk, relerr)
Definition: colloc.f:2
subroutine eqblok(t, n, kpm, work1, work2, bloks, lenblk, integs, nbloks, b)
Definition: eqblok.f:3
subroutine knots(break, l, kpm, t, n)
Definition: knots.f:2
subroutine difequ(mode, xx, v)
Definition: difequ.f:2
gtkIOStream: /tmp/gtkiostream/src/deBoor/colloc.f Source File
GTK+ IOStream  Beta