dpfqad.f 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. *DECK DPFQAD
  2. SUBROUTINE DPFQAD (F, LDC, C, XI, LXI, K, ID, X1, X2, TOL, QUAD,
  3. + IERR)
  4. C***BEGIN PROLOGUE DPFQAD
  5. C***PURPOSE Compute the integral on (X1,X2) of a product of a
  6. C function 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 DOUBLE 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 **** a double precision routine ****
  16. C DPFQAD 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
  20. C routine, DPPGQ8 (a modification of GAUS8), integrates the
  21. C product on subintervals of (X1,X2) formed by the included
  22. C break points. Integration outside of (XI(1),XI(LXI+1)) is
  23. C permitted provided F is defined.
  24. C
  25. C The maximum number of significant digits obtainable in
  26. C DBSQAD is the smaller of 18 and the number of digits
  27. C carried in double precision arithmetic.
  28. C
  29. C Description of arguments
  30. C Input F,C,XI,X1,X2,TOL are double precision
  31. C F - external function of one argument for the
  32. C integrand PF(X)=F(X)*DPPVAL(LDC,C,XI,LXI,K,ID,X,
  33. C INPPV)
  34. C LDC - leading dimension of matrix C, LDC .GE. K
  35. C C(I,J) - right Taylor derivatives at XI(J), I=1,K , J=1,LXI
  36. C XI(*) - break point array of length LXI+1
  37. C LXI - number of polynomial pieces
  38. C K - order of B-spline, K .GE. 1
  39. C ID - order of the spline derivative, 0 .LE. ID .LE. K-1
  40. C ID=0 gives the spline function
  41. C X1,X2 - end points of quadrature interval, normally in
  42. C XI(1) .LE. X .LE. XI(LXI+1)
  43. C TOL - desired accuracy for the quadrature, suggest
  44. C 10.*DTOL .LT. TOL .LE. 0.1 where DTOL is the
  45. C maximum of 1.0D-18 and double precision unit
  46. C roundoff for the machine = D1MACH(4)
  47. C
  48. C Output QUAD is double precision
  49. C QUAD - integral of PF(X) on (X1,X2)
  50. C IERR - a status code
  51. C IERR=1 normal return
  52. C 2 some quadrature does not meet the
  53. C requested tolerance
  54. C
  55. C Error Conditions
  56. C Improper input is a fatal error.
  57. C Some quadrature does not meet the requested tolerance.
  58. C
  59. C***REFERENCES D. E. Amos, Quadrature subroutines for splines and
  60. C B-splines, Report SAND79-1825, Sandia Laboratories,
  61. C December 1979.
  62. C***ROUTINES CALLED D1MACH, DINTRV, DPPGQ8, XERMSG
  63. C***REVISION HISTORY (YYMMDD)
  64. C 800901 DATE WRITTEN
  65. C 890531 Changed all specific intrinsics to generic. (WRB)
  66. C 890531 REVISION DATE from Version 3.2
  67. C 891214 Prologue converted to Version 4.0 format. (BAB)
  68. C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
  69. C 900326 Removed duplicate information from DESCRIPTION section.
  70. C (WRB)
  71. C 920501 Reformatted the REFERENCES section. (WRB)
  72. C***END PROLOGUE DPFQAD
  73. C
  74. INTEGER ID,IERR,IFLG,ILO,IL1,IL2,INPPV,K,LDC,LEFT,LXI,MF1,MF2
  75. DOUBLE PRECISION A,AA,ANS,B,BB,C,Q,QUAD,TA,TB,TOL,WTOL,XI,X1,X2
  76. DOUBLE PRECISION D1MACH, F
  77. DIMENSION XI(*), C(LDC,*)
  78. EXTERNAL F
  79. C
  80. C***FIRST EXECUTABLE STATEMENT DPFQAD
  81. IERR = 1
  82. QUAD = 0.0D0
  83. IF(K.LT.1) GO TO 100
  84. IF(LDC.LT.K) GO TO 105
  85. IF(ID.LT.0 .OR. ID.GE.K) GO TO 110
  86. IF(LXI.LT.1) GO TO 115
  87. WTOL = D1MACH(4)
  88. WTOL = MAX(WTOL,1.0D-18)
  89. IF (TOL.LT.WTOL .OR. TOL.GT.0.1D0) GO TO 20
  90. AA = MIN(X1,X2)
  91. BB = MAX(X1,X2)
  92. IF (AA.EQ.BB) RETURN
  93. ILO = 1
  94. CALL DINTRV(XI, LXI, AA, ILO, IL1, MF1)
  95. CALL DINTRV(XI, LXI, BB, ILO, IL2, MF2)
  96. Q = 0.0D0
  97. INPPV = 1
  98. DO 10 LEFT=IL1,IL2
  99. TA = XI(LEFT)
  100. A = MAX(AA,TA)
  101. IF (LEFT.EQ.1) A = AA
  102. TB = BB
  103. IF (LEFT.LT.LXI) TB = XI(LEFT+1)
  104. B = MIN(BB,TB)
  105. CALL DPPGQ8(F,LDC,C,XI,LXI,K,ID,A,B,INPPV,TOL,ANS,IFLG)
  106. IF (IFLG.GT.1) IERR = 2
  107. Q = Q + ANS
  108. 10 CONTINUE
  109. IF (X1.GT.X2) Q = -Q
  110. QUAD = Q
  111. RETURN
  112. C
  113. 20 CONTINUE
  114. CALL XERMSG ('SLATEC', 'DPFQAD',
  115. + 'TOL IS LESS DTOL OR GREATER THAN 0.1', 2, 1)
  116. RETURN
  117. 100 CONTINUE
  118. CALL XERMSG ('SLATEC', 'DPFQAD', 'K DOES NOT SATISFY K.GE.1', 2,
  119. + 1)
  120. RETURN
  121. 105 CONTINUE
  122. CALL XERMSG ('SLATEC', 'DPFQAD', 'LDC DOES NOT SATISFY LDC.GE.K',
  123. + 2, 1)
  124. RETURN
  125. 110 CONTINUE
  126. CALL XERMSG ('SLATEC', 'DPFQAD',
  127. + 'ID DOES NOT SATISFY 0.LE.ID.LT.K', 2, 1)
  128. RETURN
  129. 115 CONTINUE
  130. CALL XERMSG ('SLATEC', 'DPFQAD', 'LXI DOES NOT SATISFY LXI.GE.1',
  131. + 2, 1)
  132. RETURN
  133. END