2 SUBROUTINE DQC25F
(F
, A
, B
, OMEGA
, INTEGR
, NRMOM
, MAXP1
, KSAVE
,
3 + RESULT
, ABSERR
, NEVAL
, RESABS
, RESASC
, MOMCOM
, CHEBMO
)
4 C***BEGIN PROLOGUE DQC25F
5 C***PURPOSE To compute the integral I=Integral of F(X) over (A,B)
6 C Where W(X) = COS(OMEGA*X) or W(X)=SIN(OMEGA*X) and to
7 C compute J = Integral of ABS(F) over (A,B). For small value
8 C of OMEGA or small intervals (A,B) the 15-point GAUSS-KRONRO
9 C Rule is used. Otherwise a generalized CLENSHAW-CURTIS
11 C***LIBRARY SLATEC (QUADPACK)
13 C***TYPE DOUBLE PRECISION (QC25F-S, DQC25F-D)
14 C***KEYWORDS CLENSHAW-CURTIS METHOD, GAUSS-KRONROD RULES,
15 C INTEGRATION RULES FOR FUNCTIONS WITH COS OR SIN FACTOR,
16 C QUADPACK, QUADRATURE
17 C***AUTHOR Piessens, Robert
18 C Applied Mathematics and Programming Division
21 C Applied Mathematics and Programming Division
25 C Integration rules for functions with COS or SIN factor
26 C Standard fortran subroutine
27 C Double precision version
31 C F - Double precision
32 C Function subprogram defining the integrand
33 C function F(X). The actual name for F needs to
34 C be declared E X T E R N A L in the calling program.
36 C A - Double precision
37 C Lower limit of integration
39 C B - Double precision
40 C Upper limit of integration
42 C OMEGA - Double precision
43 C Parameter in the WEIGHT function
46 C Indicates which WEIGHT function is to be used
47 C INTEGR = 1 W(X) = COS(OMEGA*X)
48 C INTEGR = 2 W(X) = SIN(OMEGA*X)
51 C The length of interval (A,B) is equal to the length
52 C of the original integration interval divided by
53 C 2**NRMOM (we suppose that the routine is used in an
54 C adaptive integration process, otherwise set
55 C NRMOM = 0). NRMOM must be zero at the first call.
58 C Gives an upper bound on the number of Chebyshev
59 C moments which can be stored, i.e. for the
60 C intervals of lengths ABS(BB-AA)*2**(-L),
61 C L = 0,1,2, ..., MAXP1-2.
64 C Key which is one when the moments for the
65 C current interval have been computed
68 C RESULT - Double precision
69 C Approximation to the integral I
71 C ABSERR - Double precision
72 C Estimate of the modulus of the absolute
73 C error, which should equal or exceed ABS(I-RESULT)
76 C Number of integrand evaluations
78 C RESABS - Double precision
79 C Approximation to the integral J
81 C RESASC - Double precision
82 C Approximation to the integral of ABS(F-I/(B-A))
86 C For each interval length we need to compute the
87 C Chebyshev moments. MOMCOM counts the number of
88 C intervals for which these moments have already been
89 C computed. If NRMOM.LT.MOMCOM or KSAVE = 1, the
90 C Chebyshev moments for the interval (A,B) have
91 C already been computed and stored, otherwise we
92 C compute them and we increase MOMCOM.
94 C CHEBMO - Double precision
95 C Array of dimension at least (MAXP1,25) containing
96 C the modified Chebyshev moments for the first MOMCOM
97 C MOMCOM interval lengths
99 C ......................................................................
101 C***REFERENCES (NONE)
102 C***ROUTINES CALLED D1MACH, DGTSL, DQCHEB, DQK15W, DQWGTF
103 C***REVISION HISTORY (YYMMDD)
104 C 810101 DATE WRITTEN
105 C 890531 Changed all specific intrinsics to generic. (WRB)
106 C 890531 REVISION DATE from Version 3.2
107 C 891214 Prologue converted to Version 4.0 format. (BAB)
108 C***END PROLOGUE DQC25F
110 DOUBLE PRECISION A
,ABSERR
,AC
,AN
,AN2
,AS
,ASAP
,ASS
,B
,CENTR
,CHEBMO
,
111 1 CHEB12
,CHEB24
,CONC
,CONS
,COSPAR
,D
,DQWGTF
,D1
,
112 2 D1MACH
,D2
,ESTC
,ESTS
,F
,FVAL
,HLGTH
,OFLOW
,OMEGA
,PARINT
,PAR2
,PAR22
,
113 3 P2
,P3
,P4
,RESABS
,RESASC
,RESC12
,RESC24
,RESS12
,RESS24
,RESULT
,
115 INTEGER I
,IERS
,INTEGR
,ISYM
,J
,K
,KSAVE
,M
,MOMCOM
,NEVAL
,MAXP1
,
118 DIMENSION CHEBMO
(MAXP1
,25),CHEB12
(13),CHEB24
(25),D
(25),D1
(25),
119 1 D2
(25),FVAL
(25),V
(28),X
(11)
123 C THE VECTOR X CONTAINS THE VALUES COS(K*PI/24)
124 C K = 1, ...,11, TO BE USED FOR THE CHEBYSHEV EXPANSION OF F
127 DATA X
(1) / 0.9914448613 7381041114 4557526928 563D0
/
128 DATA X
(2) / 0.9659258262 8906828674 9743199728 897D0
/
129 DATA X
(3) / 0.9238795325 1128675612 8183189396 788D0
/
130 DATA X
(4) / 0.8660254037 8443864676 3723170752 936D0
/
131 DATA X
(5) / 0.7933533402 9123516457 9776961501 299D0
/
132 DATA X
(6) / 0.7071067811 8654752440 0844362104 849D0
/
133 DATA X
(7) / 0.6087614290 0872063941 6097542898 164D0
/
134 DATA X
(8) / 0.5000000000 0000000000 0000000000 000D0
/
135 DATA X
(9) / 0.3826834323 6508977172 8459984030 399D0
/
136 DATA X
(10) / 0.2588190451 0252076234 8898837624 048D0
/
137 DATA X
(11) / 0.1305261922 2005159154 8406227895 489D0
/
139 C LIST OF MAJOR VARIABLES
140 C -----------------------
142 C CENTR - MID POINT OF THE INTEGRATION INTERVAL
143 C HLGTH - HALF-LENGTH OF THE INTEGRATION INTERVAL
144 C FVAL - VALUE OF THE FUNCTION F AT THE POINTS
145 C (B-A)*0.5*COS(K*PI/12) + (B+A)*0.5, K = 0, ..., 24
146 C CHEB12 - COEFFICIENTS OF THE CHEBYSHEV SERIES EXPANSION
147 C OF DEGREE 12, FOR THE FUNCTION F, IN THE
149 C CHEB24 - COEFFICIENTS OF THE CHEBYSHEV SERIES EXPANSION
150 C OF DEGREE 24, FOR THE FUNCTION F, IN THE
152 C RESC12 - APPROXIMATION TO THE INTEGRAL OF
153 C COS(0.5*(B-A)*OMEGA*X)*F(0.5*(B-A)*X+0.5*(B+A))
154 C OVER (-1,+1), USING THE CHEBYSHEV SERIES
155 C EXPANSION OF DEGREE 12
156 C RESC24 - APPROXIMATION TO THE SAME INTEGRAL, USING THE
157 C CHEBYSHEV SERIES EXPANSION OF DEGREE 24
158 C RESS12 - THE ANALOGUE OF RESC12 FOR THE SINE
159 C RESS24 - THE ANALOGUE OF RESC24 FOR THE SINE
162 C MACHINE DEPENDENT CONSTANT
163 C --------------------------
165 C OFLOW IS THE LARGEST POSITIVE MAGNITUDE.
167 C***FIRST EXECUTABLE STATEMENT DQC25F
170 CENTR
= 0.5D
+00*(B
+A
)
171 HLGTH
= 0.5D
+00*(B
-A
)
174 C COMPUTE THE INTEGRAL USING THE 15-POINT GAUSS-KRONROD
175 C FORMULA IF THE VALUE OF THE PARAMETER IN THE INTEGRAND
178 IF(ABS
(PARINT
).GT
.0.2D
+01) GO TO 10
179 CALL DQK15W
(F
,DQWGTF
,OMEGA
,P2
,P3
,P4
,INTEGR
,A
,B
,RESULT
,
180 1 ABSERR
,RESABS
,RESASC
)
184 C COMPUTE THE INTEGRAL USING THE GENERALIZED CLENSHAW-
187 10 CONC
= HLGTH*COS
(CENTR*OMEGA
)
188 CONS
= HLGTH*SIN
(CENTR*OMEGA
)
192 C CHECK WHETHER THE CHEBYSHEV MOMENTS FOR THIS INTERVAL
193 C HAVE ALREADY BEEN COMPUTED.
195 IF(NRMOM
.LT
.MOMCOM
.OR
.KSAVE
.EQ
.1) GO TO 120
197 C COMPUTE A NEW SET OF CHEBYSHEV MOMENTS.
205 C COMPUTE THE CHEBYSHEV MOMENTS WITH RESPECT TO COSINE.
207 V
(1) = 0.2D
+01*SINPAR
/PARINT
208 V
(2) = (0.8D
+01*COSPAR
+(PAR2
+PAR2
-0.8D
+01)*SINPAR
/PARINT
)/PAR2
209 V
(3) = (0.32D
+02*(PAR2
-0.12D
+02)*COSPAR
+(0.2D
+01*
210 1 ((PAR2
-0.80D
+02)*PAR2
+0.192D
+03)*SINPAR
)/PARINT
)/(PAR2*PAR2
)
212 AS
= 0.24D
+02*PARINT*SINPAR
213 IF(ABS
(PARINT
).GT
.0.24D
+02) GO TO 30
215 C COMPUTE THE CHEBYSHEV MOMENTS AS THE SOLUTIONS OF A
216 C BOUNDARY VALUE PROBLEM WITH 1 INITIAL VALUE (V(3)) AND 1
217 C END VALUE (COMPUTED USING AN ASYMPTOTIC FORMULA).
224 D
(K
) = -0.2D
+01*(AN2
-0.4D
+01)*(PAR22
-AN2
-AN2
)
225 D2
(K
) = (AN
-0.1D
+01)*(AN
-0.2D
+01)*PAR2
226 D1
(K
+1) = (AN
+0.3D
+01)*(AN
+0.4D
+01)*PAR2
227 V
(K
+3) = AS
-(AN2
-0.4D
+01)*AC
231 D
(NOEQU
) = -0.2D
+01*(AN2
-0.4D
+01)*(PAR22
-AN2
-AN2
)
232 V
(NOEQU
+3) = AS
-(AN2
-0.4D
+01)*AC
233 V
(4) = V
(4)-0.56D
+02*PAR2*V
(3)
235 ASAP
= (((((0.210D
+03*PAR2
-0.1D
+01)*COSPAR
-(0.105D
+03*PAR2
236 1 -0.63D
+02)*ASS
)/AN2
-(0.1D
+01-0.15D
+02*PAR2
)*COSPAR
237 2 +0.15D
+02*ASS
)/AN2
-COSPAR
+0.3D
+01*ASS
)/AN2
-COSPAR
)/AN2
238 V
(NOEQU
+3) = V
(NOEQU
+3)-0.2D
+01*ASAP*PAR2*
(AN
-0.1D
+01)*
241 C SOLVE THE TRIDIAGONAL SYSTEM BY MEANS OF GAUSSIAN
242 C ELIMINATION WITH PARTIAL PIVOTING.
244 C *** CALL TO DGTSL MUST BE REPLACED BY CALL TO
245 C *** DOUBLE PRECISION VERSION OF LINPACK ROUTINE SGTSL
247 CALL DGTSL
(NOEQU
,D1
,D
,D2
,V
(4),IERS
)
250 C COMPUTE THE CHEBYSHEV MOMENTS BY MEANS OF FORWARD
256 V
(I
) = ((AN2
-0.4D
+01)*(0.2D
+01*(PAR22
-AN2
-AN2
)*V
(I
-1)-AC
)
257 1 +AS
-PAR2*
(AN
+0.1D
+01)*(AN
+0.2D
+01)*V
(I
-2))/
258 2 (PAR2*
(AN
-0.1D
+01)*(AN
-0.2D
+01))
262 CHEBMO
(M
,2*J
-1) = V
(J
)
265 C COMPUTE THE CHEBYSHEV MOMENTS WITH RESPECT TO SINE.
267 V
(1) = 0.2D
+01*(SINPAR
-PARINT*COSPAR
)/PAR2
268 V
(2) = (0.18D
+02-0.48D
+02/PAR2
)*SINPAR
/PAR2
269 1 +(-0.2D
+01+0.48D
+02/PAR2
)*COSPAR
/PARINT
270 AC
= -0.24D
+02*PARINT*COSPAR
272 IF(ABS
(PARINT
).GT
.0.24D
+02) GO TO 80
274 C COMPUTE THE CHEBYSHEV MOMENTS AS THE SOLUTIONS OF A BOUNDARY
275 C VALUE PROBLEM WITH 1 INITIAL VALUE (V(2)) AND 1 END VALUE
276 C (COMPUTED USING AN ASYMPTOTIC FORMULA).
281 D
(K
) = -0.2D
+01*(AN2
-0.4D
+01)*(PAR22
-AN2
-AN2
)
282 D2
(K
) = (AN
-0.1D
+01)*(AN
-0.2D
+01)*PAR2
283 D1
(K
+1) = (AN
+0.3D
+01)*(AN
+0.4D
+01)*PAR2
284 V
(K
+2) = AC
+(AN2
-0.4D
+01)*AS
288 D
(NOEQU
) = -0.2D
+01*(AN2
-0.4D
+01)*(PAR22
-AN2
-AN2
)
289 V
(NOEQU
+2) = AC
+(AN2
-0.4D
+01)*AS
290 V
(3) = V
(3)-0.42D
+02*PAR2*V
(2)
292 ASAP
= (((((0.105D
+03*PAR2
-0.63D
+02)*ASS
+(0.210D
+03*PAR2
293 1 -0.1D
+01)*SINPAR
)/AN2
+(0.15D
+02*PAR2
-0.1D
+01)*SINPAR
-
294 2 0.15D
+02*ASS
)/AN2
-0.3D
+01*ASS
-SINPAR
)/AN2
-SINPAR
)/AN2
295 V
(NOEQU
+2) = V
(NOEQU
+2)-0.2D
+01*ASAP*PAR2*
(AN
-0.1D
+01)
298 C SOLVE THE TRIDIAGONAL SYSTEM BY MEANS OF GAUSSIAN
299 C ELIMINATION WITH PARTIAL PIVOTING.
301 C *** CALL TO DGTSL MUST BE REPLACED BY CALL TO
302 C *** DOUBLE PRECISION VERSION OF LINPACK ROUTINE SGTSL
304 CALL DGTSL
(NOEQU
,D1
,D
,D2
,V
(3),IERS
)
307 C COMPUTE THE CHEBYSHEV MOMENTS BY MEANS OF FORWARD RECURSION.
312 V
(I
) = ((AN2
-0.4D
+01)*(0.2D
+01*(PAR22
-AN2
-AN2
)*V
(I
-1)+AS
)
313 1 +AC
-PAR2*
(AN
+0.1D
+01)*(AN
+0.2D
+01)*V
(I
-2))
314 2 /(PAR2*
(AN
-0.1D
+01)*(AN
-0.2D
+01))
320 120 IF (NRMOM
.LT
.MOMCOM
) M
= NRMOM
+1
321 IF (MOMCOM
.LT
.(MAXP1
-1).AND
.NRMOM
.GE
.MOMCOM
) MOMCOM
= MOMCOM
+1
323 C COMPUTE THE COEFFICIENTS OF THE CHEBYSHEV EXPANSIONS
324 C OF DEGREES 12 AND 24 OF THE FUNCTION F.
326 FVAL
(1) = 0.5D
+00*F
(CENTR
+HLGTH
)
328 FVAL
(25) = 0.5D
+00*F
(CENTR
-HLGTH
)
331 FVAL
(I
) = F
(HLGTH*X
(I
-1)+CENTR
)
332 FVAL
(ISYM
) = F
(CENTR
-HLGTH*X
(I
-1))
334 CALL DQCHEB
(X
,FVAL
,CHEB12
,CHEB24
)
336 C COMPUTE THE INTEGRAL AND ERROR ESTIMATES.
338 RESC12
= CHEB12
(13)*CHEBMO
(M
,13)
342 RESC12
= RESC12
+CHEB12
(K
)*CHEBMO
(M
,K
)
343 RESS12
= RESS12
+CHEB12
(K
+1)*CHEBMO
(M
,K
+1)
346 RESC24
= CHEB24
(25)*CHEBMO
(M
,25)
348 RESABS
= ABS
(CHEB24
(25))
351 RESC24
= RESC24
+CHEB24
(K
)*CHEBMO
(M
,K
)
352 RESS24
= RESS24
+CHEB24
(K
+1)*CHEBMO
(M
,K
+1)
353 RESABS
= RESABS
+ ABS
(CHEB24
(K
))+ABS
(CHEB24
(K
+1))
356 ESTC
= ABS
(RESC24
-RESC12
)
357 ESTS
= ABS
(RESS24
-RESS12
)
358 RESABS
= RESABS*ABS
(HLGTH
)
359 IF(INTEGR
.EQ
.2) GO TO 160
360 RESULT
= CONC*RESC24
-CONS*RESS24
361 ABSERR
= ABS
(CONC*ESTC
)+ABS
(CONS*ESTS
)
363 160 RESULT
= CONC*RESS24
+CONS*RESC24
364 ABSERR
= ABS
(CONC*ESTS
)+ABS
(CONS*ESTC
)