Rev 3398 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
subroutine bsplvd ( t, lent, k, x, left, a, dbiatx, nderiv )c -------- ------implicit noneC calculates value and deriv.s of all b-splines which do not vanish at xC calls bsplvbcc****** i n p u t ******c t the knot array, of length left+k (at least)c k the order of the b-splines to be evaluatedc x the point at which these values are soughtc left an integer indicating the left endpoint of the interval ofc interest. the k b-splines whose support contains the intervalc (t(left), t(left+1))c are to be considered.c a s s u m p t i o n - - - it is assumed thatc t(left) .lt. t(left+1)c division by zero will result otherwise (in b s p l v b ).c also, the output is as advertised only ifc t(left) .le. x .le. t(left+1) .c nderiv an integer indicating that values of b-splines and theirc derivatives up to but not including the nderiv-th are askedc for. ( nderiv is replaced internally by the integer in (1,k)c closest to it.)cc****** w o r k a r e a ******c a an array of order (k,k), to contain b-coeff.s of the derivat-c ives of a certain order of the k b-splines of interest.cc****** o u t p u t ******c dbiatx an array of order (k,nderiv). its entry (i,m) containsc value of (m-1)st derivative of (left-k+i)-th b-spline ofc order k for knot sequence t , i=m,...,k; m=1,...,nderiv.cc****** m e t h o d ******c values at x of all the relevant b-splines of order k,k-1,...,c k+1-nderiv are generated via bsplvb and stored temporarilyc in dbiatx . then, the b-coeffs of the required derivatives of thec b-splines of interest are generated by differencing, each from thec preceding one of lower order, and combined with the values of b-c splines of corresponding order in dbiatx to produce the desiredc values.C Argsinteger lent,k,left,nderivdouble precision t(lent),x, dbiatx(k,nderiv), a(k,k)C Localsdouble precision factor,fkp1mm,suminteger i,ideriv,il,j,jlow,jp1mid, kp1,kp1mm,ldummy,m,mhighmhigh = max0(min0(nderiv,k),1)c mhigh is usually equal to nderiv.kp1 = k+1call bsplvb(t,lent,kp1-mhigh,1,x,left,dbiatx)if (mhigh .eq. 1) go to 99c the first column of dbiatx always contains the b-spline valuesc for the current order. these are stored in column k+1-currentc order before bsplvb is called to put values for the nextc higher order on top of it.ideriv = mhighdo 15 m=2,mhighjp1mid = 1do 11 j=ideriv,kdbiatx(j,ideriv) = dbiatx(jp1mid,1)11 jp1mid = jp1mid + 1ideriv = ideriv - 1call bsplvb(t,lent,kp1-ideriv,2,x,left,dbiatx)15 continuecc at this point, b(left-k+i, k+1-j)(x) is in dbiatx(i,j) forc i=j,...,k and j=1,...,mhigh ('=' nderiv). in particular, thec first column of dbiatx is already in final form. to obtain cor-c responding derivatives of b-splines in subsequent columns, gene-c rate their b-repr. by differencing, then evaluate at x.cjlow = 1do 20 i=1,kdo 19 j=jlow,k19 a(j,i) = 0e0jlow = i20 a(i,i) = 1e0c at this point, a(.,j) contains the b-coeffs for the j-th of thec k b-splines of interest here.cdo 40 m=2,mhighkp1mm = kp1 - mfkp1mm = dble(kp1mm)il = lefti = kcc for j=1,...,k, construct b-coeffs of (m-1)st derivative ofc b-splines from those for preceding derivative by differencingc and store again in a(.,j) . the fact that a(i,j) = 0 forc i .lt. j is used.sed.do 25 ldummy=1,kp1mmfactor = fkp1mm/(t(il+kp1mm) - t(il))c the assumption that t(left).lt.t(left+1) makes denominatorc in factor nonzero.do 24 j=1,i24 a(i,j) = (a(i,j) - a(i-1,j))*factoril = il - 125 i = i - 1cc for i=1,...,k, combine b-coeffs a(.,i) with b-spline valuesc stored in dbiatx(.,m) to get value of (m-1)st derivative ofc i-th b-spline (of interest here) at x , and store inc dbiatx(i,m). storage of this value over the value of a b-splinec of order m there is safe since the remaining b-spline derivat-c ive of the same order do not use this value due to the factc that a(j,i) = 0 for j .lt. i .30 do 40 i=1,ksum = 0.jlow = max0(i,m)do 35 j=jlow,k35 sum = a(j,i)*dbiatx(j,m) + sum40 dbiatx(i,m) = sum99 returnendsubroutine bsplvb ( t, lent,jhigh, index, x, left, biatx )implicit nonec -------------calculates the value of all possibly nonzero b-splines at x of ordercc jout = dmax( jhigh , (j+1)*(index-1) )cc with knot sequence t .cc****** i n p u t ******c t.....knot sequence, of length left + jout , assumed to be nonde-c creasing. a s s u m p t i o n . . . .c t(left) .lt. t(left + 1) .c d i v i s i o n b y z e r o will result if t(left) = t(left+1)c jhigh,c index.....integers which determine the order jout = max(jhigh,c (j+1)*(index-1)) of the b-splines whose values at x are toc be returned. index is used to avoid recalculations when seve-c ral columns of the triangular array of b-spline values are nee-c ded (e.g., in bvalue or in bsplvd ). precisely,c if index = 1 ,c the calculation starts from scratch and the entire triangularc array of b-spline values of orders 1,2,...,jhigh is generatedc order by order , i.e., column by column .c if index = 2 ,c only the b-spline values of order j+1, j+2, ..., jout are ge-c nerated, the assumption being that biatx , j , deltal , deltarc are, on entry, as they were on exit at the previous call.c in particular, if jhigh = 0, then jout = j+1, i.e., justc the next column of b-spline values is generated.cc w a r n i n g . . . the restriction jout .le. jmax (= 20) is im-c posed arbitrarily by the dimension statement for deltal andc deltar below, but is n o w h e r e c h e c k e d for .cc x.....the point at which the b-splines are to be evaluated.c left.....an integer chosen (usually) so thatc t(left) .le. x .le. t(left+1) .cc****** o u t p u t ******c biatx.....array of length jout , with biatx(i) containing the val-c ue at x of the polynomial of order jout which agrees withc the b-spline b(left-jout+i,jout,t) on the interval (t(left),c t(left+1)) .cc****** m e t h o d ******c the recurrence relationcc x - t(i) t(i+j+1) - xc b(i,j+1)(x) = -----------b(i,j)(x) + ---------------b(i+1,j)(x)c t(i+j)-t(i) t(i+j+1)-t(i+1)cc is used (repeatedly) to generate the (j+1)-vector b(left-j,j+1)(x),c ...,b(left,j+1)(x) from the j-vector b(left-j+1,j)(x),...,c b(left,j)(x), storing the new values in biatx over the old. thec facts thatc b(i,1) = 1 if t(i) .le. x .lt. t(i+1)c and thatc b(i,j)(x) = 0 unless t(i) .le. x .lt. t(i+j)c are used. the particular organization of the calculations follows al-c gorithm (8) in chapter x of the text.cC Argumentsinteger lent, jhigh, index, leftdouble precision t(lent),x, biatx(jhigh)c dimension t(left+jout), biatx(jout)c -----------------------------------c current fortran standard makes it impossible to specify the length ofc t and of biatx precisely without the introduction of otherwisec superfluous additional arguments.C Local Variablesinteger jmaxparameter(jmax = 20)integer i,j,jp1double precision deltal(jmax), deltar(jmax),saved,termdata j/1/save j,deltal,deltar !(valid in fortran 77)cgo to (10,20), index10 j = 1biatx(1) = 1e0if (j .ge. jhigh) go to 99c20 jp1 = j + 1deltar(j) = t(left+j) - xdeltal(j) = x - t(left+1-j)saved = 0e0do 26 i=1,jterm = biatx(i)/(deltar(i) + deltal(jp1-i))biatx(i) = saved + deltar(i)*term26 saved = deltal(jp1-i)*termbiatx(jp1) = savedj = jp1if (j .lt. jhigh) go to 20c99 returnend