Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2789_MathNetNumerics-Exploration/HeuristicLab.Algorithms.DataAnalysis.Experimental/sbart/bsplvb.f @ 17456

Last change on this file since 17456 was 15457, checked in by gkronber, 7 years ago

#2789 added Finbarr O'Sullivan smoothing spline code

File size: 3.8 KB
Line 
1      subroutine bsplvb ( t, jhigh, index, x, left, biatx )
2c  from  * a practical guide to splines *  by c. de boor   
3calculates the value of all possibly nonzero b-splines at  x  of order
4c
5c               jout  =  max( jhigh , (j+1)*(index-1) )
6c
7c  with knot sequence  t .
8c
9c******  i n p u t  ******
10c  t.....knot sequence, of length  left + jout  , assumed to be nonde-
11c        creasing.  a s s u m p t i o n . . . .
12c                       t(left)  .lt.  t(left + 1)   .
13c   d i v i s i o n  b y  z e r o  will result if  t(left) = t(left+1)
14c  jhigh,
15c  index.....integers which determine the order  jout = max(jhigh,
16c        (j+1)*(index-1))  of the b-splines whose values at  x  are to
17c        be returned.  index  is used to avoid recalculations when seve-
18c        ral columns of the triangular array of b-spline values are nee-
19c        ded (e.g., in  bsplpp  or in  bsplvd ). precisely,
20c                     if  index = 1 ,
21c        the calculation starts from scratch and the entire triangular
22c        array of b-spline values of orders 1,2,...,jhigh  is generated
23c        order by order , i.e., column by column .
24c                     if  index = 2 ,
25c        only the b-spline values of order  j+1, j+2, ..., jout  are ge-
26c        nerated, the assumption being that  biatx , j , deltal , deltar
27c        are, on entry, as they were on exit at the previous call.
28c           in particular, if  jhigh = 0, then  jout = j+1, i.e., just
29c        the next column of b-spline values is generated.
30c
31c  w a r n i n g . . .  the restriction   jout .le. jmax (= 20)  is im-
32c        posed arbitrarily by the dimension statement for  deltal  and
33c        deltar  below, but is  n o w h e r e  c h e c k e d  for .
34c
35c  x.....the point at which the b-splines are to be evaluated.
36c  left.....an integer chosen (usually) so that
37c                  t(left) .le. x .le. t(left+1)  .
38c
39c******  o u t p u t  ******
40c  biatx.....array of length  jout , with  biatx(i)  containing the val-
41c        ue at  x  of the polynomial of order  jout  which agrees with
42c        the b-spline  b(left-jout+i,jout,t)  on the interval (t(left),
43c        t(left+1)) .
44c
45c******  m e t h o d  ******
46c  the recurrence relation
47c
48c                       x - t(i)              t(i+j+1) - x
49c     b(i,j+1)(x)  =  -----------b(i,j)(x) + ---------------b(i+1,j)(x)
50c                     t(i+j)-t(i)            t(i+j+1)-t(i+1)
51c
52c  is used (repeatedly) to generate the (j+1)-vector  b(left-j,j+1)(x),
53c  ...,b(left,j+1)(x)  from the j-vector  b(left-j+1,j)(x),...,
54c  b(left,j)(x), storing the new values in  biatx  over the old. the
55c  facts that
56c            b(i,1) = 1  if  t(i) .le. x .lt. t(i+1)
57c  and that
58c            b(i,j)(x) = 0  unless  t(i) .le. x .lt. t(i+j)
59c  are used. the particular organization of the calculations follows al-
60c  gorithm  (8)  in chapter x of the text.
61c
62      integer index,jhigh,left,   i,j,jmax,jp1
63      parameter (jmax = 20)
64      real biatx(jhigh),t(1),x,   deltal(jmax),deltar(jmax),saved,term
65C     real biatx(jhigh),t(1),x,   deltal(20),deltar(20),saved,term
66c     dimension biatx(jout), t(left+jout)
67current fortran standard makes it impossible to specify the length of
68c  t  and of  biatx  precisely without the introduction of otherwise
69c  superfluous additional arguments.
70      data j/1/
71      save j,deltal,deltar
72c
73                                        go to (10,20), index
74   10 j = 1
75      biatx(1) = 1.
76      if (j .ge. jhigh)                 go to 99
77c
78   20    jp1 = j + 1
79         deltar(j) = t(left+j) - x
80         deltal(j) = x - t(left+1-j)
81         saved = 0.
82         do 26 i=1,j
83            term = biatx(i)/(deltar(i) + deltal(jp1-i))
84            biatx(i) = saved + deltar(i)*term
85   26       saved = deltal(jp1-i)*term
86         biatx(jp1) = saved
87         j = jp1
88         if (j .lt. jhigh)              go to 20
89c
90   99                                   return
91      end
Note: See TracBrowser for help on using the repository browser.