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 t)
13 ;;; (:coerce-assigns :as-needed) (:array-type ':array)
14 ;;; (:array-slicing t) (:declare-common nil)
15 ;;; (:float-format double-float))
17 (in-package :common-lisp-user
)
20 (defun mcstep (stx fx dx sty fy dy stp fp dp brackt stpmin stpmax info
)
21 (declare (type (f2cl-lib:integer4
) info
)
22 (type f2cl-lib
:logical brackt
)
23 (type (double-float) stpmax stpmin dp fp stp dy fy sty dx fx stx
))
24 (prog ((gamma 0.0) (p 0.0) (q 0.0) (r 0.0) (s 0.0) (sgnd 0.0) (stpc 0.0)
25 (stpf 0.0) (stpq 0.0) (theta 0.0) (bound nil
))
26 (declare (type f2cl-lib
:logical bound
)
27 (type (double-float) theta stpq stpf stpc sgnd s r q p gamma
))
30 (or (and brackt
(or (<= stp
(min stx sty
)) (>= stp
(max stx sty
))))
31 (>= (* dx
(- stp stx
)) 0.0)
34 (setf sgnd
(* dp
(/ dx
(f2cl-lib:dabs dx
))))
38 (setf bound f2cl-lib
:%true%
)
39 (setf theta
(+ (/ (* 3 (- fx fp
)) (- stp stx
)) dx dp
))
41 (max (f2cl-lib:dabs theta
)
47 (- (expt (/ theta s
) 2) (* (/ dx s
) (/ dp s
))))))
48 (if (< stp stx
) (setf gamma
(- gamma
)))
49 (setf p
(+ (- gamma dx
) theta
))
50 (setf q
(+ (- gamma dx
) gamma dp
))
52 (setf stpc
(+ stx
(* r
(- stp stx
))))
55 (* (/ (/ dx
(+ (/ (- fx fp
) (- stp stx
)) dx
)) 2)
58 ((< (f2cl-lib:dabs
(+ stpc
(- stx
))) (f2cl-lib:dabs
(+ stpq
(- stx
))))
61 (setf stpf
(+ stpc
(/ (- stpq stpc
) 2)))))
62 (setf brackt f2cl-lib
:%true%
))
65 (setf bound f2cl-lib
:%false%
)
66 (setf theta
(+ (/ (* 3 (- fx fp
)) (- stp stx
)) dx dp
))
68 (max (f2cl-lib:dabs theta
)
74 (- (expt (/ theta s
) 2) (* (/ dx s
) (/ dp s
))))))
75 (if (> stp stx
) (setf gamma
(- gamma
)))
76 (setf p
(+ (- gamma dp
) theta
))
77 (setf q
(+ (- gamma dp
) gamma dx
))
79 (setf stpc
(+ stp
(* r
(- stx stp
))))
80 (setf stpq
(+ stp
(* (/ dp
(- dp dx
)) (- stx stp
))))
82 ((> (f2cl-lib:dabs
(+ stpc
(- stp
))) (f2cl-lib:dabs
(+ stpq
(- stp
))))
86 (setf brackt f2cl-lib
:%true%
))
87 ((< (f2cl-lib:dabs dp
) (f2cl-lib:dabs dx
))
89 (setf bound f2cl-lib
:%true%
)
90 (setf theta
(+ (/ (* 3 (- fx fp
)) (- stp stx
)) dx dp
))
92 (max (f2cl-lib:dabs theta
)
98 (max 0.0 (- (expt (/ theta s
) 2) (* (/ dx s
) (/ dp s
)))))))
99 (if (> stp stx
) (setf gamma
(- gamma
)))
100 (setf p
(+ (- gamma dp
) theta
))
101 (setf q
(+ gamma
(- dx dp
) gamma
))
104 ((and (< r
0.0) (/= gamma
0.0))
105 (setf stpc
(+ stp
(* r
(- stx stp
)))))
110 (setf stpq
(+ stp
(* (/ dp
(- dp dx
)) (- stx stp
))))
114 ((< (f2cl-lib:dabs
(+ stp
(- stpc
)))
115 (f2cl-lib:dabs
(+ stp
(- stpq
))))
121 ((> (f2cl-lib:dabs
(+ stp
(- stpc
)))
122 (f2cl-lib:dabs
(+ stp
(- stpq
))))
125 (setf stpf stpq
))))))
128 (setf bound f2cl-lib
:%false%
)
131 (setf theta
(+ (/ (* 3 (- fp fy
)) (- sty stp
)) dy dp
))
133 (max (f2cl-lib:dabs theta
)
139 (- (expt (/ theta s
) 2) (* (/ dy s
) (/ dp s
))))))
140 (if (> stp sty
) (setf gamma
(- gamma
)))
141 (setf p
(+ (- gamma dp
) theta
))
142 (setf q
(+ (- gamma dp
) gamma dy
))
144 (setf stpc
(+ stp
(* r
(- sty stp
))))
149 (setf stpf stpmin
)))))
164 (setf stpf
(min stpmax stpf
))
165 (setf stpf
(max stpmin stpf
))
171 (setf stp
(min (+ stx
(* 0.66 (- sty stx
))) stp
)))
173 (setf stp
(max (+ stx
(* 0.66 (- sty stx
))) stp
))))))
176 (return (values stx fx dx sty fy dy stp nil nil brackt nil nil info
))))
178 (in-package #:cl-user
)
179 #+#.
(cl:if
(cl:find-package
'#:f2cl
) '(and) '(or))
180 (eval-when (:load-toplevel
:compile-toplevel
:execute
)
181 (setf (gethash 'fortran-to-lisp
::mcstep
182 fortran-to-lisp
::*f2cl-function-info
*)
183 (fortran-to-lisp::make-f2cl-finfo
184 :arg-types
'((double-float) (double-float) (double-float)
185 (double-float) (double-float) (double-float)
186 (double-float) (double-float) (double-float)
187 fortran-to-lisp
::logical
(double-float) (double-float)
188 (fortran-to-lisp::integer4
))
189 :return-values
'(fortran-to-lisp::stx fortran-to-lisp
::fx
190 fortran-to-lisp
::dx fortran-to-lisp
::sty
191 fortran-to-lisp
::fy fortran-to-lisp
::dy
192 fortran-to-lisp
::stp nil nil
193 fortran-to-lisp
::brackt nil nil
194 fortran-to-lisp
::info
)