Changeset 534


Ignore:
Timestamp:
Feb 15, 2004, 8:08:59 AM (21 years ago)
Author:
Gary Byers
Message:

pick up acos/asin fixes

File:
1 edited

Legend:

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

    r531 r534  
    650650
    651651(defun asin (x)
    652   (if (typep x 'double-float)
    653     (locally (declare (type double-float x))
    654       (if (and (<= -1.0d0 x)
    655                (<= x 1.0d0))
    656         (%double-float-asin! x (%make-dfloat))
    657         (let* ((temp (+ (complex -0.0d0 x)
    658                         (sqrt (- 1.0d0 (the double-float (* x x)))))))
    659           (complex (phase temp) (- (log (abs temp)))))))
    660    
    661     (let* ((x1 (%make-sfloat)))
    662       (declare (dynamic-extent x1))
    663       (if (and (realp x)
    664                (<= -1.0s0 (setq x (%short-float x x1)))
    665                (<= x 1.0s0))
    666         (%single-float-asin! x1 (%make-sfloat))
    667         (progn
    668           (setq x (+ (complex (- (imagpart x)) (realpart x))
    669                      (sqrt (- 1 (* x x)))))
    670           (complex (phase x) (- (log (abs x)))))))))
    671 
     652  (number-case x
     653    (complex
     654      (let ((sqrt-1-x (sqrt (- 1 x)))
     655            (sqrt-1+x (sqrt (+ 1 x))))
     656        (complex (atan (/ (realpart x)
     657                          (realpart (* sqrt-1-x sqrt-1+x))))
     658                 (asinh (imagpart (* (conjugate sqrt-1-x)
     659                                     sqrt-1+x))))))
     660    (double-float
     661     (locally (declare (type double-float x))
     662       (if (and (<= -1.0d0 x)
     663                (<= x 1.0d0))
     664         (%double-float-asin! x (%make-dfloat))
     665         (let* ((temp (+ (complex -0.0d0 x)
     666                         (sqrt (- 1.0d0 (the double-float (* x x)))))))
     667           (complex (phase temp) (- (log (abs temp))))))))
     668    ((short-float rational)
     669     (let* ((x1 (%make-sfloat)))
     670       (declare (dynamic-extent x1))
     671       (if (and (realp x)
     672                (<= -1.0s0 (setq x (%short-float x x1)))
     673                (<= x 1.0s0))
     674         (%single-float-asin! x1 (%make-sfloat))
     675         (progn
     676           (setq x (+ (complex (- (imagpart x)) (realpart x))
     677                      (sqrt (- 1 (* x x)))))
     678           (complex (phase x) (- (log (abs x))))))))))
    672679
    673680
     
    680687
    681688(defun acos (x)
    682   (if (typep x 'double-float)
    683     (locally (declare (type double-float x))
    684       (if (and (<= -1.0d0 x)
    685                (<= x 1.0d0))
    686         (%double-float-acos! x (%make-dfloat))
    687         (- double-float-half-pi (asin x))))
    688     (ppc32::with-stack-short-floats ((sx x))
    689       (locally
    690           (declare (type short-float sx))
    691         (if (and (<= -1.0s0 sx)
    692                  (<= sx 1.0s0))
    693           (%single-float-acos! sx (%make-sfloat))
    694           (- single-float-half-pi (asin sx)))))))
     689  (number-case x
     690    (complex
     691     (let ((sqrt-1+x (sqrt (+ 1 x)))
     692           (sqrt-1-x (sqrt (- 1 x))))
     693       (complex (* 2 (atan (/ (realpart sqrt-1-x)
     694                              (realpart sqrt-1+x))))
     695                (asinh (imagpart (* (conjugate sqrt-1+x)
     696                                    sqrt-1-x))))))
     697   
     698    (double-float
     699     (locally (declare (type double-float x))
     700       (if (and (<= -1.0d0 x)
     701                (<= x 1.0d0))
     702         (%double-float-acos! x (%make-sfloat))
     703         (- double-float-half-pi (asin x)))))
     704    ((short-float rational)
     705     (ppc32::with-stack-short-floats ((sx x))
     706        (locally
     707            (declare (type short-float sx))
     708          (if (and (<= -1.0s0 sx)
     709                   (<= sx 1.0s0))
     710            (%single-float-acos! sx (%make-sfloat))
     711            (- single-float-half-pi (asin sx))))))))
    695712
    696713
Note: See TracChangeset for help on using the changeset viewer.