Use 1//2 instead of ((rat simp) 1 2)
[maxima.git] / src / numerical / slatec / zbesi.lisp
blobe010d21971964a5274e2d768aa3f2910c2b11a40
1 ;;; Compiled by f2cl version:
2 ;;; ("f2cl1.l,v 46c1f6a93b0d 2012/05/03 04:40:28 toy $"
3 ;;; "f2cl2.l,v 96616d88fb7e 2008/02/22 22:19:34 rtoy $"
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 46c1f6a93b0d 2012/05/03 04:40:28 toy $"
7 ;;; "f2cl6.l,v 1d5cbacbb977 2008/08/24 00:56:27 rtoy $"
8 ;;; "macros.l,v fceac530ef0c 2011/11/26 04:02:26 toy $")
10 ;;; Using Lisp CMU Common Lisp snapshot-2012-04 (20C Unicode)
11 ;;;
12 ;;; Options: ((:prune-labels nil) (:auto-save t) (:relaxed-array-decls t)
13 ;;; (:coerce-assigns :as-needed) (:array-type ':simple-array)
14 ;;; (:array-slicing nil) (:declare-common nil)
15 ;;; (:float-format double-float))
17 (in-package :slatec)
20 (let ((pi$ 3.141592653589793) (coner 1.0) (conei 0.0))
21 (declare (type (double-float) pi$ coner conei))
22 (defun zbesi (zr zi fnu kode n cyr cyi nz ierr)
23 (declare (type (simple-array double-float (*)) cyi cyr)
24 (type (f2cl-lib:integer4) ierr nz n kode)
25 (type (double-float) fnu zi zr))
26 (prog ((i 0) (inu 0) (k 0) (k1 0) (k2 0) (nn 0) (aa 0.0) (alim 0.0)
27 (arg 0.0) (csgni 0.0) (csgnr 0.0) (dig 0.0) (elim 0.0) (fnul 0.0)
28 (rl 0.0) (r1m5 0.0) (str 0.0) (tol 0.0) (zni 0.0) (znr 0.0) (az 0.0)
29 (bb 0.0) (fn 0.0) (ascle 0.0) (rtol 0.0) (atol 0.0) (sti 0.0))
30 (declare (type (double-float) sti atol rtol ascle fn bb az znr zni tol
31 str r1m5 rl fnul elim dig csgnr csgni arg
32 alim aa)
33 (type (f2cl-lib:integer4) nn k2 k1 k inu i))
34 (setf ierr 0)
35 (setf nz 0)
36 (if (< fnu 0.0) (setf ierr 1))
37 (if (or (< kode 1) (> kode 2)) (setf ierr 1))
38 (if (< n 1) (setf ierr 1))
39 (if (/= ierr 0) (go end_label))
40 (setf tol (max (f2cl-lib:d1mach 4) 1.0e-18))
41 (setf k1 (f2cl-lib:i1mach 15))
42 (setf k2 (f2cl-lib:i1mach 16))
43 (setf r1m5 (f2cl-lib:d1mach 5))
44 (setf k
45 (min (the f2cl-lib:integer4 (abs k1))
46 (the f2cl-lib:integer4 (abs k2))))
47 (setf elim (* 2.303 (- (* k r1m5) 3.0)))
48 (setf k1 (f2cl-lib:int-sub (f2cl-lib:i1mach 14) 1))
49 (setf aa (* r1m5 k1))
50 (setf dig (min aa 18.0))
51 (setf aa (* aa 2.303))
52 (setf alim (+ elim (max (- aa) -41.45)))
53 (setf rl (+ (* 1.2 dig) 3.0))
54 (setf fnul (+ 10.0 (* 6.0 (- dig 3.0))))
55 (setf az (coerce (realpart (zabs zr zi)) 'double-float))
56 (setf fn (+ fnu (f2cl-lib:int-sub n 1)))
57 (setf aa (/ 0.5 tol))
58 (setf bb (* (f2cl-lib:i1mach 9) 0.5))
59 (setf aa (min aa bb))
60 (if (> az aa) (go label260))
61 (if (> fn aa) (go label260))
62 (setf aa (f2cl-lib:fsqrt aa))
63 (if (> az aa) (setf ierr 3))
64 (if (> fn aa) (setf ierr 3))
65 (setf znr zr)
66 (setf zni zi)
67 (setf csgnr coner)
68 (setf csgni conei)
69 (if (>= zr 0.0) (go label40))
70 (setf znr (- zr))
71 (setf zni (- zi))
72 (setf inu (f2cl-lib:int fnu))
73 (setf arg (* (- fnu inu) pi$))
74 (if (< zi 0.0) (setf arg (- arg)))
75 (setf csgnr (cos arg))
76 (setf csgni (sin arg))
77 (if (= (mod inu 2) 0) (go label40))
78 (setf csgnr (- csgnr))
79 (setf csgni (- csgni))
80 label40
81 (multiple-value-bind
82 (var-0 var-1 var-2 var-3 var-4 var-5 var-6 var-7 var-8 var-9 var-10
83 var-11 var-12)
84 (zbinu znr zni fnu kode n cyr cyi nz rl fnul tol elim alim)
85 (declare (ignore var-0 var-1 var-2 var-3 var-4 var-5 var-6 var-8 var-9
86 var-10 var-11 var-12))
87 (setf nz var-7))
88 (if (< nz 0) (go label120))
89 (if (>= zr 0.0) (go end_label))
90 (setf nn (f2cl-lib:int-sub n nz))
91 (if (= nn 0) (go end_label))
92 (setf rtol (/ 1.0 tol))
93 (setf ascle (* (f2cl-lib:d1mach 1) rtol 1000.0))
94 (f2cl-lib:fdo (i 1 (f2cl-lib:int-add i 1))
95 ((> i nn) nil)
96 (tagbody
97 (setf aa (f2cl-lib:fref cyr (i) ((1 n))))
98 (setf bb (f2cl-lib:fref cyi (i) ((1 n))))
99 (setf atol 1.0)
100 (if (> (max (abs aa) (abs bb)) ascle) (go label55))
101 (setf aa (* aa rtol))
102 (setf bb (* bb rtol))
103 (setf atol tol)
104 label55
105 (setf str (- (* aa csgnr) (* bb csgni)))
106 (setf sti (+ (* aa csgni) (* bb csgnr)))
107 (setf (f2cl-lib:fref cyr (i) ((1 n))) (* str atol))
108 (setf (f2cl-lib:fref cyi (i) ((1 n))) (* sti atol))
109 (setf csgnr (- csgnr))
110 (setf csgni (- csgni))
111 label50))
112 (go end_label)
113 label120
114 (if (= nz -2) (go label130))
115 (setf nz 0)
116 (setf ierr 2)
117 (go end_label)
118 label130
119 (setf nz 0)
120 (setf ierr 5)
121 (go end_label)
122 label260
123 (setf nz 0)
124 (setf ierr 4)
125 (go end_label)
126 end_label
127 (return (values nil nil nil nil nil nil nil nz ierr)))))
129 (in-package #:cl-user)
130 #+#.(cl:if (cl:find-package '#:f2cl) '(and) '(or))
131 (eval-when (:load-toplevel :compile-toplevel :execute)
132 (setf (gethash 'fortran-to-lisp::zbesi fortran-to-lisp::*f2cl-function-info*)
133 (fortran-to-lisp::make-f2cl-finfo
134 :arg-types '((double-float) (double-float) (double-float)
135 (fortran-to-lisp::integer4) (fortran-to-lisp::integer4)
136 (simple-array double-float (*))
137 (simple-array double-float (*))
138 (fortran-to-lisp::integer4)
139 (fortran-to-lisp::integer4))
140 :return-values '(nil nil nil nil nil nil nil fortran-to-lisp::nz
141 fortran-to-lisp::ierr)
142 :calls '(fortran-to-lisp::zbinu fortran-to-lisp::zabs
143 fortran-to-lisp::i1mach fortran-to-lisp::d1mach))))