Commit 38deab92 authored by Raymond Toy's avatar Raymond Toy
Browse files

Address #14: Refactor code

- Create octi.asd to handle processing of the `oct-internal` functions.
  - Includes adding `octi-package.lisp`.
- Rename `qd-package.lisp` to `oct-package.lisp` which better reflects
  what the file contains.
- Update asd files for these changes.
parent e4179388
......@@ -36,30 +36,15 @@
:author "Raymond Toy"
:maintainer "See <http://www.common-lisp.net/project/oct>"
:licence "MIT"
:version "2013.11.26" ; Just use the date
:version "2020.11.27" ; Just use the date
:in-order-to ((test-op (test-op "oct/tests")))
:depends-on (octi)
:components
((:module "src"
:components
((:file "qd-package")
(:file "qd-rep" :depends-on ("qd-package"))
#-cmu
(:file "qd-dd" :depends-on ("qd-package" "qd-rep"))
(:file "qd"
:depends-on ("qd-rep" #-cmu "qd-dd"))
(:file "qd-io"
:depends-on ("qd"))
(:file "qd-const"
:depends-on ("qd-io")
:around-compile (lambda (thunk)
;; Just byte-compile these on cmucl since these are just constants
(let (#+nil (ext:*byte-compile-default* t))
(funcall thunk))))
(:file "qd-fun"
:depends-on ("qd" "qd-const"))
(:file "qd-class"
:depends-on ("qd-fun"))
(:file "qd-const2" :depends-on ("qd-class" "qd-const")
((:file "oct-package")
(:file "qd-class" :depends-on ("oct-package"))
(:file "qd-const2" :depends-on ("qd-class")
:around-compile (lambda (thunk)
;; Just byte-compile these on cmucl since these are just constants
(let (#+nil (ext:*byte-compile-default* t))
......
;;;; -*- Mode: lisp -*-
(defpackage #:octi-system
(:use #:cl #:asdf))
(in-package #:octi-system)
(asdf:defsystem octi
:description "Internals for oct"
:author "Raymond Toy"
:licence "MIT"
:version "2020.11.27"
:components
((:module "src"
:components
((:file "octi-package")
(:file "qd-const"
:depends-on ("qd-io")
:around-compile (lambda (thunk)
;; Just byte-compile these on cmucl since these are just constants
(let (#+nil (ext:*byte-compile-default* t))
(funcall thunk))))
#-cmu
(:file "qd-dd" :depends-on ("octi-package" "qd-rep"))
(:file "qd-fun"
:depends-on ("qd" "qd-const"))
(:file "qd-io"
:depends-on ("qd"))
(:file "qd"
:depends-on ("qd-rep" #-cmu "qd-dd"))
(:file "qd-rep"
:depends-on ("octi-package"))))))
......@@ -53,91 +53,6 @@
#-cmu
(pushnew :oct-array *features*)
(defpackage #:oct-internal
(:use #:cl)
(: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-parts
#:+qd-one+
#:+qd-zero+
#:+qd-pi+
#:+qd-pi/2+
#:+qd-pi/4+
#:+qd-2pi+
#:+qd-log2+
;; Functions
#:hypot-qd
#: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
#:random-qd
#:with-qd-parts
#:rational-to-qd
)
#+cmu
(: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)
......
;;;; -*- Mode: lisp -*-
;; 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
(:use #:cl)
(: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-parts
#:+qd-one+
#:+qd-zero+
#:+qd-pi+
#:+qd-pi/2+
#:+qd-pi/4+
#:+qd-2pi+
#:+qd-log2+
;; Functions
#:hypot-qd
#: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
#:random-qd
#:with-qd-parts
#:rational-to-qd
)
#+cmu
(: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))
......@@ -1188,7 +1188,7 @@
for phi = (random (/ +pi+ 2))
for epi = (elliptic-pi 1 phi 0)
for true = (tan phi)
for result = (check-accuracy 192.6 epi true)
for result = (check-accuracy 192.06 epi true)
unless (eq nil result)
append (list (list (list k phi) result)))
nil)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment