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)
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))
20 (let ((factor 100.0) (one 1.0) (zero 0.0))
21 (declare (type (double-float) factor one zero
))
22 (defun hybrj1 (fcn n x fvec fjac ldfjac tol info wa lwa
)
23 (declare (type (double-float) tol
)
24 (type (array double-float
(*)) wa fjac fvec x
)
25 (type (f2cl-lib:integer4
) lwa info ldfjac n
))
26 (f2cl-lib:with-multi-array-data
27 ((x double-float x-%data% x-%offset%
)
28 (fvec double-float fvec-%data% fvec-%offset%
)
29 (fjac double-float fjac-%data% fjac-%offset%
)
30 (wa double-float wa-%data% wa-%offset%
))
31 (prog ((xtol 0.0) (j 0) (lr 0) (maxfev 0) (mode 0) (nfev 0) (njev 0)
33 (declare (type (f2cl-lib:integer4
) nprint njev nfev mode maxfev lr j
)
34 (type (double-float) xtol
))
39 '" the purpose of hybrj1 is to find a zero of a system of"
40 '" n nonlinear functions in n variables by a modification"
41 '" of the powell hybrid method. this is done by using the"
42 '" more general nonlinear equation solver hybrj. the user"
43 '" must provide a subroutine which calculates the functions"
46 '" the subroutine statement is"
48 '" subroutine hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa)"
52 '" fcn is the name of the user-supplied subroutine which"
53 '" calculates the functions and the jacobian. fcn must"
54 '" be declared in an external statement in the user"
55 '" calling program, and should be written as follows."
57 '" subroutine fcn(n,x,fvec,fjac,ldfjac,iflag)"
58 '" integer n,ldfjac,iflag"
59 '" double precision x(n),fvec(n),fjac(ldfjac,n)"
61 '" if iflag = 1 calculate the functions at x and"
62 '" return this vector in fvec. do not alter fjac."
63 '" if iflag = 2 calculate the jacobian at x and"
64 '" return this matrix in fjac. do not alter fvec."
69 '" the value of iflag should not be changed by fcn unless"
70 '" the user wants to terminate execution of hybrj1."
71 '" in this case set iflag to a negative integer."
73 '" n is a positive integer input variable set to the number"
74 '" of functions and variables."
76 '" x is an array of length n. on input x must contain"
77 '" an initial estimate of the solution vector. on output x"
78 '" contains the final estimate of the solution vector."
80 '" fvec is an output array of length n which contains"
81 '" the functions evaluated at the output x."
83 '" fjac is an output n by n array which contains the"
84 '" orthogonal matrix q produced by the qr factorization"
85 '" of the final approximate jacobian."
87 '" ldfjac is a positive integer input variable not less than n"
88 '" which specifies the leading dimension of the array fjac."
90 '" tol is a nonnegative input variable. termination occurs"
91 '" when the algorithm estimates that the relative error"
92 '" between x and the solution is at most tol."
94 '" info is an integer output variable. if the user has"
95 '" terminated execution, info is set to the (negative)"
96 '" value of iflag. see description of fcn. otherwise,"
97 '" info is set as follows."
99 '" info = 0 improper input parameters."
101 '" info = 1 algorithm estimates that the relative error"
102 '" between x and the solution is at most tol."
104 '" info = 2 number of calls to fcn with iflag = 1 has"
105 '" reached 100*(n+1)."
107 '" info = 3 tol is too small. no further improvement in"
108 '" the approximate solution x is possible."
110 '" info = 4 iteration is not making good progress."
112 '" wa is a work array of length lwa."
114 '" lwa is a positive integer input variable not less than"
117 '" subprograms called"
119 '" user-supplied ...... fcn"
121 '" minpack-supplied ... hybrj"
123 '" argonne national laboratory. minpack project. march 1980."
124 '" burton s. garbow, kenneth e. hillstrom, jorge j. more"
129 '" check the input parameters for errors."
135 (< lwa
(the f2cl-lib
:integer4
(truncate (* n
(+ n
13)) 2))))
140 (setf maxfev
(f2cl-lib:int-mul
100 (f2cl-lib:int-add n
1)))
143 (f2cl-lib:fdo
(j 1 (f2cl-lib:int-add j
1))
146 (setf (f2cl-lib:fref wa-%data%
(j) ((1 lwa
)) wa-%offset%
) one
)
149 (setf lr
(the f2cl-lib
:integer4
(truncate (* n
(+ n
1)) 2)))
151 (var-0 var-1 var-2 var-3 var-4 var-5 var-6 var-7 var-8 var-9
152 var-10 var-11 var-12 var-13 var-14 var-15 var-16 var-17 var-18
153 var-19 var-20 var-21
)
154 (hybrj fcn n x fvec fjac ldfjac xtol maxfev
155 (f2cl-lib:array-slice wa double-float
(1) ((1 lwa
))) mode factor
156 nprint info nfev njev
157 (f2cl-lib:array-slice wa
159 ((+ (f2cl-lib:int-mul
6 n
) 1))
161 lr
(f2cl-lib:array-slice wa double-float
((+ n
1)) ((1 lwa
)))
162 (f2cl-lib:array-slice wa
164 ((+ (f2cl-lib:int-mul
2 n
) 1))
166 (f2cl-lib:array-slice wa
168 ((+ (f2cl-lib:int-mul
3 n
) 1))
170 (f2cl-lib:array-slice wa
172 ((+ (f2cl-lib:int-mul
4 n
) 1))
174 (f2cl-lib:array-slice wa
176 ((+ (f2cl-lib:int-mul
5 n
) 1))
178 (declare (ignore var-0 var-2 var-3 var-4 var-6 var-7 var-8 var-9
179 var-10 var-11 var-15 var-16 var-17 var-18 var-19
186 (if (= info
5) (setf info
4))
190 '" last card of subroutine hybrj1."
193 (return (values nil n nil nil nil ldfjac nil info nil nil
))))))
195 (in-package #:cl-user
)
196 #+#.
(cl:if
(cl:find-package
'#:f2cl
) '(and) '(or))
197 (eval-when (:load-toplevel
:compile-toplevel
:execute
)
198 (setf (gethash 'fortran-to-lisp
::hybrj1
199 fortran-to-lisp
::*f2cl-function-info
*)
200 (fortran-to-lisp::make-f2cl-finfo
201 :arg-types
'(t (fortran-to-lisp::integer4
) (array double-float
(*))
202 (array double-float
(*)) (array double-float
(*))
203 (fortran-to-lisp::integer4
) (double-float)
204 (fortran-to-lisp::integer4
) (array double-float
(*))
205 (fortran-to-lisp::integer4
))
206 :return-values
'(nil fortran-to-lisp
::n nil nil nil
207 fortran-to-lisp
::ldfjac nil fortran-to-lisp
::info
209 :calls
'(fortran-to-lisp::hybrj
))))