gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
l2err.f
Go to the documentation of this file.
1  subroutine l2err ( prfun , ftau , error )
2 
3 c*********************************************************************72
4 c
5 cc L2ERR computes the errors of an L2 approximation.
6 c
7 c from * a practical guide to splines * by c. de boor
8 c this routine is to be called in the main program l 2 m a i n .
9 calls subprogram ppvalu(interv)
10 c this subroutine computes various errors of the current l2-approxi-
11 c mation , whose pp-repr. is contained in common block approx ,
12 c to the given data contained in common block data . it prints out
13 c the average error e r r l 1 , the l2-error e r r l 2, and the
14 c maximum error e r r m a x .
15 c
16 c****** i n p u t ******
17 c prfun a logical value. if prfun = TRUE, the routine prints out
18 c the value of the approximation as well as its error at
19 c every data point.
20 c
21 c****** o u t p u t ******
22 c ftau(1), ..., ftau(ntau), with ftau(i) the approximation f at
23 c tau(i), all i.
24 c error(1), ..., error(ntau), with error(i) = scale*(g - f)
25 c at tau(i), all i. here, s c a l e equals 1. in case
26 c prfun .ne. 'ON' , or the abs.error is greater than 100 some-
27 c where. otherwise, s c a l e is such that the maximum of
28 c abs(error)) over all i lies between 10 and 100. this
29 c makes the printed output more illustrative.
30 c
31  implicit none
32 
33  logical prfun
34  integer ie,k,l,ll,lpkmax,ltkmax,ntau,ntmax,on
35  double precision ftau(ntau),error(ntau),
36  & break,coef,err,errmax,errl1,errl2,gtau,ppvalu,
37  & scale,tau,totalw,weight
38 
39  parameter(lpkmax=100,ntmax=200,ltkmax=2000)
40 
41  common / i4data / ntau
42  common / r8data / tau(ntmax),gtau(ntmax),weight(ntmax),totalw
43  common /approx/ break(lpkmax),coef(ltkmax),l,k
44 
45  errl1 = 0.0d+00
46  errl2 = 0.0d+00
47  errmax = 0.0d+00
48 
49  do ll=1,ntau
50  ftau(ll) = ppvalu(break, coef, l, k, tau(ll), 0 )
51  error(ll) = gtau(ll) - ftau(ll)
52  err = dabs(error(ll))
53  if (errmax .lt. err) errmax = err
54  errl1 = errl1 + err*weight(ll)
55  errl2 = errl2 + err**2*weight(ll)
56  end do
57 
58  errl1 = errl1/totalw
59  errl2 = dsqrt(errl2/totalw)
60  print 615,errl2,errl1,errmax
61  615 format(///' least square error =',e20.6/
62  & ' average error =',e20.6/
63  & ' maximum error =',e20.6//)
64 c
65 c Scale error curve and print.
66 c
67  if ( prfun ) then
68 
69  ie = 0
70  scale = 1.0d+00
71  if (errmax .ge. 10.0d+00) go to 18
72 
73  do ie=1,9
74  scale = scale*10.0d+00
75  if (errmax*scale .ge. 10.0d+00) go to 18
76  end do
77 
78  18 do 19 ll=1,ntau
79  19 error(ll) = error(ll)*scale
80 
81  print 620,ie,(ll,tau(ll),ftau(ll),error(ll),ll=1,ntau)
82  620 format(///14x,'approximation and scaled error curve'/7x,
83  &'data point',7x,'approximation',3x,'deviation x 10**',i1/
84  &(i4,f16.8,f16.8,f17.6))
85 
86  end if
87 
88  return
89  end
float * x
double precision function ppvalu(break, coef, l, k, x, jderiv)
Definition: ppvalu.f:2
subroutine l2err(prfun, ftau, error)
Definition: l2err.f:2
gtkIOStream: /tmp/gtkiostream/src/deBoor/l2err.f Source File
GTK+ IOStream  Beta