Newer
Older
;;;; Copyright (c) 2007, 2011 Raymond Toy
;;;;
;;;; Permission is hereby granted, free of charge, to any person
;;;; obtaining a copy of this software and associated documentation
;;;; files (the "Software"), to deal in the Software without
;;;; restriction, including without limitation the rights to use,
;;;; copy, modify, merge, publish, distribute, sublicense, and/or sell
;;;; copies of the Software, and to permit persons to whom the
;;;; Software is furnished to do so, subject to the following
;;;; conditions:
;;;;
;;;; The above copyright notice and this permission notice shall be
;;;; included in all copies or substantial portions of the Software.
;;;;
;;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
;;;; OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
;;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
;;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
;;;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
;;;; OTHER DEALINGS IN THE SOFTWARE.
;; If you want all core functions to be inline (like the C++ code
;; does), add :qd-inline to *features* by enabling the following line.
;; This makes compilation much, much slower, but the resulting code
;; conses much less and is significantly faster.
#+(not (and cmu x86))
(eval-when (:load-toplevel :compile-toplevel :execute)
(pushnew :qd-inline *features*))
;; To be able to inline all the functions, we need to make
;; *inline-expansion-limit* much larger.
;;
;; Not sure we really want to inline everything, but the QD C++ code
;; inlines all of the functions so we do the same. This makes CMUCL
;; take a very long time to compile the code, and the resulting
;; functions are huge. (I think div-qd is 8 KB, and sqrt-qd is a
;; whopping 30 KB!)
;;
#+(and cmu qd-inline)
(eval-when (:load-toplevel :compile-toplevel :execute)
(setf ext:*inline-expansion-limit* 1600))
;;
;; For all Lisps other than CMUCL, oct uses arrays to store the
;; quad-double values. This is denoted by the feature :oct-array.
;; For CMUCL, quad-doubles can be stored in a (complex
;; double-double-float) object, which is an extension in CMUCL.
;; If you want CMUCL to use an array too, add :oct-array to *features*.
#-cmu
(pushnew :oct-array *features*)
(defpackage #:oct-internal
(:nicknames #:octi)
(:export #:%quad-double
#:read-qd
#:add-qd
#:add-qd-d
#:add-d-qd
#:sub-qd
#:sub-qd-d
#:sub-d-qd
#:neg-qd
#:mul-qd
#:mul-qd-d
#:sqr-qd
#:div-qd
#:div-qd-d
#:make-qd-d
#:integer-decode-qd
#:npow
#:qd-0
#:qd-1
#:qd-2
#:qd-3
#:+qd-one+
#:+qd-zero+
#:+qd-pi+
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#:abs-qd
#:sqrt-qd
#:log-qd
#:log1p-qd
#:exp-qd
#:sin-qd
#:cos-qd
#:tan-qd
#:sincos-qd
#:asin-qd
#:acos-qd
#:atan-qd
#:atan2-qd
#:sinh-qd
#:cosh-qd
#:tanh-qd
#:asinh-qd
#:acosh-qd
#:atanh-qd
#:qd-=
#:qd->
#:qd-<
#:qd->=
#:qd-<=
#:zerop-qd
#:plusp-qd
#:minusp-qd
#:integer-decode-qd
#:decode-float-qd
#:scale-float-qd
#:ffloor-qd
#:with-qd-parts
(:export #:add-qd-dd
#:sub-qd-dd
#:div-qd-dd
#:make-qd-dd)
#+cmu
(:import-from #:c
#:two-prod
#:two-sqr)
#+cmu
(:import-from #:ext
#:float-infinity-p
#:float-nan-p
#:float-trapping-nan-p
#:double-double-float))
(defpackage #:net.common-lisp.oct
(:use #:cl #:oct-internal)
(:nicknames #:oct)
(:shadow #:+
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#:-
#:*
#:/
#:1+
#:1-
#:zerop
#:plusp
#:minusp
#:abs
#:sqrt
#:log
#:exp
#:sin
#:cos
#:tan
#:asin
#:acos
#:atan
#:sinh
#:cosh
#:tanh
#:asinh
#:acosh
#:atanh
#:expt
#:=
#:/=
#:<
#:>
#:<=
#:>=
#:complex
#:integer-decode-float
#:decode-float
#:scale-float
#:float
#:floor
#:ffloor
#:ceiling
#:fceiling
#:truncate
#:ftruncate
#:round
#:fround
#:realpart
#:imagpart
#:conjugate
#:float-sign
#:qd-format-exp
#:max
#:min
#:cis
#:phase
#:signum
#:realp
#:complexp
#:numberp
#:incf
#:decf
#:rationalize
#+cmu
(:shadow ext:float-nan-p)
;; Export functions that have CL equivalents
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#:-
#:*
#:/
#:1+
#:1-
#:zerop
#:plusp
#:minusp
#:abs
#:sqrt
#:log
#:exp
#:sin
#:cos
#:tan
#:asin
#:acos
#:atan
#:sinh
#:cosh
#:tanh
#:asinh
#:acosh
#:atanh
#:expt
#:=
#:/=
#:<
#:>
#:<=
#:>=
#:complex
#:integer-decode-float
#:decode-float
#:scale-float
#:float
#:floor
#:ffloor
#:ceiling
#:fceiling
#:truncate
#:ftruncate
#:round
#:fround
#:realpart
#:imagpart
#:conjugate
#:float-sign
#:qd-format-exp
#:max
#:min
#:cis
#:phase
#:signum
#:rationalize)
;; Export Oct-specific functions
(:export #:make-qd
#:jacobi-sn
#:jacobi-cn
#:jacobi-dn
#:elliptic-k
#:elliptic-f
#:elliptic-e
#:elliptic-ec
#:carlson-rd
#:carlson-rf
#:carlson-rj
#:elliptic-theta-1
#:elliptic-theta-2
#:elliptic-theta-3
#:elliptic-theta-4
#:elliptic-theta)
(:export #:+pi+
#:+pi/2+
#:+pi/4+
#:+2pi+
#:+log2+)