Commit 9324e05e authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Define math functions

Define generic simple math functions that have definitions for numbers
in CL, like #'+, #'cos, etc.  These call the CL function if the
argument(s) are numbers, but method(s) may be defined for non-numbers
different objects.  Define a package antik-user which will import
symbols from antik and other packages, but will be left to the user
for other definitions.  Add copyright and license notice.
parent df2a11db
Antik: a Common Lisp library for computational mathematics, science, and engineering. It is named after the [[http://www.antikythera-mechanism.gr/][Antikythera Mechanism]], one of the oldest known devices built and used for scientific computation.
Antik: a Common Lisp library for computational mathematics, science, and engineering. It is named after the Antikythera Mechanism [http://www.antikythera-mechanism.gr/], one of the oldest known devices built and used for scientific computation.
Antik defines library functions for common mathemtical operations used in science and engineering including arrays and physical (dimensioned) quantities. It is expressly designed to facilitate the interchange of data with foreign (that is, non-lisp) libraries. For example, GSLL, the GNU Scientific Library for Lisp, uses Antik.
Antik defines library functions for common mathematical operations used in science and engineering including arrays and physical (dimensioned) quantities. It is expressly designed to facilitate the interchange of data with foreign (that is, non-lisp) libraries. For example, GSLL, the GNU Scientific Library for Lisp, uses Antik.
;; Antik system definition
;; Liam Healy 2010-12-24 09:43:28EST antik.asd
;; Time-stamp: <2010-12-24 09:46:08EST antik.asd>
;; Time-stamp: <2010-12-24 11:45:18EST antik.asd>
;; Copyright 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(asdf:defsystem #:antik
:serial t
......@@ -9,4 +25,5 @@
((:module init
:components
((:file "package")
(:file "conditions")))))
(:file "conditions")
(:file "generic")))))
;; Conditions and handlers for arithmetic.
;; Liam Healy Tue May 17 2005 - 16:29
;; Time-stamp: <2010-12-24 09:42:10EST conditions.lisp>
;; Time-stamp: <2010-12-24 11:45:43EST conditions.lisp>
;; Copyright 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(in-package :antik)
(eval-when (:compile-toplevel :load-toplevel :execute)
(export '(handling-complex-number arithmetic-errors-return-nan)))
(export '(handling-complex-number arithmetic-errors-return-nan))
;;;;****************************************************************************
;;;; Conditions
;;;;****************************************************************************
(define-condition gcoerce-undefined (arithmetic-error)
((object :initarg :object :reader gcoerce-object)
(to :initarg :to :reader gcoerce-to))
(define-condition coerce-undefined (arithmetic-error)
((object :initarg :object :reader coerce-object)
(to :initarg :to :reader coerce-to))
(:report (lambda (condition stream)
(format stream "Cannot coerce ~a to ~a."
(gcoerce-object condition)
(gcoerce-to condition))))
(coerce-object condition)
(coerce-to condition))))
(:documentation
"Signalled when making a generalized number in which a higher type
(like taylor-number) is a component of a lower type (like physical-quantity)."))
(define-condition gcoerce-nil (arithmetic-error)
((object :initarg :object :reader gcoerce-object))
(define-condition coerce-nil (arithmetic-error)
((object :initarg :object :reader coerce-object))
(:report (lambda (condition stream)
(format stream "Cannot coerce ~a to NIL." (gcoerce-object condition))))
(format stream "Cannot coerce ~a to NIL." (coerce-object condition))))
(:documentation "Signalled when gcoercing something to nil."))
(define-condition making-complex-number (arithmetic-error)
......
;; Define package and reader for Antik
;; Liam Healy 2010-12-24 09:12:15EST package.lisp
;; Time-stamp: <2010-12-24 09:47:36EST package.lisp>
;; Time-stamp: <2010-12-24 13:18:28EST package.lisp>
;;;; package.lisp
;; Copyright 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(in-package :cl-user)
......@@ -12,12 +26,30 @@
(defpackage #:antik
;; (:nicknames)
;; (:shadow :!)
(:shadowing-import-from #:iterate #:in #:for #:while)
(:shadow #:+ #:- #:* #:/
#:sin #:cos #:tan #:asin #:acos #:atan
#:sqrt #:expt #:log #:exp #:abs
#:plusp #:minusp #:zerop #:min #:max
#:= #:>= #:> #:<= #:<
#:coerce #:floor #:round #:signum
#:incf #:decf)
(:export
#:+ #:- #:* #:/
#:sin #:cos #:tan #:asin #:acos #:atan
#:sqrt #:expt #:log #:exp #:abs
#:plusp #:minusp #:zerop #:min #:max
#:= #:>= #:> #:<= #:<
#:coerce #:floor #:round #:signum
#:incf #:decf)
(:use #:common-lisp #:iterate))
(defpackage #:antik-user
;; (:nicknames)
;; (:shadow :!)
(:shadowing-import-from #:iterate #:in #:for #:while)
(:shadowing-import-from #:antik
#:+ #:- #:* #:/
#:sin #:cos #:tan #:asin #:acos #:atan
#:sqrt #:expt #:log #:exp #:abs
#:plusp #:minusp #:zerop #:min #:max
#:= #:>= #:> #:<= #:<
#:coerce #:floor #:round #:signum
#:incf #:decf)
(:use #:common-lisp #:iterate #:antik))
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