dbspdr.f 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. *DECK DBSPDR
  2. SUBROUTINE DBSPDR (T, A, N, K, NDERIV, AD)
  3. C***BEGIN PROLOGUE DBSPDR
  4. C***PURPOSE Use the B-representation to construct a divided difference
  5. C table preparatory to a (right) derivative calculation.
  6. C***LIBRARY SLATEC
  7. C***CATEGORY E3, K6
  8. C***TYPE DOUBLE PRECISION (BSPDR-S, DBSPDR-D)
  9. C***KEYWORDS B-SPLINE, DATA FITTING, DIFFERENTIATION OF SPLINES,
  10. C INTERPOLATION
  11. C***AUTHOR Amos, D. E., (SNLA)
  12. C***DESCRIPTION
  13. C
  14. C Written by Carl de Boor and modified by D. E. Amos
  15. C
  16. C Abstract **** a double precision routine ****
  17. C DBSPDR is the BSPLDR routine of the reference.
  18. C
  19. C DBSPDR uses the B-representation (T,A,N,K) to construct a
  20. C divided difference table ADIF preparatory to a (right)
  21. C derivative calculation in DBSPEV. The lower triangular matrix
  22. C ADIF is stored in vector AD by columns. The arrays are
  23. C related by
  24. C
  25. C ADIF(I,J) = AD(I-J+1 + (2*N-J+2)*(J-1)/2)
  26. C
  27. C I = J,N , J=1,NDERIV.
  28. C
  29. C Description of Arguments
  30. C
  31. C Input T,A are double precision
  32. C T - knot vector of length N+K
  33. C A - B-spline coefficient vector of length N
  34. C N - number of B-spline coefficients
  35. C N = sum of knot multiplicities-K
  36. C K - order of the spline, K .GE. 1
  37. C NDERIV - number of derivatives, 1 .LE. NDERIV .LE. K.
  38. C NDERIV=1 gives the zero-th derivative =
  39. C function value
  40. C
  41. C Output AD is double precision
  42. C AD - table of differences in a vector of length
  43. C (2*N-NDERIV+1)*NDERIV/2 for input to DBSPEV
  44. C
  45. C Error Conditions
  46. C Improper input is a fatal error
  47. C
  48. C***REFERENCES Carl de Boor, Package for calculating with B-splines,
  49. C SIAM Journal on Numerical Analysis 14, 3 (June 1977),
  50. C pp. 441-472.
  51. C***ROUTINES CALLED XERMSG
  52. C***REVISION HISTORY (YYMMDD)
  53. C 800901 DATE WRITTEN
  54. C 890831 Modified array declarations. (WRB)
  55. C 890911 Removed unnecessary intrinsics. (WRB)
  56. C 890911 REVISION DATE from Version 3.2
  57. C 891214 Prologue converted to Version 4.0 format. (BAB)
  58. C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
  59. C 920501 Reformatted the REFERENCES section. (WRB)
  60. C***END PROLOGUE DBSPDR
  61. C
  62. C
  63. INTEGER I, ID, II, IPKMID, JJ, JM, K, KMID, N, NDERIV
  64. DOUBLE PRECISION A, AD, DIFF, FKMID, T
  65. C DIMENSION T(N+K), AD((2*N-NDERIV+1)*NDERIV/2)
  66. DIMENSION T(*), A(*), AD(*)
  67. C***FIRST EXECUTABLE STATEMENT DBSPDR
  68. IF(K.LT.1) GO TO 100
  69. IF(N.LT.K) GO TO 105
  70. IF(NDERIV.LT.1 .OR. NDERIV.GT.K) GO TO 110
  71. DO 10 I=1,N
  72. AD(I) = A(I)
  73. 10 CONTINUE
  74. IF (NDERIV.EQ.1) RETURN
  75. KMID = K
  76. JJ = N
  77. JM = 0
  78. DO 30 ID=2,NDERIV
  79. KMID = KMID - 1
  80. FKMID = KMID
  81. II = 1
  82. DO 20 I=ID,N
  83. IPKMID = I + KMID
  84. DIFF = T(IPKMID) - T(I)
  85. IF (DIFF.NE.0.0D0) AD(II+JJ) = (AD(II+JM+1)-AD(II+JM))/
  86. 1 DIFF*FKMID
  87. II = II + 1
  88. 20 CONTINUE
  89. JM = JJ
  90. JJ = JJ + N - ID + 1
  91. 30 CONTINUE
  92. RETURN
  93. C
  94. C
  95. 100 CONTINUE
  96. CALL XERMSG ('SLATEC', 'DBSPDR', 'K DOES NOT SATISFY K.GE.1', 2,
  97. + 1)
  98. RETURN
  99. 105 CONTINUE
  100. CALL XERMSG ('SLATEC', 'DBSPDR', 'N DOES NOT SATISFY N.GE.K', 2,
  101. + 1)
  102. RETURN
  103. 110 CONTINUE
  104. CALL XERMSG ('SLATEC', 'DBSPDR',
  105. + 'NDERIV DOES NOT SATISFY 1.LE.NDERIV.LE.K', 2, 1)
  106. RETURN
  107. END