Commit c26f7f8e authored by Liam Healy's avatar Liam Healy
Browse files

Fix assert-to-tolerance; remaining exponential-function tests ported

The macro #'assert-to-tolerance was not correct but now maps to
sf-check-results.  The order of arguments in the sf-frac-diff call in
sf-check-single has reversed to match test_sf_check_result in the GSL
code.  The remaining exponential-function tests have been ported
except for the one involving gsl_sf_exprel_n_CF_e which hasn't been
ported.  All the tests except one pass.
parent 0f161980
;; Additional methods for lisp-unit
;; Liam Healy 2009-04-15 23:23:30EDT augment.lisp
;; Time-stamp: <2010-06-01 11:49:45EDT augment.lisp>
;; Time-stamp: <2010-06-01 22:02:57EDT augment.lisp>
;; Copyright 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -43,7 +43,7 @@
(defun sf-frac-diff (x1 x2)
;; After test_sf_frac_diff in specfunc/test_sf.c.
(cond ((and (zerop x1) (zerop x2))(exp-err-scaled 1.0d0 +test-sqrt-tol0+)
(cond ((and (zerop x1) (zerop x2))
(coerce 0 (type-of x1)))
((zerop x1)
(abs x2))
......@@ -58,7 +58,7 @@
(or (eql result expected-value) ; catch expected inifinity/nan
(let ((diff (abs (- result expected-value))))
(<= (sf-frac-diff result expected-value) (* +test-factor+ tolerance))
(<= (sf-frac-diff expected-value result) (* +test-factor+ tolerance))
(if error-estimate
(and (not (minusp error-estimate)) ; redundant but signalled as separate error in C
(finitep error-estimate)
......@@ -83,15 +83,11 @@
(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))))
(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)
......@@ -30,10 +30,8 @@
(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+))
(exp-err-scaled 1.0d0 +test-sqrt-tol0+) (exp 1.0d0) 0 +test-tol1+ (* 32 +test-sqrt-tol0+))
(exp-err-scaled 2000.0d0 1.0d-10) 3.88118019428363725d0 868 +test-tol3+ 1.0d-7)
(assert-to-tolerance (exp-mult -10.0d0 1.0d-06) (* 1.0d-06 (exp -10.0d0)) +test-tol0+)
......@@ -52,7 +50,7 @@
(exp-mult +exp-x+ 1.0d20) (* 1.0d20 (exp +exp-x+)) +test-tol3+)
(exp-mult +exp-x+ (* +exp-x+ (exp +ln2+))) 2.0d0 +test-tol4+)
(exp-mult +exp-x+ (* (exp (- +exp-x+)) (exp +ln2+))) 2.0d0 +test-tol4+)
(exp-mult-scaled 1.0d0 1.0d0) (exp 1.0d0) 0 +test-tol0+ +test-tol2+)
......@@ -67,5 +65,75 @@
(exp-mult-scaled 10000.0d0 1.0d0) 8.806818225662921587261496007d0 4342 +test-tol5+)
(exp-mult-scaled 100.0d0 1.0d0) 2.688117141816135448412625551d43 0 +test-tol2+))
(exp-mult-scaled 100.0d0 1.0d0) 2.688117141816135448412625551d43 0 +test-tol2+)
(exp-scaled 100.0d0) 2.688117141816135448412625551d43 0 +test-tol2+)
(exp-scaled 1000.0d0) 1.970071114017046993888879352d0 434 +test-tol3+)
(exp-scaled -100.0d0) 3.720075976020835962959695803d-44 0 +test-tol2+)
(exp-scaled -1000.0d0) 5.075958897549456765291809479d0 -435 +test-tol3+)
(ASSERT-TO-TOLERANCE (EXPM1 -10.0d0) (1- (EXP -10.0d0)) +test-tol0+)
(ASSERT-TO-TOLERANCE (EXPM1 -0.001d0) -0.00099950016662500845d0
(assert-to-tolerance (expm1 -1.0d-8) (+ -1.0d-8 0.5d-16) +test-tol0+)
(assert-to-tolerance (expm1 1.0d-8) (+ 1.0d-8 0.5d-16) +test-tol0+)
(assert-to-tolerance (expm1 0.001d0) 0.0010005001667083417d0 +test-tol0+)
(assert-to-tolerance (expm1 10.0d0) (1- (exp 10.0d0)) +test-tol0+)
(ASSERT-TO-TOLERANCE (EXPREL -10.0d0) 0.0999954600070237515d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL -0.001d0) 0.9995001666250084d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL -1.0d-8) (- 1.0d0 0.5d-8) +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL 1.0d-8) (+ 1.0d0 0.5d-8) +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL 0.001d0) 1.0005001667083417d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL 10.0d0) 2202.5465794806716517d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-2 -10.0d0) 0.18000090799859524970d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-2 -0.001d0) 0.9996667499833361107d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-2 -1.0d-8) 0.9999999966666666750d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-2 1.0d-8) 1.0000000033333333417d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-2 0.001d0) 1.0003334166833361115d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-2 10.0d0) 440.3093158961343303d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 3 -1000.0d0) 0.00299400600000000000d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 3 -100.0d0) 0.02940600000000000000d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 3 -10.0d0) 0.24599972760042142509d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 3 -3.0d0) 0.5444917625849191238d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 3 -0.001d0) 0.9997500499916678570d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 3 -1.0d-8) 0.9999999975000000050d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 3 1.0d-8) 1.0000000025000000050d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 3 0.001d0) 1.0002500500083345240d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 3 3.0d0) 2.5745637607083706091d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 3 3.1d0) 2.6772417068460206247d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 3 10.0d0) 131.79279476884029910d0 +TEST-TOL1+)
(ASSERT-TO-TOLERANCE (EXPREL-N 3 100.0d0) 1.6128702850896812690d+38 +TEST-TOL2+)
(ASSERT-TO-TOLERANCE (EXPREL-N 50 -1000.0d0) 0.04766231609253975959d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 50 -100.0d0) 0.3348247572345889317d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 50 -10.0d0) 0.8356287051853286482d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 50 -3.0d0) 0.9443881609152163615d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 50 -1.0d0) 0.980762245565660617d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 50 -1.0d-8) (- 1.0d0 (/ 1.0d-8 51.0d0)) +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 50 1.0d-8) (+ 1.0d0 (/ 1.0d-8 51.0d0)) +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 50 1.0d0) 1.01999216583666790d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 50 3.0d0) 1.0624205757460368307d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 50 48.0d0) 7.499573876877194416d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 50 50.1d0) 9.311803306230992272d0 +TEST-TOL4+)
(ASSERT-TO-TOLERANCE (EXPREL-N 50 100.0d0) 8.175664432485807634d+07 +TEST-TOL4+)
(ASSERT-TO-TOLERANCE (EXPREL-N 50 500.0d0) 4.806352370663185330d+146 +TEST-TOL3+)
(ASSERT-TO-TOLERANCE (EXPREL-N 500 -1000.0d0) 0.3334815803127619256d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 500 -100.0d0) 0.8335646217536183909d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 500 -10.0d0) 0.9804297803131823066d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 500 -3.0d0) 0.9940475488850672997d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 500 -1.0d0) 0.9980079602383488808d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 500 -1.0d-8) (- 1.0d0 (/ 1.0d-8 501.0d0)) +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 500 1.0d-8) (+ 1.0d0 (/ 1.0d-8 501.0d0)) +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 500 1.0d0) 1.0019999920160634252d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 500 3.0d0) 1.0060240236632444934d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 500 48.0d0) 1.1059355517981272174d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (EXPREL-N 500 100.0d0) 1.2492221464878287204d0 +TEST-TOL1+)
(ASSERT-TO-TOLERANCE (EXPREL-N 500 500.0d0) 28.363019877927630858d0 +TEST-TOL2+)
(ASSERT-TO-TOLERANCE (EXPREL-N 500 1000.0d0) 2.4037563160335300322d+68 +TEST-TOL4+)
(ASSERT-TO-TOLERANCE (EXPREL-N 500 1600.0d0) 7.899293535320607403d+226 +TEST-TOL4+)
(ASSERT-TO-TOLERANCE (EXPREL-N 1263131 1261282.3637d0)
545.0113107238425900305428360d0 +TEST-TOL4+)
;; Nothing for this ported yet
;; gsl_sf_exprel_n_CF_e, (6.315655e+05, 6.302583168053568806e+05, &r), 385.425369029433473098652465720, TEST_TOL4, GSL_SUCCESS)
......@@ -158,7 +158,7 @@
(ASSERT-TO-TOLERANCE (RELATIVE-POCHAMMER -5.5d0 -11.0d0) 0.09090909090939652475d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (POCHAMMER -9.0d0 -4.0d0) #.(/ 17160.0d0) +test-tol0+)
(ASSERT-TO-TOLERANCE (POCHAMMER -9.0d0 -3.0d0) #.(/ -1320.0d0) +test-tol0+)
(ASSERT-TO-TOLERANCE (POCHAMMER -9.0d0 4.0d0) 3024.0d0 +TEST-TOL0+)
(ASSERT-TO-TOLERANCE (POCHAMMER -9.0d0 3.0d0) -504.0d0 +TEST-TOL0+)
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