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