From 9fe590bf5597827195dd00790e6aaaee1e525ccb Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Tue, 20 Nov 2018 06:33:18 +0000 Subject: [PATCH] Test some screw cases for logistic-1/2. --- tests/runtime/test-arith.scm | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/runtime/test-arith.scm b/tests/runtime/test-arith.scm index 26d403d34..f43d0aabf 100644 --- a/tests/runtime/test-arith.scm +++ b/tests/runtime/test-arith.scm @@ -387,14 +387,25 @@ USA. (vector 1e-300 4e-300) (vector 1e-16 4e-16) (vector .2310585786300049 1.) - (vector .49999999999999994 37.42994775023705)) + (vector .49999999999999994 37.42994775023705) + (vector .5 38) + (vector .5 38) + (vector .5 709) + (vector .5 1000) + (vector .5 1e300)) (lambda (v) (let ((p (vector-ref v 0)) (x (vector-ref v 1))) - (assert-<= (relerr x (logit1/2+ p)) 1e-15) + (if (< p .5) + (begin + (assert-<= (relerr x (logit1/2+ p)) 1e-15) + (assert-= (- (logit1/2+ p)) (logit1/2+ (- p))))) (assert-<= (relerr p (logistic-1/2 x)) 1e-15) - (assert-= (- (logit1/2+ p)) (logit1/2+ (- p))) - (assert-= (- (logistic-1/2 x)) (logistic-1/2 (- x)))))) + ;; Currently logistic-1/2 takes no measures to avoid overflow in + ;; (exp (- x)). + (with-expected-failure (if (>= x 710) 'xfail #f) + (lambda () + (assert-= (- (logistic-1/2 x)) (logistic-1/2 (- x)))))))) (define-enumerated-test 'expt-exact (vector -- 2.25.1