[Git][cmucl/cmucl][master] Add tanh tests.

Raymond Toy rtoy at common-lisp.net
Sun Dec 20 20:39:19 UTC 2015


Raymond Toy pushed to branch master at cmucl / cmucl


Commits:
4b556124 by Raymond Toy at 2015-12-20T12:38:54Z
Add tanh tests.

- - - - -


1 changed file:

- tests/fdlibm.lisp


Changes:

=====================================
tests/fdlibm.lisp
=====================================
--- a/tests/fdlibm.lisp
+++ b/tests/fdlibm.lisp
@@ -515,3 +515,26 @@
     (assert-error 'floating-point-overflow (sinh (- x))))
   (assert-error 'floating-point-overflow (sinh 1000d0))
   (assert-error 'floating-point-overflow (sinh -1000d0)))
+
+(define-test tanh-basic-tests
+    (:tag :fdlibm)
+  ;; case |x| < 2^-55
+  (let ((x (scale-float 1d0 -56)))
+    (assert-eql x (tanh x))
+    (assert-eql (- x) (tanh (- x))))
+  ;; tanh(log(2)) = 3/5, case |x| < 1
+  (let ((x (log 2d0))
+	(y (float 3/5 1d0)))
+    (assert-eql y (tanh x))
+    (assert-eql (- y) (tanh (- x))))
+  ;; tanh(2*log(2)) = 15/17, case |x| < 22
+  (let ((x (* 2 (log 2d0)))
+	(y (float 15/17 1d0)))
+    (assert-eql y (tanh x))
+    (assert-eql (- y) (tanh (- x))))
+  ;; tanh(100) = 1, case |x| > 22
+  (assert-eql 1d0 (tanh 100d0))
+  (assert-eql -1d0 (tanh -100d0))
+  ;; tanh(1d300), no overflow
+  (assert-eql 1d0 (tanh most-positive-double-float))
+  (assert-eql -1d0 (tanh (- most-positive-double-float))))
\ No newline at end of file



View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/commit/4b5561248417690e415cf61522515f3d4b9e219f
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cmucl-cvs/attachments/20151220/f0619648/attachment.html>


More information about the cmucl-cvs mailing list