Commit 039d1089 authored by Liam Healy's avatar Liam Healy
Browse files

New macro assert-to-tolerance and constants defining tolerances

Introduced a new macro #'assert-to-tolerance to be used in
lisp-unit:define-test forms that takes three arguments: form
expected-value tolerance.  This replaces test-tol6 that was defined in
tdist.lisp.  Defined the tolerance constants +test-tol6+ the exact
same way as GSL, but grovelling machine.h where GSL_DBL_EPSILON is
defined.
parent 24574c15
;; Definition of GSLL system
;; Liam Healy
;; Time-stamp: <2010-01-01 12:25:22EST gsll-tests.asd>
;; Time-stamp: <2010-05-22 10:24:43EDT gsll-tests.asd>
;;
;; Copyright 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -18,6 +18,9 @@
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(eval-when (:compile-toplevel :load-toplevel :execute)
(asdf:oos 'asdf:load-op :cffi-grovel))
(asdf:defsystem GSLL-TESTS
:name "GSLL-tests"
:description "Regression (unit) tests for GNU Scientific Library for Lisp."
......@@ -28,8 +31,10 @@
:components
((:module test-unit
:components
((:file "augment")))
((cffi-grovel:grovel-file "machine")
(:file "augment" :depends-on ("machine"))))
(:module tests
:depends-on (test-unit)
:components
((:file "absolute-deviation")
(:file "absolute-sum")
......
;; Additional methods for lisp-unit
;; Liam Healy 2009-04-15 23:23:30EDT augment.lisp
;; Time-stamp: <2009-12-27 10:12:13EST augment.lisp>
;; Time-stamp: <2010-05-22 10:54:02EDT augment.lisp>
;;
;; Copyright 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -26,3 +26,19 @@
(when (equal (dimensions result1) (dimensions result2))
(lisp-unit:numerical-equal (cl-array result1) (cl-array result2)
:test test)))
;;; See cdf/test.c
(defconstant +test-tol0+ (* 2 +dbl-epsilon+))
(defconstant +test-tol1+ (* 16 +dbl-epsilon+))
(defconstant +test-tol2+ (* 256 +dbl-epsilon+))
(defconstant +test-tol3+ (* 2048 +dbl-epsilon+))
(defconstant +test-tol4+ (* 16384 +dbl-epsilon+))
(defconstant +test-tol5+ (* 131072 +dbl-epsilon+))
(defconstant +test-tol6+ (* 1048576 +dbl-epsilon+))
;; (assert-to-tolerance (tdist-P 0.0d0 1.0d0) 0.5d0 +test-tol6+)
(defmacro assert-to-tolerance (form expected-value tolerance)
`(let ((lisp-unit:*epsilon* ,tolerance))
(lisp-unit::assert-numerical-equal
,expected-value
,form)))
;; Constants specifying limits of floating point calculations in hardware
;; Liam Healy
;; Time-stamp: <2010-05-22 10:01:27EDT machine.lisp>
;;
;; Copyright 2009 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 :gsl)
#+linux
(define "_GNU_SOURCE")
;;; When installed through Mac Ports, GSL .h files will be found
;;; in /opt/local/include.
#+darwin
(cc-flags "-I/opt/local/include/")
(include "gsl/gsl_machine.h")
(constant (+dbl-epsilon+ "GSL_DBL_EPSILON") :type double-float)
This diff is collapsed.
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