Fix magnitude on numbers with negative components.
Closes PR 15183.
This commit is contained in:
parent
f9825cb250
commit
fe4808f96a
|
@ -569,8 +569,10 @@
|
|||
(log-unboxing-opt "unboxed unary float complex")
|
||||
#`(let*-values (c.bindings ...)
|
||||
;; reuses the algorithm used by the Racket runtime
|
||||
(let-values ([(q) (unsafe-fl/ c.real-binding c.imag-binding)])
|
||||
(unsafe-fl* c.imag-binding
|
||||
(let*-values ([(r) (unsafe-flabs c.real-binding)]
|
||||
[(i) (unsafe-flabs c.imag-binding)]
|
||||
[(q) (unsafe-fl/ r i)])
|
||||
(unsafe-fl* i
|
||||
(unsafe-flsqrt (unsafe-fl+ 1.0
|
||||
(unsafe-fl* q q))))))])))
|
||||
|
||||
|
|
|
@ -95,7 +95,10 @@
|
|||
(good-opt (- 0+0i 0.0+0.0i))
|
||||
|
||||
;; Conjugate should correctly compute sign of 0.0
|
||||
(good-opt (conjugate 0.0+0.0i))))
|
||||
(good-opt (conjugate 0.0+0.0i))
|
||||
|
||||
;; Magnitude should always return positive results
|
||||
(good-opt (magnitude -1.0-2i))))
|
||||
|
||||
(module+ main
|
||||
(require rackunit/text-ui)
|
||||
|
|
Loading…
Reference in New Issue
Block a user