Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pygau2.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pygau2.f
1 
2 C*********************************************************************
3 
4 C...PYGAU2
5 C...Integration by adaptive Gaussian quadrature.
6 C...Adapted from the CERNLIB DGAUSS routine by K.S. Kolbig.
7 C...Carbon copy of PYGAUS, but avoids having to use it recursively.
8 
9  FUNCTION pygau2(F, A, B, EPS)
10 
11 C...Double precision and integer declarations.
12  IMPLICIT DOUBLE PRECISION(a-h, o-z)
13  IMPLICIT INTEGER(i-n)
14  INTEGER pyk,pychge,pycomp
15 
16 C...Local declarations.
17  EXTERNAL f
18  DOUBLE PRECISION f,w(12), x(12)
19  DATA x( 1) /9.6028985649753623d-1/, w( 1) /1.0122853629037626d-1/
20  DATA x( 2) /7.9666647741362674d-1/, w( 2) /2.2238103445337447d-1/
21  DATA x( 3) /5.2553240991632899d-1/, w( 3) /3.1370664587788729d-1/
22  DATA x( 4) /1.8343464249564980d-1/, w( 4) /3.6268378337836198d-1/
23  DATA x( 5) /9.8940093499164993d-1/, w( 5) /2.7152459411754095d-2/
24  DATA x( 6) /9.4457502307323258d-1/, w( 6) /6.2253523938647893d-2/
25  DATA x( 7) /8.6563120238783174d-1/, w( 7) /9.5158511682492785d-2/
26  DATA x( 8) /7.5540440835500303d-1/, w( 8) /1.2462897125553387d-1/
27  DATA x( 9) /6.1787624440264375d-1/, w( 9) /1.4959598881657673d-1/
28  DATA x(10) /4.5801677765722739d-1/, w(10) /1.6915651939500254d-1/
29  DATA x(11) /2.8160355077925891d-1/, w(11) /1.8260341504492359d-1/
30  DATA x(12) /9.5012509837637440d-2/, w(12) /1.8945061045506850d-1/
31 
32 C...The Gaussian quadrature algorithm.
33  h = 0d0
34  IF(b .EQ. a) goto 140
35  const = 5d-3 / abs(b-a)
36  bb = a
37  100 CONTINUE
38  aa = bb
39  bb = b
40  110 CONTINUE
41  c1 = 0.5d0*(bb+aa)
42  c2 = 0.5d0*(bb-aa)
43  s8 = 0d0
44  DO 120 i = 1, 4
45  u = c2*x(i)
46  s8 = s8 + w(i) * (f(c1+u) + f(c1-u))
47  120 CONTINUE
48  s16 = 0d0
49  DO 130 i = 5, 12
50  u = c2*x(i)
51  s16 = s16 + w(i) * (f(c1+u) + f(c1-u))
52  130 CONTINUE
53  s16 = c2*s16
54  IF(dabs(s16-c2*s8) .LE. eps*(1d0+dabs(s16))) THEN
55  h = h + s16
56  IF(bb .NE. b) goto 100
57  ELSE
58  bb = c1
59  IF(1d0 + const*abs(c2) .NE. 1d0) goto 110
60  h = 0d0
61  CALL pyerrm(18,'(PYGAU2:) too high accuracy required')
62  goto 140
63  ENDIF
64  140 CONTINUE
65  pygau2 = h
66 
67  RETURN
68  END