mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 05:39:17 +02:00
Issue #376 - Support for two-argument atan
This commit is contained in:
parent
c760283bff
commit
8effbb64cd
1 changed files with 18 additions and 1 deletions
|
@ -75,5 +75,22 @@
|
|||
(define-inexact-op tan "tan" "ctan")
|
||||
(define-inexact-op asin "asin" "casin")
|
||||
(define-inexact-op acos "acos" "cacos")
|
||||
(define-inexact-op atan "atan" "catan")
|
||||
(define-inexact-op atan1 "atan" "catan")
|
||||
|
||||
;; Support for two-argument atan, from Chibi Scheme
|
||||
(define (atan y . o)
|
||||
(define (inf? z) (if (= +inf.0 z) #t (= -inf.0 z)))
|
||||
(if (null? o)
|
||||
(atan1 y)
|
||||
(let ((x (inexact (car o))))
|
||||
(if (and (inf? x) (inf? y))
|
||||
(* (if (< y 0) -1 1) (if (= x -inf.0) 3 1) 0.7853981633974483)
|
||||
(if (negative? x)
|
||||
(if (or (negative? y) (eqv? y -0.0))
|
||||
(- (atan1 (/ y x)) 3.141592653589793)
|
||||
(- 3.141592653589793 (atan1 (/ y (- x)))))
|
||||
(if (and (zero? x) (zero? y))
|
||||
(* (if (eqv? y -0.0) -1 1)
|
||||
(if (eqv? x -0.0) 3.141592653589793 x))
|
||||
(atan1 (/ y x))))))))
|
||||
))
|
||||
|
|
Loading…
Add table
Reference in a new issue