pfqad.f 4.7 KB

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