bfqad.f 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. *DECK BFQAD
  2. SUBROUTINE BFQAD (F, T, BCOEF, N, K, ID, X1, X2, TOL, QUAD, IERR,
  3. + WORK)
  4. C***BEGIN PROLOGUE BFQAD
  5. C***PURPOSE Compute the integral of a product of a function and a
  6. C derivative of a B-spline.
  7. C***LIBRARY SLATEC
  8. C***CATEGORY H2A2A1, E3, K6
  9. C***TYPE SINGLE PRECISION (BFQAD-S, DBFQAD-D)
  10. C***KEYWORDS INTEGRAL OF B-SPLINE, QUADRATURE
  11. C***AUTHOR Amos, D. E., (SNLA)
  12. C***DESCRIPTION
  13. C
  14. C Abstract
  15. C BFQAD computes the integral on (X1,X2) of a product of a
  16. C function F and the ID-th derivative of a K-th order B-spline,
  17. C using the B-representation (T,BCOEF,N,K). (X1,X2) must be
  18. C a subinterval of T(K) .LE. X .le. T(N+1). An integration
  19. C routine BSGQ8 (a modification
  20. C of GAUS8), integrates the product on sub-
  21. C intervals of (X1,X2) formed by included (distinct) knots.
  22. C
  23. C Description of Arguments
  24. C Input
  25. C F - external function of one argument for the
  26. C integrand BF(X)=F(X)*BVALU(T,BCOEF,N,K,ID,X,INBV,
  27. C WORK)
  28. C T - knot array of length N+K
  29. C BCOEF - coefficient array of length N
  30. C N - length of coefficient array
  31. C K - order of B-spline, K .GE. 1
  32. C ID - order of the spline derivative, 0 .LE. ID .LE. K-1
  33. C ID=0 gives the spline function
  34. C X1,X2 - end points of quadrature interval in
  35. C T(K) .LE. X .LE. T(N+1)
  36. C TOL - desired accuracy for the quadrature, suggest
  37. C 10.*STOL .LT. TOL .LE. 0.1 where STOL is the single
  38. C precision unit roundoff for the machine = R1MACH(4)
  39. C
  40. C Output
  41. C QUAD - integral of BF(X) on (X1,X2)
  42. C IERR - a status code
  43. C IERR=1 normal return
  44. C 2 some quadrature on (X1,X2) does not meet
  45. C the requested tolerance.
  46. C WORK - work vector of length 3*K
  47. C
  48. C Error Conditions
  49. C X1 or X2 not in T(K) .LE. X .LE. T(N+1) is a fatal error.
  50. C TOL not greater than the single precision unit roundoff or
  51. C less than 0.1 is a fatal error.
  52. C Some quadrature fails to meet the requested tolerance.
  53. C
  54. C***REFERENCES D. E. Amos, Quadrature subroutines for splines and
  55. C B-splines, Report SAND79-1825, Sandia Laboratories,
  56. C December 1979.
  57. C***ROUTINES CALLED BSGQ8, INTRV, R1MACH, XERMSG
  58. C***REVISION HISTORY (YYMMDD)
  59. C 800901 DATE WRITTEN
  60. C 890531 Changed all specific intrinsics to generic. (WRB)
  61. C 890531 REVISION DATE from Version 3.2
  62. C 891214 Prologue converted to Version 4.0 format. (BAB)
  63. C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
  64. C 900326 Removed duplicate information from DESCRIPTION section.
  65. C (WRB)
  66. C 920501 Reformatted the REFERENCES section. (WRB)
  67. C***END PROLOGUE BFQAD
  68. C
  69. C
  70. INTEGER ID, IERR, IFLG, ILO, IL1, IL2, K, LEFT, MFLAG, N, NPK, NP1
  71. REAL A,AA,ANS,B,BB,BCOEF,Q,QUAD,T,TA,TB,TOL,WORK,WTOL, X1,
  72. 1 X2
  73. REAL R1MACH, F
  74. DIMENSION T(*), BCOEF(*), WORK(*)
  75. EXTERNAL F
  76. C***FIRST EXECUTABLE STATEMENT BFQAD
  77. IERR = 1
  78. QUAD = 0.0E0
  79. IF(K.LT.1) GO TO 100
  80. IF(N.LT.K) GO TO 105
  81. IF(ID.LT.0 .OR. ID.GE.K) GO TO 110
  82. WTOL = R1MACH(4)
  83. IF (TOL.LT.WTOL .OR. TOL.GT.0.1E0) GO TO 30
  84. AA = MIN(X1,X2)
  85. BB = MAX(X1,X2)
  86. IF (AA.LT.T(K)) GO TO 20
  87. NP1 = N + 1
  88. IF (BB.GT.T(NP1)) GO TO 20
  89. IF (AA.EQ.BB) RETURN
  90. NPK = N + K
  91. C
  92. ILO = 1
  93. CALL INTRV(T, NPK, AA, ILO, IL1, MFLAG)
  94. CALL INTRV(T, NPK, BB, ILO, IL2, MFLAG)
  95. IF (IL2.GE.NP1) IL2 = N
  96. INBV = 1
  97. Q = 0.0E0
  98. DO 10 LEFT=IL1,IL2
  99. TA = T(LEFT)
  100. TB = T(LEFT+1)
  101. IF (TA.EQ.TB) GO TO 10
  102. A = MAX(AA,TA)
  103. B = MIN(BB,TB)
  104. CALL BSGQ8(F,T,BCOEF,N,K,ID,A,B,INBV,TOL,ANS,IFLG,WORK)
  105. IF (IFLG.GT.1) IERR = 2
  106. Q = Q + ANS
  107. 10 CONTINUE
  108. IF (X1.GT.X2) Q = -Q
  109. QUAD = Q
  110. RETURN
  111. C
  112. C
  113. 20 CONTINUE
  114. CALL XERMSG ('SLATEC', 'BFQAD',
  115. + 'X1 OR X2 OR BOTH DO NOT SATISFY T(K).LE.X.LE.T(N+1)', 2, 1)
  116. RETURN
  117. 30 CONTINUE
  118. CALL XERMSG ('SLATEC', 'BFQAD',
  119. + 'TOL IS LESS THAN THE SINGLE PRECISION TOLERANCE OR ' //
  120. + 'GREATER THAN 0.1', 2, 1)
  121. RETURN
  122. 100 CONTINUE
  123. CALL XERMSG ('SLATEC', 'BFQAD', 'K DOES NOT SATISFY K.GE.1', 2,
  124. + 1)
  125. RETURN
  126. 105 CONTINUE
  127. CALL XERMSG ('SLATEC', 'BFQAD', 'N DOES NOT SATISFY N.GE.K', 2,
  128. + 1)
  129. RETURN
  130. 110 CONTINUE
  131. CALL XERMSG ('SLATEC', 'BFQAD',
  132. + 'ID DOES NOT SATISFY 0 .LE. ID .LT. K', 2, 1)
  133. RETURN
  134. END