Changeset 15553


Ignore:
Timestamp:
Dec 29, 2012, 11:23:41 PM (6 years ago)
Author:
svspire
Message:

acos and asin now do the right thing with complex args.
Fixes ticket:1040 in the trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-0/l0-float.lisp

    r15407 r15553  
    888888      (let ((sqrt-1-x (sqrt (- 1 x)))
    889889            (sqrt-1+x (sqrt (+ 1 x))))
    890         (complex (atan (/ (realpart x)
    891                           (realpart (* sqrt-1-x sqrt-1+x))))
     890        (complex (atan (realpart x)
     891                       (realpart (* sqrt-1-x sqrt-1+x)))
    892892                 (asinh (imagpart (* (conjugate sqrt-1-x)
    893893                                     sqrt-1+x))))))
     
    930930)
    931931
    932 
    933 
    934932(defun acos (x)
    935933  "Return the arc cosine of NUMBER."
    936934  (number-case x
    937935    (complex
    938      (let ((sqrt-1+x (sqrt (+ 1 x)))
    939            (sqrt-1-x (sqrt (- 1 x))))
    940        (complex (* 2 (atan (/ (realpart sqrt-1-x)
    941                               (realpart sqrt-1+x))))
    942                 (asinh (imagpart (* (conjugate sqrt-1+x)
    943                                     sqrt-1-x))))))
    944    
     936     (if (typep (realpart x) 'double-float)
     937       (- double-float-half-pi (asin x))
     938       (- single-float-half-pi (asin x))))
    945939    (double-float
    946940     (locally (declare (type double-float x))
Note: See TracChangeset for help on using the changeset viewer.