share/tensor/itensor.lisp: make X and D shared lexical variables for the functions...
[maxima.git] / share / minpack / lisp / hybrj.lisp
blobdf65c8dece652ae299e977b29a0b745b2a83328c
1 ;;; Compiled by f2cl version:
2 ;;; ("f2cl1.l,v 1.215 2009/04/07 22:05:21 rtoy Exp $"
3 ;;; "f2cl2.l,v 1.37 2008/02/22 22:19:33 rtoy Exp $"
4 ;;; "f2cl3.l,v 1.6 2008/02/22 22:19:33 rtoy Exp $"
5 ;;; "f2cl4.l,v 1.7 2008/02/22 22:19:34 rtoy Exp $"
6 ;;; "f2cl5.l,v 1.200 2009/01/19 02:38:17 rtoy Exp $"
7 ;;; "f2cl6.l,v 1.48 2008/08/24 00:56:27 rtoy Exp $"
8 ;;; "macros.l,v 1.112 2009/01/08 12:57:19 rtoy Exp $")
10 ;;; Using Lisp CMU Common Lisp 19f (19F)
11 ;;;
12 ;;; Options: ((:prune-labels nil) (:auto-save t) (:relaxed-array-decls nil)
13 ;;; (:coerce-assigns :as-needed) (:array-type ':array)
14 ;;; (:array-slicing t) (:declare-common nil)
15 ;;; (:float-format double-float))
17 (in-package :minpack)
20 (let ((one 1.0) (p1 0.1) (p5 0.5) (p001 0.001) (p0001 1.0e-4) (zero 0.0))
21 (declare (type (double-float) one p1 p5 p001 p0001 zero))
22 (defun hybrj
23 (fcn n x fvec fjac ldfjac xtol maxfev diag mode factor nprint info
24 nfev njev r lr qtf wa1 wa2 wa3 wa4)
25 (declare (type (double-float) factor xtol)
26 (type (array double-float (*)) wa4 wa3 wa2 wa1 qtf r diag fjac
27 fvec x)
28 (type (f2cl-lib:integer4) lr njev nfev info nprint mode maxfev
29 ldfjac n))
30 (f2cl-lib:with-multi-array-data
31 ((x double-float x-%data% x-%offset%)
32 (fvec double-float fvec-%data% fvec-%offset%)
33 (fjac double-float fjac-%data% fjac-%offset%)
34 (diag double-float diag-%data% diag-%offset%)
35 (r double-float r-%data% r-%offset%)
36 (qtf double-float qtf-%data% qtf-%offset%)
37 (wa1 double-float wa1-%data% wa1-%offset%)
38 (wa2 double-float wa2-%data% wa2-%offset%)
39 (wa3 double-float wa3-%data% wa3-%offset%)
40 (wa4 double-float wa4-%data% wa4-%offset%))
41 (prog ((actred 0.0) (delta 0.0) (epsmch 0.0) (fnorm 0.0) (fnorm1 0.0)
42 (pnorm 0.0) (prered 0.0) (ratio 0.0) (sum 0.0) (temp 0.0)
43 (xnorm 0.0) (jeval nil) (sing nil)
44 (iwa (make-array 1 :element-type 'f2cl-lib:integer4)) (i 0)
45 (iflag 0) (iter 0) (j 0) (jm1 0) (l 0) (ncfail 0) (ncsuc 0)
46 (nslow1 0) (nslow2 0))
47 (declare (type (f2cl-lib:integer4) nslow2 nslow1 ncsuc ncfail l jm1 j
48 iter iflag i)
49 (type (array f2cl-lib:integer4 (1)) iwa)
50 (type f2cl-lib:logical sing jeval)
51 (type (double-float) xnorm temp sum ratio prered pnorm fnorm1
52 fnorm epsmch delta actred))
53 '" **********"
54 '""
55 '" subroutine hybrj"
56 '""
57 '" the purpose of hybrj is to find a zero of a system of"
58 '" n nonlinear functions in n variables by a modification"
59 '" of the powell hybrid method. the user must provide a"
60 '" subroutine which calculates the functions and the jacobian."
61 '""
62 '" the subroutine statement is"
63 '""
64 '" subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag,"
65 '" mode,factor,nprint,info,nfev,njev,r,lr,qtf,"
66 '" wa1,wa2,wa3,wa4)"
67 '""
68 '" where"
69 '""
70 '" fcn is the name of the user-supplied subroutine which"
71 '" calculates the functions and the jacobian. fcn must"
72 '" be declared in an external statement in the user"
73 '" calling program, and should be written as follows."
74 '""
75 '" subroutine fcn(n,x,fvec,fjac,ldfjac,iflag)"
76 '" integer n,ldfjac,iflag"
77 '" double precision x(n),fvec(n),fjac(ldfjac,n)"
78 '" ----------"
79 '" if iflag = 1 calculate the functions at x and"
80 '" return this vector in fvec. do not alter fjac."
81 '" if iflag = 2 calculate the jacobian at x and"
82 '" return this matrix in fjac. do not alter fvec."
83 '" ---------"
84 '" return"
85 '" end"
86 '""
87 '" the value of iflag should not be changed by fcn unless"
88 '" the user wants to terminate execution of hybrj."
89 '" in this case set iflag to a negative integer."
90 '""
91 '" n is a positive integer input variable set to the number"
92 '" of functions and variables."
93 '""
94 '" x is an array of length n. on input x must contain"
95 '" an initial estimate of the solution vector. on output x"
96 '" contains the final estimate of the solution vector."
97 '""
98 '" fvec is an output array of length n which contains"
99 '" the functions evaluated at the output x."
101 '" fjac is an output n by n array which contains the"
102 '" orthogonal matrix q produced by the qr factorization"
103 '" of the final approximate jacobian."
105 '" ldfjac is a positive integer input variable not less than n"
106 '" which specifies the leading dimension of the array fjac."
108 '" xtol is a nonnegative input variable. termination"
109 '" occurs when the relative error between two consecutive"
110 '" iterates is at most xtol."
112 '" maxfev is a positive integer input variable. termination"
113 '" occurs when the number of calls to fcn with iflag = 1"
114 '" has reached maxfev."
116 '" diag is an array of length n. if mode = 1 (see"
117 '" below), diag is internally set. if mode = 2, diag"
118 '" must contain positive entries that serve as"
119 '" multiplicative scale factors for the variables."
121 '" mode is an integer input variable. if mode = 1, the"
122 '" variables will be scaled internally. if mode = 2,"
123 '" the scaling is specified by the input diag. other"
124 '" values of mode are equivalent to mode = 1."
126 '" factor is a positive input variable used in determining the"
127 '" initial step bound. this bound is set to the product of"
128 '" factor and the euclidean norm of diag*x if nonzero, or else"
129 '" to factor itself. in most cases factor should lie in the"
130 '" interval (.1,100.). 100. is a generally recommended value."
132 '" nprint is an integer input variable that enables controlled"
133 '" printing of iterates if it is positive. in this case,"
134 '" fcn is called with iflag = 0 at the beginning of the first"
135 '" iteration and every nprint iterations thereafter and"
136 '" immediately prior to return, with x and fvec available"
137 '" for printing. fvec and fjac should not be altered."
138 '" if nprint is not positive, no special calls of fcn"
139 '" with iflag = 0 are made."
141 '" info is an integer output variable. if the user has"
142 '" terminated execution, info is set to the (negative)"
143 '" value of iflag. see description of fcn. otherwise,"
144 '" info is set as follows."
146 '" info = 0 improper input parameters."
148 '" info = 1 relative error between two consecutive iterates"
149 '" is at most xtol."
151 '" info = 2 number of calls to fcn with iflag = 1 has"
152 '" reached maxfev."
154 '" info = 3 xtol is too small. no further improvement in"
155 '" the approximate solution x is possible."
157 '" info = 4 iteration is not making good progress, as"
158 '" measured by the improvement from the last"
159 '" five jacobian evaluations."
161 '" info = 5 iteration is not making good progress, as"
162 '" measured by the improvement from the last"
163 '" ten iterations."
165 '" nfev is an integer output variable set to the number of"
166 '" calls to fcn with iflag = 1."
168 '" njev is an integer output variable set to the number of"
169 '" calls to fcn with iflag = 2."
171 '" r is an output array of length lr which contains the"
172 '" upper triangular matrix produced by the qr factorization"
173 '" of the final approximate jacobian, stored rowwise."
175 '" lr is a positive integer input variable not less than"
176 '" (n*(n+1))/2."
178 '" qtf is an output array of length n which contains"
179 '" the vector (q transpose)*fvec."
181 '" wa1, wa2, wa3, and wa4 are work arrays of length n."
183 '" subprograms called"
185 '" user-supplied ...... fcn"
187 '" minpack-supplied ... dogleg,dpmpar,enorm,"
188 '" qform,qrfac,r1mpyq,r1updt"
190 '" fortran-supplied ... dabs,dmax1,dmin1,mod"
192 '" argonne national laboratory. minpack project. march 1980."
193 '" burton s. garbow, kenneth e. hillstrom, jorge j. more"
195 '" **********"
197 '" epsmch is the machine precision."
199 (setf epsmch (dpmpar 1))
201 (setf info 0)
202 (setf iflag 0)
203 (setf nfev 0)
204 (setf njev 0)
206 '" check the input parameters for errors."
209 (or (<= n 0)
210 (< ldfjac n)
211 (< xtol zero)
212 (<= maxfev 0)
213 (<= factor zero)
214 (< lr (the f2cl-lib:integer4 (truncate (* n (+ n 1)) 2))))
215 (go label300))
216 (if (/= mode 2) (go label20))
217 (f2cl-lib:fdo (j 1 (f2cl-lib:int-add j 1))
218 ((> j n) nil)
219 (tagbody
220 (if (<= (f2cl-lib:fref diag-%data% (j) ((1 n)) diag-%offset%) zero)
221 (go label300))
222 label10))
223 label20
225 '" evaluate the function at the starting point"
226 '" and calculate its norm."
228 (setf iflag 1)
229 (multiple-value-bind (var-0 var-1 var-2 var-3 var-4 var-5)
230 (funcall fcn n x fvec fjac ldfjac iflag)
231 (declare (ignore var-1 var-2 var-3))
232 (when var-0
233 (setf n var-0))
234 (when var-4
235 (setf ldfjac var-4))
236 (when var-5
237 (setf iflag var-5)))
238 (setf nfev 1)
239 (if (< iflag 0) (go label300))
240 (setf fnorm (enorm n fvec))
242 '" initialize iteration counter and monitors."
244 (setf iter 1)
245 (setf ncsuc 0)
246 (setf ncfail 0)
247 (setf nslow1 0)
248 (setf nslow2 0)
250 '" beginning of the outer loop."
252 label30
253 (setf jeval f2cl-lib:%true%)
255 '" calculate the jacobian matrix."
257 (setf iflag 2)
258 (multiple-value-bind (var-0 var-1 var-2 var-3 var-4 var-5)
259 (funcall fcn n x fvec fjac ldfjac iflag)
260 (declare (ignore var-1 var-2 var-3))
261 (when var-0
262 (setf n var-0))
263 (when var-4
264 (setf ldfjac var-4))
265 (when var-5
266 (setf iflag var-5)))
267 (setf njev (f2cl-lib:int-add njev 1))
268 (if (< iflag 0) (go label300))
270 '" compute the qr factorization of the jacobian."
272 (qrfac n n fjac ldfjac f2cl-lib:%false% iwa 1 wa1 wa2 wa3)
274 '" on the first iteration and if mode is 1, scale according"
275 '" to the norms of the columns of the initial jacobian."
277 (if (/= iter 1) (go label70))
278 (if (= mode 2) (go label50))
279 (f2cl-lib:fdo (j 1 (f2cl-lib:int-add j 1))
280 ((> j n) nil)
281 (tagbody
282 (setf (f2cl-lib:fref diag-%data% (j) ((1 n)) diag-%offset%)
283 (f2cl-lib:fref wa2-%data% (j) ((1 n)) wa2-%offset%))
284 (if (= (f2cl-lib:fref wa2-%data% (j) ((1 n)) wa2-%offset%) zero)
285 (setf (f2cl-lib:fref diag-%data% (j) ((1 n)) diag-%offset%)
286 one))
287 label40))
288 label50
290 '" on the first iteration, calculate the norm of the scaled x"
291 '" and initialize the step bound delta."
293 (f2cl-lib:fdo (j 1 (f2cl-lib:int-add j 1))
294 ((> j n) nil)
295 (tagbody
296 (setf (f2cl-lib:fref wa3-%data% (j) ((1 n)) wa3-%offset%)
297 (* (f2cl-lib:fref diag-%data% (j) ((1 n)) diag-%offset%)
298 (f2cl-lib:fref x-%data% (j) ((1 n)) x-%offset%)))
299 label60))
300 (setf xnorm (enorm n wa3))
301 (setf delta (* factor xnorm))
302 (if (= delta zero) (setf delta factor))
303 label70
305 '" form (q transpose)*fvec and store in qtf."
307 (f2cl-lib:fdo (i 1 (f2cl-lib:int-add i 1))
308 ((> i n) nil)
309 (tagbody
310 (setf (f2cl-lib:fref qtf-%data% (i) ((1 n)) qtf-%offset%)
311 (f2cl-lib:fref fvec-%data% (i) ((1 n)) fvec-%offset%))
312 label80))
313 (f2cl-lib:fdo (j 1 (f2cl-lib:int-add j 1))
314 ((> j n) nil)
315 (tagbody
318 (f2cl-lib:fref fjac-%data%
319 (j j)
320 ((1 ldfjac) (1 n))
321 fjac-%offset%)
322 zero)
323 (go label110))
324 (setf sum zero)
325 (f2cl-lib:fdo (i j (f2cl-lib:int-add i 1))
326 ((> i n) nil)
327 (tagbody
328 (setf sum
329 (+ sum
331 (f2cl-lib:fref fjac-%data%
332 (i j)
333 ((1 ldfjac) (1 n))
334 fjac-%offset%)
335 (f2cl-lib:fref qtf-%data%
337 ((1 n))
338 qtf-%offset%))))
339 label90))
340 (setf temp
341 (/ (- sum)
342 (f2cl-lib:fref fjac-%data%
343 (j j)
344 ((1 ldfjac) (1 n))
345 fjac-%offset%)))
346 (f2cl-lib:fdo (i j (f2cl-lib:int-add i 1))
347 ((> i n) nil)
348 (tagbody
349 (setf (f2cl-lib:fref qtf-%data% (i) ((1 n)) qtf-%offset%)
350 (+ (f2cl-lib:fref qtf-%data% (i) ((1 n)) qtf-%offset%)
352 (f2cl-lib:fref fjac-%data%
353 (i j)
354 ((1 ldfjac) (1 n))
355 fjac-%offset%)
356 temp)))
357 label100))
358 label110
359 label120))
361 '" copy the triangular factor of the qr factorization into r."
363 (setf sing f2cl-lib:%false%)
364 (f2cl-lib:fdo (j 1 (f2cl-lib:int-add j 1))
365 ((> j n) nil)
366 (tagbody
367 (setf l j)
368 (setf jm1 (f2cl-lib:int-sub j 1))
369 (if (< jm1 1) (go label140))
370 (f2cl-lib:fdo (i 1 (f2cl-lib:int-add i 1))
371 ((> i jm1) nil)
372 (tagbody
373 (setf (f2cl-lib:fref r-%data% (l) ((1 lr)) r-%offset%)
374 (f2cl-lib:fref fjac-%data%
375 (i j)
376 ((1 ldfjac) (1 n))
377 fjac-%offset%))
378 (setf l (f2cl-lib:int-sub (f2cl-lib:int-add l n) i))
379 label130))
380 label140
381 (setf (f2cl-lib:fref r-%data% (l) ((1 lr)) r-%offset%)
382 (f2cl-lib:fref wa1-%data% (j) ((1 n)) wa1-%offset%))
383 (if (= (f2cl-lib:fref wa1-%data% (j) ((1 n)) wa1-%offset%) zero)
384 (setf sing f2cl-lib:%true%))
385 label150))
387 '" accumulate the orthogonal factor in fjac."
389 (qform n n fjac ldfjac wa1)
391 '" rescale if necessary."
393 (if (= mode 2) (go label170))
394 (f2cl-lib:fdo (j 1 (f2cl-lib:int-add j 1))
395 ((> j n) nil)
396 (tagbody
397 (setf (f2cl-lib:fref diag-%data% (j) ((1 n)) diag-%offset%)
398 (f2cl-lib:dmax1
399 (f2cl-lib:fref diag-%data% (j) ((1 n)) diag-%offset%)
400 (f2cl-lib:fref wa2-%data% (j) ((1 n)) wa2-%offset%)))
401 label160))
402 label170
404 '" beginning of the inner loop."
406 label180
408 '" if requested, call fcn to enable printing of iterates."
410 (if (<= nprint 0) (go label190))
411 (setf iflag 0)
412 (if (= (mod (f2cl-lib:int-sub iter 1) nprint) 0)
413 (multiple-value-bind (var-0 var-1 var-2 var-3 var-4 var-5)
414 (funcall fcn n x fvec fjac ldfjac iflag)
415 (declare (ignore var-1 var-2 var-3))
416 (when var-0
417 (setf n var-0))
418 (when var-4
419 (setf ldfjac var-4))
420 (when var-5
421 (setf iflag var-5))))
422 (if (< iflag 0) (go label300))
423 label190
425 '" determine the direction p."
427 (dogleg n r lr diag qtf delta wa1 wa2 wa3)
429 '" store the direction p and x + p. calculate the norm of p."
431 (f2cl-lib:fdo (j 1 (f2cl-lib:int-add j 1))
432 ((> j n) nil)
433 (tagbody
434 (setf (f2cl-lib:fref wa1-%data% (j) ((1 n)) wa1-%offset%)
435 (- (f2cl-lib:fref wa1-%data% (j) ((1 n)) wa1-%offset%)))
436 (setf (f2cl-lib:fref wa2-%data% (j) ((1 n)) wa2-%offset%)
437 (+ (f2cl-lib:fref x-%data% (j) ((1 n)) x-%offset%)
438 (f2cl-lib:fref wa1-%data% (j) ((1 n)) wa1-%offset%)))
439 (setf (f2cl-lib:fref wa3-%data% (j) ((1 n)) wa3-%offset%)
440 (* (f2cl-lib:fref diag-%data% (j) ((1 n)) diag-%offset%)
441 (f2cl-lib:fref wa1-%data% (j) ((1 n)) wa1-%offset%)))
442 label200))
443 (setf pnorm (enorm n wa3))
445 '" on the first iteration, adjust the initial step bound."
447 (if (= iter 1) (setf delta (f2cl-lib:dmin1 delta pnorm)))
449 '" evaluate the function at x + p and calculate its norm."
451 (setf iflag 1)
452 (multiple-value-bind (var-0 var-1 var-2 var-3 var-4 var-5)
453 (funcall fcn n wa2 wa4 fjac ldfjac iflag)
454 (declare (ignore var-1 var-2 var-3))
455 (when var-0
456 (setf n var-0))
457 (when var-4
458 (setf ldfjac var-4))
459 (when var-5
460 (setf iflag var-5)))
461 (setf nfev (f2cl-lib:int-add nfev 1))
462 (if (< iflag 0) (go label300))
463 (setf fnorm1 (enorm n wa4))
465 '" compute the scaled actual reduction."
467 (setf actred (- one))
468 (if (< fnorm1 fnorm) (setf actred (- one (expt (/ fnorm1 fnorm) 2))))
470 '" compute the scaled predicted reduction."
472 (setf l 1)
473 (f2cl-lib:fdo (i 1 (f2cl-lib:int-add i 1))
474 ((> i n) nil)
475 (tagbody
476 (setf sum zero)
477 (f2cl-lib:fdo (j i (f2cl-lib:int-add j 1))
478 ((> j n) nil)
479 (tagbody
480 (setf sum
481 (+ sum
482 (* (f2cl-lib:fref r-%data% (l) ((1 lr)) r-%offset%)
483 (f2cl-lib:fref wa1-%data%
485 ((1 n))
486 wa1-%offset%))))
487 (setf l (f2cl-lib:int-add l 1))
488 label210))
489 (setf (f2cl-lib:fref wa3-%data% (i) ((1 n)) wa3-%offset%)
490 (+ (f2cl-lib:fref qtf-%data% (i) ((1 n)) qtf-%offset%)
491 sum))
492 label220))
493 (setf temp (enorm n wa3))
494 (setf prered zero)
495 (if (< temp fnorm) (setf prered (- one (expt (/ temp fnorm) 2))))
497 '" compute the ratio of the actual to the predicted"
498 '" reduction."
500 (setf ratio zero)
501 (if (> prered zero) (setf ratio (/ actred prered)))
503 '" update the step bound."
505 (if (>= ratio p1) (go label230))
506 (setf ncsuc 0)
507 (setf ncfail (f2cl-lib:int-add ncfail 1))
508 (setf delta (* p5 delta))
509 (go label240)
510 label230
511 (setf ncfail 0)
512 (setf ncsuc (f2cl-lib:int-add ncsuc 1))
513 (if (or (>= ratio p5) (> ncsuc 1))
514 (setf delta (f2cl-lib:dmax1 delta (/ pnorm p5))))
515 (if (<= (f2cl-lib:dabs (- ratio one)) p1) (setf delta (/ pnorm p5)))
516 label240
518 '" test for successful iteration."
520 (if (< ratio p0001) (go label260))
522 '" successful iteration. update x, fvec, and their norms."
524 (f2cl-lib:fdo (j 1 (f2cl-lib:int-add j 1))
525 ((> j n) nil)
526 (tagbody
527 (setf (f2cl-lib:fref x-%data% (j) ((1 n)) x-%offset%)
528 (f2cl-lib:fref wa2-%data% (j) ((1 n)) wa2-%offset%))
529 (setf (f2cl-lib:fref wa2-%data% (j) ((1 n)) wa2-%offset%)
530 (* (f2cl-lib:fref diag-%data% (j) ((1 n)) diag-%offset%)
531 (f2cl-lib:fref x-%data% (j) ((1 n)) x-%offset%)))
532 (setf (f2cl-lib:fref fvec-%data% (j) ((1 n)) fvec-%offset%)
533 (f2cl-lib:fref wa4-%data% (j) ((1 n)) wa4-%offset%))
534 label250))
535 (setf xnorm (enorm n wa2))
536 (setf fnorm fnorm1)
537 (setf iter (f2cl-lib:int-add iter 1))
538 label260
540 '" determine the progress of the iteration."
542 (setf nslow1 (f2cl-lib:int-add nslow1 1))
543 (if (>= actred p001) (setf nslow1 0))
544 (if jeval (setf nslow2 (f2cl-lib:int-add nslow2 1)))
545 (if (>= actred p1) (setf nslow2 0))
547 '" test for convergence."
549 (if (or (<= delta (* xtol xnorm)) (= fnorm zero)) (setf info 1))
550 (if (/= info 0) (go label300))
552 '" tests for termination and stringent tolerances."
554 (if (>= nfev maxfev) (setf info 2))
555 (if (<= (* p1 (f2cl-lib:dmax1 (* p1 delta) pnorm)) (* epsmch xnorm))
556 (setf info 3))
557 (if (= nslow2 5) (setf info 4))
558 (if (= nslow1 10) (setf info 5))
559 (if (/= info 0) (go label300))
561 '" criterion for recalculating jacobian."
563 (if (= ncfail 2) (go label290))
565 '" calculate the rank one modification to the jacobian"
566 '" and update qtf if necessary."
568 (f2cl-lib:fdo (j 1 (f2cl-lib:int-add j 1))
569 ((> j n) nil)
570 (tagbody
571 (setf sum zero)
572 (f2cl-lib:fdo (i 1 (f2cl-lib:int-add i 1))
573 ((> i n) nil)
574 (tagbody
575 (setf sum
576 (+ sum
578 (f2cl-lib:fref fjac-%data%
579 (i j)
580 ((1 ldfjac) (1 n))
581 fjac-%offset%)
582 (f2cl-lib:fref wa4-%data%
584 ((1 n))
585 wa4-%offset%))))
586 label270))
587 (setf (f2cl-lib:fref wa2-%data% (j) ((1 n)) wa2-%offset%)
589 (- sum
590 (f2cl-lib:fref wa3-%data% (j) ((1 n)) wa3-%offset%))
591 pnorm))
592 (setf (f2cl-lib:fref wa1-%data% (j) ((1 n)) wa1-%offset%)
593 (* (f2cl-lib:fref diag-%data% (j) ((1 n)) diag-%offset%)
596 (f2cl-lib:fref diag-%data% (j) ((1 n)) diag-%offset%)
597 (f2cl-lib:fref wa1-%data% (j) ((1 n)) wa1-%offset%))
598 pnorm)))
599 (if (>= ratio p0001)
600 (setf (f2cl-lib:fref qtf-%data% (j) ((1 n)) qtf-%offset%) sum))
601 label280))
603 '" compute the qr factorization of the updated jacobian."
605 (multiple-value-bind (var-0 var-1 var-2 var-3 var-4 var-5 var-6 var-7)
606 (r1updt n n r lr wa1 wa2 wa3 sing)
607 (declare (ignore var-0 var-1 var-2 var-3 var-4 var-5 var-6))
608 (setf sing var-7))
609 (r1mpyq n n fjac ldfjac wa2 wa3)
610 (r1mpyq 1 n qtf 1 wa2 wa3)
612 '" end of the inner loop."
614 (setf jeval f2cl-lib:%false%)
615 (go label180)
616 label290
618 '" end of the outer loop."
620 (go label30)
621 label300
623 '" termination, either normal or user imposed."
625 (if (< iflag 0) (setf info iflag))
626 (setf iflag 0)
627 (if (> nprint 0)
628 (multiple-value-bind (var-0 var-1 var-2 var-3 var-4 var-5)
629 (funcall fcn n x fvec fjac ldfjac iflag)
630 (declare (ignore var-1 var-2 var-3))
631 (when var-0
632 (setf n var-0))
633 (when var-4
634 (setf ldfjac var-4))
635 (when var-5
636 (setf iflag var-5))))
637 (go end_label)
639 '" last card of subroutine hybrj."
641 end_label
642 (return
643 (values nil
648 ldfjac
655 info
656 nfev
657 njev
664 nil))))))
666 (in-package #:cl-user)
667 #+#.(cl:if (cl:find-package '#:f2cl) '(and) '(or))
668 (eval-when (:load-toplevel :compile-toplevel :execute)
669 (setf (gethash 'fortran-to-lisp::hybrj fortran-to-lisp::*f2cl-function-info*)
670 (fortran-to-lisp::make-f2cl-finfo
671 :arg-types '(t (fortran-to-lisp::integer4) (array double-float (*))
672 (array double-float (*)) (array double-float (*))
673 (fortran-to-lisp::integer4) (double-float)
674 (fortran-to-lisp::integer4) (array double-float (*))
675 (fortran-to-lisp::integer4) (double-float)
676 (fortran-to-lisp::integer4) (fortran-to-lisp::integer4)
677 (fortran-to-lisp::integer4) (fortran-to-lisp::integer4)
678 (array double-float (*)) (fortran-to-lisp::integer4)
679 (array double-float (*)) (array double-float (*))
680 (array double-float (*)) (array double-float (*))
681 (array double-float (*)))
682 :return-values '(nil fortran-to-lisp::n nil nil nil
683 fortran-to-lisp::ldfjac nil nil nil nil nil nil
684 fortran-to-lisp::info fortran-to-lisp::nfev
685 fortran-to-lisp::njev nil nil nil nil nil nil nil)
686 :calls '(fortran-to-lisp::r1mpyq fortran-to-lisp::r1updt
687 fortran-to-lisp::dogleg fortran-to-lisp::qform
688 fortran-to-lisp::qrfac fortran-to-lisp::enorm
689 fortran-to-lisp::dpmpar))))