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))
21 (declare (type (double-float) zero
))
22 (defun fdjac2 (fcn m n x fvec fjac ldfjac iflag epsfcn wa
)
23 (declare (type (double-float) epsfcn
)
24 (type (array double-float
(*)) wa fjac fvec x
)
25 (type (f2cl-lib:integer4
) iflag ldfjac n m
))
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 ((eps 0.0) (epsmch 0.0) (h 0.0) (temp 0.0) (i 0) (j 0))
32 (declare (type (f2cl-lib:integer4
) j i
)
33 (type (double-float) temp h epsmch eps
))
38 '" this subroutine computes a forward-difference approximation"
39 '" to the m by n jacobian matrix associated with a specified"
40 '" problem of m functions in n variables."
42 '" the subroutine statement is"
44 '" subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa)"
48 '" fcn is the name of the user-supplied subroutine which"
49 '" calculates the functions. fcn must be declared"
50 '" in an external statement in the user calling"
51 '" program, and should be written as follows."
53 '" subroutine fcn(m,n,x,fvec,iflag)"
55 '" double precision x(n),fvec(m)"
57 '" calculate the functions at x and"
58 '" return this vector in fvec."
63 '" the value of iflag should not be changed by fcn unless"
64 '" the user wants to terminate execution of fdjac2."
65 '" in this case set iflag to a negative integer."
67 '" m is a positive integer input variable set to the number"
70 '" n is a positive integer input variable set to the number"
71 '" of variables. n must not exceed m."
73 '" x is an input array of length n."
75 '" fvec is an input array of length m which must contain the"
76 '" functions evaluated at x."
78 '" fjac is an output m by n array which contains the"
79 '" approximation to the jacobian matrix evaluated at x."
81 '" ldfjac is a positive integer input variable not less than m"
82 '" which specifies the leading dimension of the array fjac."
84 '" iflag is an integer variable which can be used to terminate"
85 '" the execution of fdjac2. see description of fcn."
87 '" epsfcn is an input variable used in determining a suitable"
88 '" step length for the forward-difference approximation. this"
89 '" approximation assumes that the relative errors in the"
90 '" functions are of the order of epsfcn. if epsfcn is less"
91 '" than the machine precision, it is assumed that the relative"
92 '" errors in the functions are of the order of the machine"
95 '" wa is a work array of length m."
97 '" subprograms called"
99 '" user-supplied ...... fcn"
101 '" minpack-supplied ... dpmpar"
103 '" fortran-supplied ... dabs,dmax1,dsqrt"
105 '" argonne national laboratory. minpack project. march 1980."
106 '" burton s. garbow, kenneth e. hillstrom, jorge j. more"
110 '" epsmch is the machine precision."
112 (setf epsmch
(dpmpar 1))
114 (setf eps
(f2cl-lib:dsqrt
(f2cl-lib:dmax1 epsfcn epsmch
)))
115 (f2cl-lib:fdo
(j 1 (f2cl-lib:int-add j
1))
118 (setf temp
(f2cl-lib:fref x-%data%
(j) ((1 n
)) x-%offset%
))
119 (setf h
(* eps
(f2cl-lib:dabs temp
)))
120 (if (= h zero
) (setf h eps
))
121 (setf (f2cl-lib:fref x-%data%
(j) ((1 n
)) x-%offset%
) (+ temp h
))
122 (multiple-value-bind (var-0 var-1 var-2 var-3 var-4
)
123 (funcall fcn m n x wa iflag
)
124 (declare (ignore var-2 var-3
))
131 (if (< iflag
0) (go label30
))
132 (setf (f2cl-lib:fref x-%data%
(j) ((1 n
)) x-%offset%
) temp
)
133 (f2cl-lib:fdo
(i 1 (f2cl-lib:int-add i
1))
136 (setf (f2cl-lib:fref fjac-%data%
141 (- (f2cl-lib:fref wa-%data%
(i) ((1 m
)) wa-%offset%
)
142 (f2cl-lib:fref fvec-%data%
152 '" last card of subroutine fdjac2."
155 (return (values nil m n nil nil nil nil iflag nil nil
))))))
157 (in-package #:cl-user
)
158 #+#.
(cl:if
(cl:find-package
'#:f2cl
) '(and) '(or))
159 (eval-when (:load-toplevel
:compile-toplevel
:execute
)
160 (setf (gethash 'fortran-to-lisp
::fdjac2
161 fortran-to-lisp
::*f2cl-function-info
*)
162 (fortran-to-lisp::make-f2cl-finfo
163 :arg-types
'(t (fortran-to-lisp::integer4
)
164 (fortran-to-lisp::integer4
) (array double-float
(*))
165 (array double-float
(*)) (array double-float
(*))
166 (fortran-to-lisp::integer4
) (fortran-to-lisp::integer4
)
167 (double-float) (array double-float
(*)))
168 :return-values
'(nil fortran-to-lisp
::m fortran-to-lisp
::n nil nil
169 nil nil fortran-to-lisp
::iflag nil nil
)
170 :calls
'(fortran-to-lisp::dpmpar
))))