Commit 712df0bc authored by Raymond Toy's avatar Raymond Toy
Browse files

Add tests for dd-%sincos.

parent bf84dbc8
......@@ -388,3 +388,46 @@
(define-test dd-sincos.signed-zeroes
"Test sincos at 0d0, -0d0"
(:tag :sincos :signed-zeroes :double-double)
(assert-equal '(0w0 1w0)
(multiple-value-list (kernel::dd-%sincos 0w0)))
(assert-equal '(-0w0 1w0)
(multiple-value-list (kernel::dd-%sincos -0w0))))
;; Test sincos at a bunch of random points and compare the result from
;; sin and cos. If they differ, save the result in a list to be
;; returned.
(defun dd-sincos-test (limit n)
(let (results)
(dotimes (k n)
(let* ((x (random limit))
(s-exp (sin x))
(c-exp (cos x)))
(multiple-value-bind (s c)
(kernel::dd-%sincos x)
(unless (and (eql s s-exp)
(eql c c-exp))
(push (list x
(list s s-exp)
(list c c-exp))
(define-test dd-sincos.consistent
"Test sincos is consistent with sin and cos"
(:tag :sincos :double-double)
;; Small values
(assert-eql nil
(dd-sincos-test (/ kernel:dd-pi 4) 1000))
;; Medium
(assert-eql nil
(dd-sincos-test 16w0 1000))
;; Large
(assert-eql nil
(dd-sincos-test (scale-float 1w0 120) 1000))
;; Very large
(assert-eql nil
(dd-sincos-test (scale-float 1w0 1023) 1000)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment