Commit 0f161980 by Liam M. Healy

Fix argument order, optional error estimate for tests

Fixed the argument order to an exponential-functions test.  Error
estimates used in special function calculations are optional in
sf-check-results.  There is an exponential-functions test which fails
even though it is identical to a GSL test; commented out.
parent 60a4d332
;; Additional methods for lisp-unit
;; Liam Healy 2009-04-15 23:23:30EDT augment.lisp
;; Time-stamp: <2010-05-31 23:29:58EDT augment.lisp>
;; Time-stamp: <2010-06-01 11:49:45EDT augment.lisp>
;; Copyright 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -66,10 +66,12 @@
(defun sf-check-results (result-list expected-value tolerance)
"Check the results of multiple returns where each value may have an
error estimate returned as well."
;; After test_sf_check_result in specfunc/test_sf.c.
(when (atom expected-value)
(setf expected-value (list expected-value)))
(when (= (length result-list) (* 2 (length expected-value)))
(let ((errorsp (= (length result-list) (* 2 (length expected-value)))))
;; Error information is returned
(loop for ind below (length expected-value)
......@@ -77,19 +79,23 @@
(elt result-list ind)
(elt expected-value ind)
(elt result-list (+ ind (length expected-value)))))))
(when errorsp
(elt result-list (+ ind (length expected-value))))))))
;; (assert-to-tolerance (tdist-P 0.0d0 1.0d0) 0.5d0 +test-tol6+)
;; Probably can remove the binding of lisp-unit:*epsilon*, it doesn't
;; do anything anymore.
(defmacro assert-to-tolerance (form expected-value tolerance)
;; Equivalent of TEST_SF.
`(let ((lisp-unit:*epsilon* ,tolerance))
(multiple-value-list ,form) ,expected-value ,tolerance))))
;; and TEST_SF becomes assert-to-tolerance.
(defmacro assert-sf-scale (form expected-value scale result-tol &optional err-tol)
;; Equivalent of TEST_SF_E10.
;; Some of the tests in test_exp like gsl_sf_exp_mult_e10_e(1.0,
;; 1.0, &re) do a check of test_sf_frac_diff, then of the err, then
;; the scale (e10), then they (redundantly?) call test_sf_e10.
......@@ -102,8 +108,6 @@
(= scale ,scale)
,(if err-tol `(<= err ,err-tol) t)))))
;; lisp-unit::assert-true
(defmacro assert-posinf (form)
(let ((val ,form))
......@@ -23,13 +23,15 @@
;; assert-to-tolerance probably not doing any good here
(lisp-unit:define-test exponential-functions
;; From specfunc/test_sf.c
(assert-to-tolerance (gsl-exp -10.0d0) (exp -10.0d0) +test-tol0+)
;; From specfunc/test_sf.c.
(assert-to-tolerance (gsl-exp -10.0d0) (exp -10.0d0) +test-tol0+)
(assert-to-tolerance (gsl-exp 10.0d0) (exp 10.0d0) +test-tol0+)
(assert-sf-scale (exp-scaled 1.0d0) (exp 1.0d0) 0 +test-tol0+ +test-tol1+)
(assert-sf-scale (exp-scaled 2000.0d0) 3.88118019428363725d0 868 +test-tol3+ +test-tol5+)
(assert-to-tolerance (exp-err -10.0d0 +test-tol1+) (exp -10.0d0) +test-tol1+)
(assert-to-tolerance (exp-err 10.0d0 +test-tol1+) (exp 10.0d0) +test-tol1+)
;; This one fails even though it's identical to the GSL test which passes:
(exp-err-scaled 1.0d0 +test-sqrt-tol0+) (exp 1.0d0) 0 +test-tol1+ (* 32 +test-tol0+))
......@@ -58,7 +60,7 @@
634 +test-tol3+ 1.0d-11)
(exp-mult-err-scaled 1.0d0 +test-tol0+ 1.0d0 +test-tol0+)
0 (exp 1.0d0) +test-tol0+ +test-tol2+)
(exp 1.0d0) 0 +test-tol0+ +test-tol2+)
(exp-mult-err-scaled 1000.0d0 1.0d-12 1.0d200 1.0d190) 1.9700711140165661d0
634 +test-tol3+ 1.0d-9)
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