Fix possible lisp error when translating entier
[maxima.git] / share / hompack / lisp / rootqs.lisp
blob549d03f22b6a26d9be9e55602aba7a8bc8d28e73
1 ;;; Compiled by f2cl version:
2 ;;; ("f2cl1.l,v 95098eb54f13 2013/04/01 00:45:16 toy $"
3 ;;; "f2cl2.l,v 95098eb54f13 2013/04/01 00:45:16 toy $"
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 95098eb54f13 2013/04/01 00:45:16 toy $"
7 ;;; "f2cl6.l,v 1d5cbacbb977 2008/08/24 00:56:27 rtoy $"
8 ;;; "macros.l,v 1409c1352feb 2013/03/24 20:44:50 toy $")
10 ;;; Using Lisp CMU Common Lisp snapshot-2020-04 (21D 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 "HOMPACK")
20 (defun rootqs
21 (n nfe iflag lenqr relerr abserr y yp yold ypold a qr pivot pp rhovec z
22 dz work par ipar)
23 (declare (type (array f2cl-lib:integer4 (*)) ipar)
24 (type (array double-float (*)) par)
25 (type (array f2cl-lib:integer4 (*)) pivot)
26 (type (array double-float (*)) work dz z rhovec pp qr a ypold yold
27 yp y)
28 (type (double-float) abserr relerr)
29 (type (f2cl-lib:integer4) lenqr iflag nfe n))
30 (f2cl-lib:with-multi-array-data
31 ((y double-float y-%data% y-%offset%)
32 (yp double-float yp-%data% yp-%offset%)
33 (yold double-float yold-%data% yold-%offset%)
34 (ypold double-float ypold-%data% ypold-%offset%)
35 (a double-float a-%data% a-%offset%)
36 (qr double-float qr-%data% qr-%offset%)
37 (pp double-float pp-%data% pp-%offset%)
38 (rhovec double-float rhovec-%data% rhovec-%offset%)
39 (z double-float z-%data% z-%offset%)
40 (dz double-float dz-%data% dz-%offset%)
41 (work double-float work-%data% work-%offset%)
42 (pivot f2cl-lib:integer4 pivot-%data% pivot-%offset%)
43 (par double-float par-%data% par-%offset%)
44 (ipar f2cl-lib:integer4 ipar-%data% ipar-%offset%))
45 (labels ((dd01 (p0 p1 dels)
46 (f2cl-lib:f2cl/ (+ p1 (- p0)) dels))
47 (dd001 (p0 pp0 p1 dels)
48 (/ (- (dd01 p0 p1 dels) pp0) dels))
49 (dd011 (p0 p1 pp1 dels)
50 (/ (- pp1 (dd01 p0 p1 dels)) dels))
51 (dd0011 (p0 pp0 p1 pp1 dels)
52 (/ (- (dd011 p0 p1 pp1 dels) (dd001 p0 pp0 p1 dels)) dels))
53 (qofs (p0 pp0 p1 pp1 dels s)
58 (+ (* (dd0011 p0 pp0 p1 pp1 dels) (- s dels))
59 (dd001 p0 pp0 p1 dels))
61 pp0)
63 p0)))
64 (declare (ftype (function (double-float double-float double-float)
65 (values double-float &rest t))
66 dd01))
67 (declare (ftype (function
68 (double-float double-float double-float double-float)
69 (values double-float &rest t))
70 dd001))
71 (declare (ftype (function
72 (double-float double-float double-float double-float)
73 (values double-float &rest t))
74 dd011))
75 (declare (ftype (function
76 (double-float double-float double-float double-float
77 double-float)
78 (values double-float &rest t))
79 dd0011))
80 (declare (ftype (function
81 (double-float double-float double-float double-float
82 double-float double-float)
83 (values double-float &rest t))
84 qofs))
85 (prog ((brack nil) (istep 0) (i 0) (j 0) (lcode 0) (limit 0) (np1 0)
86 (zu 0) (aerr 0.0) (dels 0.0) (one 0.0) (p0 0.0) (p1 0.0) (pp0 0.0)
87 (pp1 0.0) (qsout 0.0) (rerr 0.0) (s 0.0) (sa 0.0) (sb 0.0)
88 (sigma 0.0) (sout 0.0) (u 0.0) (zero 0.0) (lambda$ 0.0))
89 (declare (type (double-float) lambda$ zero u sout sigma sb sa s rerr
90 qsout pp1 pp0 p1 p0 one dels aerr)
91 (type (f2cl-lib:integer4) zu np1 limit lcode j i istep)
92 (type f2cl-lib:logical brack))
93 (setf one (coerce 1.0f0 'double-float))
94 (setf zero (coerce 0.0f0 'double-float))
95 (setf u (f2cl-lib:d1mach 4))
96 (setf rerr (max relerr u))
97 (setf aerr (max abserr zero))
98 (setf np1 (f2cl-lib:int-add n 1))
99 (setf limit
100 (f2cl-lib:int-mul 2
101 (f2cl-lib:int-add
102 (f2cl-lib:int
104 (f2cl-lib:log10
105 (+ aerr (* rerr (dnrm2 np1 y 1))))))
106 1)))
107 (setf zu (f2cl-lib:int-add n 2))
108 (dcopy np1 y 1 dz 1)
109 (daxpy np1 (- one) yold 1 dz 1)
110 (setf dels (dnrm2 np1 dz 1))
111 (setf sa (coerce 0.0f0 'double-float))
112 (setf sb dels)
113 (setf lcode 1)
114 label40
115 (multiple-value-bind (var-0 var-1 var-2 var-3 var-4 var-5 var-6)
116 (root sout qsout sa sb rerr aerr lcode)
117 (declare (ignore var-1 var-4 var-5))
118 (setf sout var-0)
119 (setf sa var-2)
120 (setf sb var-3)
121 (setf lcode var-6))
122 (if (> lcode 0) (go label50))
123 (setf qsout
125 (qofs
126 (f2cl-lib:fref yold-%data%
127 (np1)
128 ((1 (f2cl-lib:int-add n 1)))
129 yold-%offset%)
130 (f2cl-lib:fref ypold-%data%
131 (np1)
132 ((1 (f2cl-lib:int-add n 1)))
133 ypold-%offset%)
134 (f2cl-lib:fref y-%data%
135 (np1)
136 ((1 (f2cl-lib:int-add n 1)))
137 y-%offset%)
138 (f2cl-lib:fref yp-%data%
139 (np1)
140 ((1 (f2cl-lib:int-add n 1)))
141 yp-%offset%)
142 dels sout)
143 1.0f0))
144 (go label40)
145 label50
146 (cond
147 ((> lcode 2)
148 (setf iflag 6)
149 (go end_label)))
150 (f2cl-lib:fdo (i 1 (f2cl-lib:int-add i 1))
151 ((> i np1) nil)
152 (tagbody
153 (setf (f2cl-lib:fref z-%data%
155 ((1 (f2cl-lib:int-add n 1)))
156 z-%offset%)
157 (qofs
158 (f2cl-lib:fref yold-%data%
160 ((1 (f2cl-lib:int-add n 1)))
161 yold-%offset%)
162 (f2cl-lib:fref ypold-%data%
164 ((1 (f2cl-lib:int-add n 1)))
165 ypold-%offset%)
166 (f2cl-lib:fref y-%data%
168 ((1 (f2cl-lib:int-add n 1)))
169 y-%offset%)
170 (f2cl-lib:fref yp-%data%
172 ((1 (f2cl-lib:int-add n 1)))
173 yp-%offset%)
174 dels sa))
175 label60))
176 (dcopy np1 yold 1 ypold 1)
177 (setf brack f2cl-lib:%true%)
178 (f2cl-lib:fdo (istep 1 (f2cl-lib:int-add istep 1))
179 ((> istep limit) nil)
180 (tagbody
181 (f2cl-lib:fdo (j zu (f2cl-lib:int-add j 1))
182 ((> j (f2cl-lib:int-add zu (f2cl-lib:int-mul 2 n) 1))
183 nil)
184 (tagbody
185 (setf (f2cl-lib:fref work-%data%
188 (f2cl-lib:int-add
189 (f2cl-lib:int-mul 6
190 (f2cl-lib:int-add n
192 lenqr)))
193 work-%offset%)
194 (coerce 0.0f0 'double-float))
195 label70))
196 (setf lambda$
197 (f2cl-lib:fref z-%data%
198 (np1)
199 ((1 (f2cl-lib:int-add n 1)))
200 z-%offset%))
201 (cond
202 ((= iflag (f2cl-lib:int-sub 2))
203 (rhojs a lambda$ z qr lenqr pivot pp par ipar)
204 (multiple-value-bind (var-0 var-1 var-2 var-3 var-4 var-5)
205 (rho a lambda$ z rhovec par ipar)
206 (declare (ignore var-0 var-2 var-3 var-4 var-5))
207 (setf lambda$ var-1)))
208 ((= iflag (f2cl-lib:int-sub 1))
209 (fjacs z qr lenqr pivot)
210 (dscal lenqr lambda$ qr 1)
211 (setf sigma (- 1.0f0 lambda$))
212 (f2cl-lib:fdo (j 1 (f2cl-lib:int-add j 1))
213 ((> j n) nil)
214 (tagbody
215 (setf (f2cl-lib:fref qr-%data%
216 ((f2cl-lib:fref pivot
219 (f2cl-lib:int-add n
220 2)))))
221 ((1 lenqr))
222 qr-%offset%)
224 (f2cl-lib:fref qr-%data%
225 ((f2cl-lib:fref pivot
228 (f2cl-lib:int-add
230 2)))))
231 ((1 lenqr))
232 qr-%offset%)
233 sigma))
234 label80))
235 (dcopy n z 1 rhovec 1)
236 (daxpy n (- one) a 1 rhovec 1)
237 (f z pp)
238 (dscal n (- one) pp 1)
239 (daxpy n one rhovec 1 pp 1)
240 (daxpy n (- lambda$) pp 1 rhovec 1))
242 (fjacs z qr lenqr pivot)
243 (dscal lenqr (- lambda$) qr 1)
244 (f2cl-lib:fdo (j 1 (f2cl-lib:int-add j 1))
245 ((> j n) nil)
246 (tagbody
247 (setf (f2cl-lib:fref qr-%data%
248 ((f2cl-lib:fref pivot
251 (f2cl-lib:int-add n
252 2)))))
253 ((1 lenqr))
254 qr-%offset%)
256 (f2cl-lib:fref qr-%data%
257 ((f2cl-lib:fref pivot
260 (f2cl-lib:int-add
262 2)))))
263 ((1 lenqr))
264 qr-%offset%)
265 1.0f0))
266 label90))
267 (dcopy n z 1 rhovec 1)
268 (daxpy n (- one) a 1 rhovec 1)
269 (f z pp)
270 (daxpy n (- one) a 1 pp 1)
271 (daxpy n (- lambda$) pp 1 rhovec 1)))
272 (setf (f2cl-lib:fref rhovec-%data%
273 (np1)
274 ((1 (f2cl-lib:int-add n 1)))
275 rhovec-%offset%)
276 (coerce 0.0f0 'double-float))
277 (setf nfe (f2cl-lib:int-add nfe 1))
278 (multiple-value-bind
279 (var-0 var-1 var-2 var-3 var-4 var-5 var-6 var-7 var-8 var-9)
280 (pcgqs n qr lenqr pivot pp yp rhovec dz work iflag)
281 (declare (ignore var-0 var-1 var-2 var-3 var-4 var-5 var-6 var-7
282 var-8))
283 (setf iflag var-9))
284 (if (> iflag 0) (go end_label))
285 (daxpy np1 one dz 1 z 1)
286 (cond
287 ((and
289 (abs
290 (+ (f2cl-lib:fref z (np1) ((1 (f2cl-lib:int-add n 1))))
291 (- 1.0f0)))
292 (+ rerr aerr))
293 (<= (dnrm2 np1 dz 1) (+ (* rerr (dnrm2 n z 1)) aerr)))
294 (go end_label)))
297 (abs
299 (f2cl-lib:fref z-%data%
300 (np1)
301 ((1 (f2cl-lib:int-add n 1)))
302 z-%offset%)
303 1.0f0))
304 (+ rerr aerr))
305 (go label300))
306 (dcopy np1 y 1 yold 1)
307 (dcopy np1 z 1 y 1)
308 (cond
311 (+ (f2cl-lib:fref yold (np1) ((1 (f2cl-lib:int-add n 1))))
312 (- 1.0f0))
313 (+ (f2cl-lib:fref y (np1) ((1 (f2cl-lib:int-add n 1))))
314 (- 1.0f0)))
316 (setf brack f2cl-lib:%false%))
318 (setf brack f2cl-lib:%true%)
319 (dcopy np1 yold 1 ypold 1)))
320 (dcopy np1 y 1 dz 1)
321 (daxpy np1 (- one) ypold 1 dz 1)
322 (setf dels (dnrm2 np1 dz 1))
323 (setf sa
325 (- 1.0f0
326 (f2cl-lib:fref y-%data%
327 (np1)
328 ((1 (f2cl-lib:int-add n 1)))
329 y-%offset%))
331 (f2cl-lib:fref yold-%data%
332 (np1)
333 ((1 (f2cl-lib:int-add n 1)))
334 yold-%offset%)
335 (f2cl-lib:fref y-%data%
336 (np1)
337 ((1 (f2cl-lib:int-add n 1)))
338 y-%offset%))))
339 (dcopy np1 yold 1 dz 1)
340 (daxpy np1 (- one) y 1 dz 1)
341 (dscal np1 sa dz 1)
342 (cond
343 ((not brack)
344 (cond
345 ((> (dnrm2 np1 dz 1) dels)
346 (setf sa
348 (- 1.0f0
349 (f2cl-lib:fref y-%data%
350 (np1)
351 ((1 (f2cl-lib:int-add n 1)))
352 y-%offset%))
354 (f2cl-lib:fref ypold-%data%
355 (np1)
356 ((1 (f2cl-lib:int-add n 1)))
357 ypold-%offset%)
358 (f2cl-lib:fref y-%data%
359 (np1)
360 ((1 (f2cl-lib:int-add n 1)))
361 y-%offset%))))
362 (dcopy np1 ypold 1 dz 1)
363 (daxpy np1 (- one) y 1 dz 1)
364 (dscal np1 sa dz 1)))))
365 (dcopy np1 y 1 z 1)
366 (daxpy np1 one dz 1 z 1)
367 label300))
368 (setf iflag 6)
369 (go end_label)
370 end_label
371 (return
372 (values nil
374 iflag
391 nil))))))
393 (in-package #:cl-user)
394 #+#.(cl:if (cl:find-package '#:f2cl) '(and) '(or))
395 (eval-when (:load-toplevel :compile-toplevel :execute)
396 (setf (gethash 'fortran-to-lisp::rootqs
397 fortran-to-lisp::*f2cl-function-info*)
398 (fortran-to-lisp::make-f2cl-finfo
399 :arg-types '((fortran-to-lisp::integer4) (fortran-to-lisp::integer4)
400 (fortran-to-lisp::integer4) (fortran-to-lisp::integer4)
401 (double-float) (double-float) (array double-float (*))
402 (array double-float (*)) (array double-float (*))
403 (array double-float (*)) (array double-float (*))
404 (array double-float (*))
405 (array fortran-to-lisp::integer4 (*))
406 (array double-float (*)) (array double-float (*))
407 (array double-float (*)) (array double-float (*))
408 (array double-float (*)) (array double-float (*))
409 (array fortran-to-lisp::integer4 (*)))
410 :return-values '(nil fortran-to-lisp::nfe fortran-to-lisp::iflag nil
411 nil nil nil nil nil nil nil nil nil nil nil nil nil
412 nil nil nil)
413 :calls '(fortran-to-lisp::f fortran-to-lisp::fjacs
414 fortran-to-lisp::rhojs fortran-to-lisp::dscal
415 fortran-to-lisp::daxpy fortran-to-lisp::dcopy
416 fortran-to-lisp::dnrm2 fortran-to-lisp::pcgqs
417 fortran-to-lisp::rho fortran-to-lisp::root
418 fortran-to-lisp::d1mach))))