From: Raymond T. <rt...@us...> - 2010-05-28 02:05:35
|
Update of /cvsroot/maxima/maxima/src In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv5154 Modified Files: comm.lisp Log Message: Gcl doesn't signal errors on float(log(n)) for large n. Hence, don't try to compute that. Instead, for gcl, just use the more complicated algorithm(s) for all values of n. Index: comm.lisp =================================================================== RCS file: /cvsroot/maxima/maxima/src/comm.lisp,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- comm.lisp 22 May 2010 20:20:03 -0000 1.47 +++ comm.lisp 28 May 2010 02:05:26 -0000 1.48 @@ -1165,11 +1165,17 @@ (list (ncons (caar e)) ($float (cadr e)) (caddr e))))) ((and (eq (caar e) '%log) (complex-number-p (second e) '$ratnump)) + ;; Basically we try to compute float(log(x)) as directly as + ;; possible, expecting Lisp to return some error if it can't. + ;; Then we do a more complicated approach to compute the + ;; result. However, gcl doesn't signal errors in these + ;; cases, so we always use the complicated approach for gcl. (let ((n (second e))) (cond ((integerp n) - ;; float(log(int)). First try to compute (log (float n)). - ;; If that works, we're done. Otherwise we need to do more. - (to (or (ignore-errors (log (float n))) + ;; float(log(int)). First try to compute (log + ;; (float n)). If that works, we're done. + ;; Otherwise we need to do more. + (to (or #-gcl (ignore-errors (log (float n))) (let ((m (integer-length n))) ;; Write n as (n/2^m)*2^m where m is the number of ;; bits in n. Then log(n) = log(2^m) + log(n/2^m). @@ -1180,7 +1186,7 @@ (($ratnump n) ;; float(log(n/m)) where n and m are integers. Try computing ;; it first. If it fails, compute as log(n) - log(m). - (let ((try (ignore-errors (log (fpcofrat n))))) + (let ((try #-gcl (ignore-errors (log (fpcofrat n))))) (if try (to try) (sub ($float `((%log) ,(second n))) @@ -1189,7 +1195,8 @@ ;; float(log(n+m*%i)). (let ((re ($realpart n)) (im ($imagpart n))) - (to (or (ignore-errors (log (complex (float re) + (to (or #-gcl + (ignore-errors (log (complex (float re) (float im)))) (let* ((size (max (integer-length re) (integer-length im))) |