[git] CMU Common Lisp branch master updated. snapshot-2014-03-1-g508b659

Raymond Toy rtoy at common-lisp.net
Sat Mar 8 19:27:18 UTC 2014

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMU Common Lisp".

The branch, master has been updated
       via  508b6594cf003d6a9d400d59d4ec32255728d0e9 (commit)
      from  901d7539202d485429c76b4262d0f6e500826a07 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 508b6594cf003d6a9d400d59d4ec32255728d0e9
Author: Raymond Toy <toy.raymond at gmail.com>
Date:   Sat Mar 8 11:27:06 2014 -0800

    Revert change for ticket 92.
    It's incorrect. We really want log(-0) to be -inf + i*pi. It's needed
    to get the correct values on the branch cuts of the special functions
    from the definitions.
    Update trac test to test for this.

diff --git a/src/compiler/float-tran.lisp b/src/compiler/float-tran.lisp
index b856a6c..08ce90b 100644
--- a/src/compiler/float-tran.lisp
+++ b/src/compiler/float-tran.lisp
@@ -1494,15 +1494,11 @@
   (two-arg-derive-type x y #'expt-derive-type-aux #'expt))
+;;; Note must assume that a type including 0.0 may also include -0.0
+;;; and thus the result may be complex -infinity + i*pi.
 (defun log-derive-type-aux-1 (x)
-  (elfun-derive-type-simple x
-			    #'(lambda (z)
-				;; log(0) and log(-0) is -infinity.
-				;; Return NIL to indicate that.
-				(if (zerop z)
-				    nil
-				    (log z)))
-			    -0d0 nil nil nil))
+  (elfun-derive-type-simple x #'log 0d0 nil nil nil))
 (defun log-derive-type-aux-2 (x y same-arg)
   (let ((log-x (log-derive-type-aux-1 x))
diff --git a/tests/trac.lisp b/tests/trac.lisp
index 7fd9408..f8b4258 100644
--- a/tests/trac.lisp
+++ b/tests/trac.lisp
@@ -329,8 +329,20 @@
 			(declare (type (double-float 0d0) x))
 			(log x)))))
-     'double-float
-     (third (kernel:%function-type f)))))
+     '(or double-float (complex double-float))
+     (third (kernel:%function-type f)))
+    ;; It is important that log(-0) = -inf + i*pi. This is needed to
+    ;; ensure that all of the special functions have the right values
+    ;; on the branch cuts. (Although the implementation of the special
+    ;; function may not use log internally, the definition might and
+    ;; this property is needed to derive the correct value from the
+    ;; definition.)
+    (assert-equal
+     (complex ext:double-float-negative-infinity pi)
+     (ext:with-float-traps-masked (:divide-by-zero) (log -0d0)))
+    (assert-equal
+     (complex ext:single-float-negative-infinity (float pi 1f0))
+     (ext:with-float-traps-masked (:divide-by-zero) (log -0f0)))))
 (define-test trac.93
   (:tag :trac)


Summary of changes:
 src/compiler/float-tran.lisp |   12 ++++--------
 tests/trac.lisp              |   16 ++++++++++++++--
 2 files changed, 18 insertions(+), 10 deletions(-)

CMU Common Lisp

More information about the cmucl-cvs mailing list