Don't use fname to define functions
[maxima.git] / src / numerical / slatec / dqagse.lisp
blob2d20153ac1aebf58fbb73873275bf99ddf67f782
1 ;;; Compiled by f2cl version:
2 ;;; ("f2cl1.l,v 46c1f6a93b0d 2012/05/03 04:40:28 toy $"
3 ;;; "f2cl2.l,v 96616d88fb7e 2008/02/22 22:19:34 rtoy $"
4 ;;; "f2cl3.l,v 96616d88fb7e 2008/02/22 22:19:34 rtoy $"
5 ;;; "f2cl4.l,v 96616d88fb7e 2008/02/22 22:19:34 rtoy $"
6 ;;; "f2cl5.l,v 46c1f6a93b0d 2012/05/03 04:40:28 toy $"
7 ;;; "f2cl6.l,v 1d5cbacbb977 2008/08/24 00:56:27 rtoy $"
8 ;;; "macros.l,v fceac530ef0c 2011/11/26 04:02:26 toy $")
10 ;;; Using Lisp CMU Common Lisp snapshot-2012-04 (20C Unicode)
11 ;;;
12 ;;; Options: ((:prune-labels nil) (:auto-save t) (:relaxed-array-decls t)
13 ;;; (:coerce-assigns :as-needed) (:array-type ':array)
14 ;;; (:array-slicing t) (:declare-common nil)
15 ;;; (:float-format double-float))
17 (in-package :slatec)
20 (defun dqagse
21 (f a b epsabs epsrel limit result abserr neval ier alist blist rlist
22 elist iord last$)
23 (declare (type (array f2cl-lib:integer4 (*)) iord)
24 (type (array double-float (*)) elist rlist blist alist)
25 (type (f2cl-lib:integer4) last$ ier neval limit)
26 (type (double-float) abserr result epsrel epsabs b a))
27 (f2cl-lib:with-multi-array-data
28 ((alist double-float alist-%data% alist-%offset%)
29 (blist double-float blist-%data% blist-%offset%)
30 (rlist double-float rlist-%data% rlist-%offset%)
31 (elist double-float elist-%data% elist-%offset%)
32 (iord f2cl-lib:integer4 iord-%data% iord-%offset%))
33 (prog ((res3la (make-array 3 :element-type 'double-float))
34 (rlist2 (make-array 52 :element-type 'double-float)) (extrap nil)
35 (noext nil) (id 0) (ierro 0) (iroff1 0) (iroff2 0) (iroff3 0)
36 (jupbnd 0) (k 0) (ksgn 0) (ktmin 0) (maxerr 0) (nres 0) (nrmax 0)
37 (numrl2 0) (abseps 0.0) (area 0.0) (area1 0.0) (area12 0.0)
38 (area2 0.0) (a1 0.0) (a2 0.0) (b1 0.0) (b2 0.0) (correc 0.0)
39 (defabs 0.0) (defab1 0.0) (defab2 0.0) (dres 0.0) (epmach 0.0)
40 (erlarg 0.0) (erlast 0.0) (errbnd 0.0) (errmax 0.0) (error1 0.0)
41 (error2 0.0) (erro12 0.0) (errsum 0.0) (ertest 0.0) (oflow 0.0)
42 (resabs 0.0) (reseps 0.0) (small 0.0) (uflow 0.0))
43 (declare (type (array double-float (52)) rlist2)
44 (type (array double-float (3)) res3la)
45 (type (double-float) uflow small reseps resabs oflow ertest
46 errsum erro12 error2 error1 errmax errbnd
47 erlast erlarg epmach dres defab2 defab1
48 defabs correc b2 b1 a2 a1 area2 area12
49 area1 area abseps)
50 (type (f2cl-lib:integer4) numrl2 nrmax nres maxerr ktmin ksgn k
51 jupbnd iroff3 iroff2 iroff1 ierro id)
52 (type f2cl-lib:logical noext extrap))
53 (setf epmach (f2cl-lib:d1mach 4))
54 (setf ier 0)
55 (setf neval 0)
56 (setf last$ 0)
57 (setf result 0.0)
58 (setf abserr 0.0)
59 (setf (f2cl-lib:fref alist-%data% (1) ((1 *)) alist-%offset%) a)
60 (setf (f2cl-lib:fref blist-%data% (1) ((1 *)) blist-%offset%) b)
61 (setf (f2cl-lib:fref rlist-%data% (1) ((1 *)) rlist-%offset%) 0.0)
62 (setf (f2cl-lib:fref elist-%data% (1) ((1 *)) elist-%offset%) 0.0)
63 (if (and (<= epsabs 0.0) (< epsrel (max (* 50.0 epmach) 5.0e-29)))
64 (setf ier 6))
65 (if (= ier 6) (go label999))
66 (setf uflow (f2cl-lib:d1mach 1))
67 (setf oflow (f2cl-lib:d1mach 2))
68 (setf ierro 0)
69 (multiple-value-bind (var-0 var-1 var-2 var-3 var-4 var-5 var-6)
70 (dqk21 f a b result abserr defabs resabs)
71 (declare (ignore var-0 var-1 var-2))
72 (setf result var-3)
73 (setf abserr var-4)
74 (setf defabs var-5)
75 (setf resabs var-6))
76 (setf dres (abs result))
77 (setf errbnd (max epsabs (* epsrel dres)))
78 (setf last$ 1)
79 (setf (f2cl-lib:fref rlist-%data% (1) ((1 *)) rlist-%offset%) result)
80 (setf (f2cl-lib:fref elist-%data% (1) ((1 *)) elist-%offset%) abserr)
81 (setf (f2cl-lib:fref iord-%data% (1) ((1 *)) iord-%offset%) 1)
82 (if (and (<= abserr (* 100.0 epmach defabs)) (> abserr errbnd))
83 (setf ier 2))
84 (if (= limit 1) (setf ier 1))
85 (if
86 (or (/= ier 0)
87 (and (<= abserr errbnd) (/= abserr resabs))
88 (= abserr 0.0))
89 (go label140))
90 (setf (f2cl-lib:fref rlist2 (1) ((1 52))) result)
91 (setf errmax abserr)
92 (setf maxerr 1)
93 (setf area result)
94 (setf errsum abserr)
95 (setf abserr oflow)
96 (setf nrmax 1)
97 (setf nres 0)
98 (setf numrl2 2)
99 (setf ktmin 0)
100 (setf extrap f2cl-lib:%false%)
101 (setf noext f2cl-lib:%false%)
102 (setf iroff1 0)
103 (setf iroff2 0)
104 (setf iroff3 0)
105 (setf ksgn -1)
106 (if (>= dres (* (- 1.0 (* 50.0 epmach)) defabs)) (setf ksgn 1))
107 (f2cl-lib:fdo (last$ 2 (f2cl-lib:int-add last$ 1))
108 ((> last$ limit) nil)
109 (tagbody
110 (setf a1
111 (f2cl-lib:fref alist-%data% (maxerr) ((1 *)) alist-%offset%))
112 (setf b1
113 (* 0.5
115 (f2cl-lib:fref alist-%data%
116 (maxerr)
117 ((1 *))
118 alist-%offset%)
119 (f2cl-lib:fref blist-%data%
120 (maxerr)
121 ((1 *))
122 blist-%offset%))))
123 (setf a2 b1)
124 (setf b2
125 (f2cl-lib:fref blist-%data% (maxerr) ((1 *)) blist-%offset%))
126 (setf erlast errmax)
127 (multiple-value-bind (var-0 var-1 var-2 var-3 var-4 var-5 var-6)
128 (dqk21 f a1 b1 area1 error1 resabs defab1)
129 (declare (ignore var-0 var-1 var-2))
130 (setf area1 var-3)
131 (setf error1 var-4)
132 (setf resabs var-5)
133 (setf defab1 var-6))
134 (multiple-value-bind (var-0 var-1 var-2 var-3 var-4 var-5 var-6)
135 (dqk21 f a2 b2 area2 error2 resabs defab2)
136 (declare (ignore var-0 var-1 var-2))
137 (setf area2 var-3)
138 (setf error2 var-4)
139 (setf resabs var-5)
140 (setf defab2 var-6))
141 (setf area12 (+ area1 area2))
142 (setf erro12 (+ error1 error2))
143 (setf errsum (- (+ errsum erro12) errmax))
144 (setf area
145 (- (+ area area12)
146 (f2cl-lib:fref rlist-%data%
147 (maxerr)
148 ((1 *))
149 rlist-%offset%)))
150 (if (or (= defab1 error1) (= defab2 error2)) (go label15))
154 (abs
155 (- (f2cl-lib:fref rlist-%data% (maxerr) ((1 *)) rlist-%offset%)
156 area12))
157 (* 1.0e-5 (abs area12)))
158 (< erro12 (* 0.99 errmax)))
159 (go label10))
160 (if extrap (setf iroff2 (f2cl-lib:int-add iroff2 1)))
161 (if (not extrap) (setf iroff1 (f2cl-lib:int-add iroff1 1)))
162 label10
163 (if (and (> last$ 10) (> erro12 errmax))
164 (setf iroff3 (f2cl-lib:int-add iroff3 1)))
165 label15
166 (setf (f2cl-lib:fref rlist-%data% (maxerr) ((1 *)) rlist-%offset%)
167 area1)
168 (setf (f2cl-lib:fref rlist-%data% (last$) ((1 *)) rlist-%offset%)
169 area2)
170 (setf errbnd (max epsabs (* epsrel (abs area))))
171 (if (or (>= (f2cl-lib:int-add iroff1 iroff2) 10) (>= iroff3 20))
172 (setf ier 2))
173 (if (>= iroff2 5) (setf ierro 3))
174 (if (= last$ limit) (setf ier 1))
176 (<= (max (abs a1) (abs b2))
177 (* (+ 1.0 (* 100.0 epmach)) (+ (abs a2) (* 1000.0 uflow))))
178 (setf ier 4))
179 (if (> error2 error1) (go label20))
180 (setf (f2cl-lib:fref alist-%data% (last$) ((1 *)) alist-%offset%) a2)
181 (setf (f2cl-lib:fref blist-%data% (maxerr) ((1 *)) blist-%offset%)
183 (setf (f2cl-lib:fref blist-%data% (last$) ((1 *)) blist-%offset%) b2)
184 (setf (f2cl-lib:fref elist-%data% (maxerr) ((1 *)) elist-%offset%)
185 error1)
186 (setf (f2cl-lib:fref elist-%data% (last$) ((1 *)) elist-%offset%)
187 error2)
188 (go label30)
189 label20
190 (setf (f2cl-lib:fref alist-%data% (maxerr) ((1 *)) alist-%offset%)
192 (setf (f2cl-lib:fref alist-%data% (last$) ((1 *)) alist-%offset%) a1)
193 (setf (f2cl-lib:fref blist-%data% (last$) ((1 *)) blist-%offset%) b1)
194 (setf (f2cl-lib:fref rlist-%data% (maxerr) ((1 *)) rlist-%offset%)
195 area2)
196 (setf (f2cl-lib:fref rlist-%data% (last$) ((1 *)) rlist-%offset%)
197 area1)
198 (setf (f2cl-lib:fref elist-%data% (maxerr) ((1 *)) elist-%offset%)
199 error2)
200 (setf (f2cl-lib:fref elist-%data% (last$) ((1 *)) elist-%offset%)
201 error1)
202 label30
203 (multiple-value-bind (var-0 var-1 var-2 var-3 var-4 var-5 var-6)
204 (dqpsrt limit last$ maxerr errmax elist iord nrmax)
205 (declare (ignore var-0 var-1 var-4 var-5))
206 (setf maxerr var-2)
207 (setf errmax var-3)
208 (setf nrmax var-6))
209 (if (<= errsum errbnd) (go label115))
210 (if (/= ier 0) (go label100))
211 (if (= last$ 2) (go label80))
212 (if noext (go label90))
213 (setf erlarg (- erlarg erlast))
214 (if (> (abs (- b1 a1)) small) (setf erlarg (+ erlarg erro12)))
215 (if extrap (go label40))
218 (abs
219 (- (f2cl-lib:fref blist-%data% (maxerr) ((1 *)) blist-%offset%)
220 (f2cl-lib:fref alist-%data% (maxerr) ((1 *)) alist-%offset%)))
221 small)
222 (go label90))
223 (setf extrap f2cl-lib:%true%)
224 (setf nrmax 2)
225 label40
226 (if (or (= ierro 3) (<= erlarg ertest)) (go label60))
227 (setf id nrmax)
228 (setf jupbnd last$)
229 (if (> last$ (+ 2 (the f2cl-lib:integer4 (truncate limit 2))))
230 (setf jupbnd
231 (f2cl-lib:int-sub (f2cl-lib:int-add limit 3) last$)))
232 (f2cl-lib:fdo (k id (f2cl-lib:int-add k 1))
233 ((> k jupbnd) nil)
234 (tagbody
235 (setf maxerr
236 (f2cl-lib:fref iord-%data%
237 (nrmax)
238 ((1 *))
239 iord-%offset%))
240 (setf errmax
241 (f2cl-lib:fref elist-%data%
242 (maxerr)
243 ((1 *))
244 elist-%offset%))
247 (abs
249 (f2cl-lib:fref blist-%data% (maxerr) ((1 *)) blist-%offset%)
250 (f2cl-lib:fref alist-%data%
251 (maxerr)
252 ((1 *))
253 alist-%offset%)))
254 small)
255 (go label90))
256 (setf nrmax (f2cl-lib:int-add nrmax 1))
257 label50))
258 label60
259 (setf numrl2 (f2cl-lib:int-add numrl2 1))
260 (setf (f2cl-lib:fref rlist2 (numrl2) ((1 52))) area)
261 (multiple-value-bind (var-0 var-1 var-2 var-3 var-4 var-5)
262 (dqelg numrl2 rlist2 reseps abseps res3la nres)
263 (declare (ignore var-1 var-4))
264 (setf numrl2 var-0)
265 (setf reseps var-2)
266 (setf abseps var-3)
267 (setf nres var-5))
268 (setf ktmin (f2cl-lib:int-add ktmin 1))
269 (if (and (> ktmin 5) (< abserr (* 0.001 errsum))) (setf ier 5))
270 (if (>= abseps abserr) (go label70))
271 (setf ktmin 0)
272 (setf abserr abseps)
273 (setf result reseps)
274 (setf correc erlarg)
275 (setf ertest (max epsabs (* epsrel (abs reseps))))
276 (if (<= abserr ertest) (go label100))
277 label70
278 (if (= numrl2 1) (setf noext f2cl-lib:%true%))
279 (if (= ier 5) (go label100))
280 (setf maxerr (f2cl-lib:fref iord-%data% (1) ((1 *)) iord-%offset%))
281 (setf errmax
282 (f2cl-lib:fref elist-%data% (maxerr) ((1 *)) elist-%offset%))
283 (setf nrmax 1)
284 (setf extrap f2cl-lib:%false%)
285 (setf small (* small 0.5))
286 (setf erlarg errsum)
287 (go label90)
288 label80
289 (setf small (* (abs (- b a)) 0.375))
290 (setf erlarg errsum)
291 (setf ertest errbnd)
292 (setf (f2cl-lib:fref rlist2 (2) ((1 52))) area)
293 label90))
294 label100
295 (if (= abserr oflow) (go label115))
296 (if (= (f2cl-lib:int-add ier ierro) 0) (go label110))
297 (if (= ierro 3) (setf abserr (+ abserr correc)))
298 (if (= ier 0) (setf ier 3))
299 (if (and (/= result 0.0) (/= area 0.0)) (go label105))
300 (if (> abserr errsum) (go label115))
301 (if (= area 0.0) (go label130))
302 (go label110)
303 label105
304 (if (> (/ abserr (abs result)) (/ errsum (abs area))) (go label115))
305 label110
306 (if (and (= ksgn -1) (<= (max (abs result) (abs area)) (* defabs 0.01)))
307 (go label130))
309 (or (> 0.01 (/ result area))
310 (> (/ result area) 100.0)
311 (> errsum (abs area)))
312 (setf ier 6))
313 (go label130)
314 label115
315 (setf result 0.0)
316 (f2cl-lib:fdo (k 1 (f2cl-lib:int-add k 1))
317 ((> k last$) nil)
318 (tagbody
319 (setf result
320 (+ result
321 (f2cl-lib:fref rlist-%data% (k) ((1 *)) rlist-%offset%)))
322 label120))
323 (setf abserr errsum)
324 label130
325 (if (> ier 2) (setf ier (f2cl-lib:int-sub ier 1)))
326 label140
327 (setf neval (f2cl-lib:int-sub (f2cl-lib:int-mul 42 last$) 21))
328 label999
329 (go end_label)
330 end_label
331 (return
332 (values nil
338 result
339 abserr
340 neval
347 last$)))))
349 (in-package #:cl-user)
350 #+#.(cl:if (cl:find-package '#:f2cl) '(and) '(or))
351 (eval-when (:load-toplevel :compile-toplevel :execute)
352 (setf (gethash 'fortran-to-lisp::dqagse
353 fortran-to-lisp::*f2cl-function-info*)
354 (fortran-to-lisp::make-f2cl-finfo
355 :arg-types '(t (double-float) (double-float) (double-float)
356 (double-float) (fortran-to-lisp::integer4)
357 (double-float) (double-float)
358 (fortran-to-lisp::integer4) (fortran-to-lisp::integer4)
359 (array double-float (*)) (array double-float (*))
360 (array double-float (*)) (array double-float (*))
361 (array fortran-to-lisp::integer4 (*))
362 (fortran-to-lisp::integer4))
363 :return-values '(nil nil nil nil nil nil fortran-to-lisp::result
364 fortran-to-lisp::abserr fortran-to-lisp::neval
365 fortran-to-lisp::ier nil nil nil nil nil
366 fortran-to-lisp::last$)
367 :calls '(fortran-to-lisp::dqelg fortran-to-lisp::dqpsrt
368 fortran-to-lisp::dqk21 fortran-to-lisp::d1mach))))