~ubuntu-branches/ubuntu/karmic/python-scipy/karmic

« back to all changes in this revision

Viewing changes to Lib/integrate/quadpack/dqagi.f

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T. Chen (new)
  • Date: 2005-03-16 02:15:29 UTC
  • Revision ID: james.westby@ubuntu.com-20050316021529-xrjlowsejs0cijig
Tags: upstream-0.3.2
ImportĀ upstreamĀ versionĀ 0.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
      subroutine dqagi(f,bound,inf,epsabs,epsrel,result,abserr,neval,
 
2
     *   ier,limit,lenw,last,iwork,work)
 
3
c***begin prologue  dqagi
 
4
c***date written   800101   (yymmdd)
 
5
c***revision date  830518   (yymmdd)
 
6
c***category no.  h2a3a1,h2a4a1
 
7
c***keywords  automatic integrator, infinite intervals,
 
8
c             general-purpose, transformation, extrapolation,
 
9
c             globally adaptive
 
10
c***author  piessens,robert,appl. math. & progr. div. - k.u.leuven
 
11
c           de doncker,elise,appl. math. & progr. div. -k.u.leuven
 
12
c***purpose  the routine calculates an approximation result to a given
 
13
c            integral   i = integral of f over (bound,+infinity)
 
14
c            or i = integral of f over (-infinity,bound)
 
15
c            or i = integral of f over (-infinity,+infinity)
 
16
c            hopefully satisfying following claim for accuracy
 
17
c            abs(i-result).le.max(epsabs,epsrel*abs(i)).
 
18
c***description
 
19
c
 
20
c        integration over infinite intervals
 
21
c        standard fortran subroutine
 
22
c
 
23
c        parameters
 
24
c         on entry
 
25
c            f      - double precision
 
26
c                     function subprogram defining the integrand
 
27
c                     function f(x). the actual name for f needs to be
 
28
c                     declared e x t e r n a l in the driver program.
 
29
c
 
30
c            bound  - double precision
 
31
c                     finite bound of integration range
 
32
c                     (has no meaning if interval is doubly-infinite)
 
33
c
 
34
c            inf    - integer
 
35
c                     indicating the kind of integration range involved
 
36
c                     inf = 1 corresponds to  (bound,+infinity),
 
37
c                     inf = -1            to  (-infinity,bound),
 
38
c                     inf = 2             to (-infinity,+infinity).
 
39
c
 
40
c            epsabs - double precision
 
41
c                     absolute accuracy requested
 
42
c            epsrel - double precision
 
43
c                     relative accuracy requested
 
44
c                     if  epsabs.le.0
 
45
c                     and epsrel.lt.max(50*rel.mach.acc.,0.5d-28),
 
46
c                     the routine will end with ier = 6.
 
47
c
 
48
c
 
49
c         on return
 
50
c            result - double precision
 
51
c                     approximation to the integral
 
52
c
 
53
c            abserr - double precision
 
54
c                     estimate of the modulus of the absolute error,
 
55
c                     which should equal or exceed abs(i-result)
 
56
c
 
57
c            neval  - integer
 
58
c                     number of integrand evaluations
 
59
c
 
60
c            ier    - integer
 
61
c                     ier = 0 normal and reliable termination of the
 
62
c                             routine. it is assumed that the requested
 
63
c                             accuracy has been achieved.
 
64
c                   - ier.gt.0 abnormal termination of the routine. the
 
65
c                             estimates for result and error are less
 
66
c                             reliable. it is assumed that the requested
 
67
c                             accuracy has not been achieved.
 
68
c            error messages
 
69
c                     ier = 1 maximum number of subdivisions allowed
 
70
c                             has been achieved. one can allow more
 
71
c                             subdivisions by increasing the value of
 
72
c                             limit (and taking the according dimension
 
73
c                             adjustments into account). however, if
 
74
c                             this yields no improvement it is advised
 
75
c                             to analyze the integrand in order to
 
76
c                             determine the integration difficulties. if
 
77
c                             the position of a local difficulty can be
 
78
c                             determined (e.g. singularity,
 
79
c                             discontinuity within the interval) one
 
80
c                             will probably gain from splitting up the
 
81
c                             interval at this point and calling the
 
82
c                             integrator on the subranges. if possible,
 
83
c                             an appropriate special-purpose integrator
 
84
c                             should be used, which is designed for
 
85
c                             handling the type of difficulty involved.
 
86
c                         = 2 the occurrence of roundoff error is
 
87
c                             detected, which prevents the requested
 
88
c                             tolerance from being achieved.
 
89
c                             the error may be under-estimated.
 
90
c                         = 3 extremely bad integrand behaviour occurs
 
91
c                             at some points of the integration
 
92
c                             interval.
 
93
c                         = 4 the algorithm does not converge.
 
94
c                             roundoff error is detected in the
 
95
c                             extrapolation table.
 
96
c                             it is assumed that the requested tolerance
 
97
c                             cannot be achieved, and that the returned
 
98
c                             result is the best which can be obtained.
 
99
c                         = 5 the integral is probably divergent, or
 
100
c                             slowly convergent. it must be noted that
 
101
c                             divergence can occur with any other value
 
102
c                             of ier.
 
103
c                         = 6 the input is invalid, because
 
104
c                             (epsabs.le.0 and
 
105
c                              epsrel.lt.max(50*rel.mach.acc.,0.5d-28))
 
106
c                              or limit.lt.1 or leniw.lt.limit*4.
 
107
c                             result, abserr, neval, last are set to
 
108
c                             zero. exept when limit or leniw is
 
109
c                             invalid, iwork(1), work(limit*2+1) and
 
110
c                             work(limit*3+1) are set to zero, work(1)
 
111
c                             is set to a and work(limit+1) to b.
 
112
c
 
113
c         dimensioning parameters
 
114
c            limit - integer
 
115
c                    dimensioning parameter for iwork
 
116
c                    limit determines the maximum number of subintervals
 
117
c                    in the partition of the given integration interval
 
118
c                    (a,b), limit.ge.1.
 
119
c                    if limit.lt.1, the routine will end with ier = 6.
 
120
c
 
121
c            lenw  - integer
 
122
c                    dimensioning parameter for work
 
123
c                    lenw must be at least limit*4.
 
124
c                    if lenw.lt.limit*4, the routine will end
 
125
c                    with ier = 6.
 
126
c
 
127
c            last  - integer
 
128
c                    on return, last equals the number of subintervals
 
129
c                    produced in the subdivision process, which
 
130
c                    determines the number of significant elements
 
131
c                    actually in the work arrays.
 
132
c
 
133
c         work arrays
 
134
c            iwork - integer
 
135
c                    vector of dimension at least limit, the first
 
136
c                    k elements of which contain pointers
 
137
c                    to the error estimates over the subintervals,
 
138
c                    such that work(limit*3+iwork(1)),... ,
 
139
c                    work(limit*3+iwork(k)) form a decreasing
 
140
c                    sequence, with k = last if last.le.(limit/2+2), and
 
141
c                    k = limit+1-last otherwise
 
142
c
 
143
c            work  - double precision
 
144
c                    vector of dimension at least lenw
 
145
c                    on return
 
146
c                    work(1), ..., work(last) contain the left
 
147
c                     end points of the subintervals in the
 
148
c                     partition of (a,b),
 
149
c                    work(limit+1), ..., work(limit+last) contain
 
150
c                     the right end points,
 
151
c                    work(limit*2+1), ...,work(limit*2+last) contain the
 
152
c                     integral approximations over the subintervals,
 
153
c                    work(limit*3+1), ..., work(limit*3+last)
 
154
c                     contain the error estimates.
 
155
c***references  (none)
 
156
c***routines called  dqagie,xerror
 
157
c***end prologue  dqagi
 
158
c
 
159
      double precision abserr,bound,epsabs,epsrel,f,result,work
 
160
      integer ier,inf,iwork,last,lenw,limit,lvl,l1,l2,l3,neval
 
161
c
 
162
      dimension iwork(limit),work(lenw)
 
163
c
 
164
      external f
 
165
c
 
166
c         check validity of limit and lenw.
 
167
c
 
168
c***first executable statement  dqagi
 
169
      ier = 6
 
170
      neval = 0
 
171
      last = 0
 
172
      result = 0.0d+00
 
173
      abserr = 0.0d+00
 
174
      if(limit.lt.1.or.lenw.lt.limit*4) go to 10
 
175
c
 
176
c         prepare call for dqagie.
 
177
c
 
178
      l1 = limit+1
 
179
      l2 = limit+l1
 
180
      l3 = limit+l2
 
181
c
 
182
      call dqagie(f,bound,inf,epsabs,epsrel,limit,result,abserr,
 
183
     *  neval,ier,work(1),work(l1),work(l2),work(l3),iwork,last)
 
184
c
 
185
c         call error handler if necessary.
 
186
c
 
187
       lvl = 0
 
188
10    if(ier.eq.6) lvl = 1
 
189
      if(ier.ne.0) call xerror(26habnormal return from dqagi,26,ier,lvl)
 
190
      return
 
191
      end