Commit a3fceffb authored by pfdietz's avatar pfdietz

Added some hyperbolic trig function tests.

parent 12fd563d
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Wed Feb 11 19:20:53 2004
;;;; Contains: Tests of ACOSH
(in-package :cl-test)
(deftest acosh.1
(let ((result (acosh 1)))
(or (eqlt result 0)
(eqlt result 0.0)))
t)
(deftest acosh.2
(loop for type in '(short-float single-float double-float long-float)
for zero = (coerce 0 type)
for one = (coerce 1 type)
unless (equal (multiple-value-list (acosh one))
(list zero))
collect type)
nil)
(deftest acosh.3
(loop for type in '(short-float single-float double-float long-float)
for zero = (coerce 0 `(complex ,type))
for one = (coerce 1 `(complex ,type))
unless (equal (multiple-value-list (acosh one))
(list zero))
collect type)
nil)
(deftest acosh.4
(loop for den = (1+ (random 10000))
for num = (random (* 10 den))
for x = (/ num den)
for rlist = (multiple-value-list (acosh x))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(numberp y))
collect (list x rlist))
nil)
(deftest acosh.5
(loop for type in '(short-float single-float double-float long-float)
nconc
(loop
for x = (1+ (random (coerce 1000 type)))
for rlist = (multiple-value-list (acosh x))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(typep y type))
collect (list x rlist)))
nil)
(deftest acosh.6
(loop for type in '(short-float single-float double-float long-float)
nconc
(loop
for x1 = (- (random (coerce 20 type)) 10)
for x2 = (- (random (coerce 20 type)) 10)
for rlist = (multiple-value-list (acosh (complex x1 x2)))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(typep y `(complex ,type)))
collect (list x rlist)))
nil)
;;; FIXME
;;; Add accuracy tests here
;;; Error tests
(deftest acosh.error.1
(signals-error (acosh) program-error)
t)
(deftest acosh.error.2
(signals-error (acosh 1.0 1.0) program-error)
t)
(deftest acosh.error.3
(loop for x in *mini-universe*
unless (or (numberp x)
(eval `(signals-error (acosh ',x) type-error)))
collect x)
nil)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Wed Feb 11 19:19:02 2004
;;;; Contains: Tests of ASINH
(in-package :cl-test)
(deftest asinh.1
(let ((result (asinh 0)))
(or (eqlt result 0)
(eqlt result 0.0)))
t)
(deftest asinh.2
(loop for type in '(short-float single-float double-float long-float)
for zero = (coerce 0 type)
unless (equal (multiple-value-list (asinh zero))
(list zero))
collect type)
nil)
(deftest asinh.3
(loop for type in '(short-float single-float double-float long-float)
for zero = (coerce 0 `(complex ,type))
unless (equal (multiple-value-list (asinh zero))
(list zero))
collect type)
nil)
(deftest asinh.4
(loop for den = (1+ (random 10000))
for num = (random (* 10 den))
for x = (/ num den)
for rlist = (multiple-value-list (asinh x))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(numberp y))
collect (list x rlist))
nil)
(deftest asinh.5
(loop for type in '(short-float single-float double-float long-float)
nconc
(loop
for x = (- (random (coerce 20 type)) 10)
for rlist = (multiple-value-list (asinh x))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(typep y type))
collect (list x rlist)))
nil)
(deftest asinh.6
(loop for type in '(short-float single-float double-float long-float)
nconc
(loop
for x1 = (- (random (coerce 20 type)) 10)
for x2 = (- (random (coerce 20 type)) 10)
for rlist = (multiple-value-list (asinh (complex x1 x2)))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(typep y `(complex ,type)))
collect (list x rlist)))
nil)
;;; FIXME
;;; Add accuracy tests here
;;; Error tests
(deftest asinh.error.1
(signals-error (asinh) program-error)
t)
(deftest asinh.error.2
(signals-error (asinh 1.0 1.0) program-error)
t)
(deftest asinh.error.3
(loop for x in *mini-universe*
unless (or (numberp x)
(eval `(signals-error (asinh ',x) type-error)))
collect x)
nil)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Wed Feb 11 19:26:25 2004
;;;; Contains: Tests of ATANH
(in-package :cl-test)
(deftest atanh.1
(let ((result (atanh 0)))
(or (eqlt result 0)
(eqlt result 0.0)))
t)
(deftest atanh.2
(loop for type in '(short-float single-float double-float long-float)
for zero = (coerce 0 type)
unless (equal (multiple-value-list (atanh zero))
(list zero))
collect type)
nil)
(deftest atanh.3
(loop for type in '(short-float single-float double-float long-float)
for zero = (coerce 0 `(complex ,type))
unless (equal (multiple-value-list (atanh zero))
(list zero))
collect type)
nil)
(deftest atanh.4
(loop for den = (1+ (random 10000))
for num = (random den)
for x = (/ num den)
for rlist = (multiple-value-list (atanh x))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(numberp y))
collect (list x rlist))
nil)
(deftest atanh.5
(loop for type in '(short-float single-float double-float long-float)
nconc
(loop
for x = (if (eql (random 2) 0)
(+ 2 (random (coerce 1000 type)))
(- -2 (random (coerce 1000 type))))
for rlist = (multiple-value-list (atanh x))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(typep y `(complex ,type)))
collect (list x rlist)))
nil)
(deftest atanh.5a
(loop for type in '(short-float single-float double-float long-float)
nconc
(loop
for x = (- (random (coerce 1.9998s0 type)) 0.9999s0)
for rlist = (multiple-value-list (atanh x))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(typep y type))
collect (list x rlist)))
nil)
(deftest atanh.6
(loop for type in '(short-float single-float double-float long-float)
nconc
(loop
for x1 = (- (random (coerce 1.9998s0 type)) 0.9999s0)
for rlist = (multiple-value-list (atanh (complex x1 0.0s0)))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(typep y `(complex ,type)))
collect (list x rlist)))
nil)
(deftest atanh.7
(loop for type in '(short-float single-float double-float long-float)
nconc
(loop
for x1 = (- (random (coerce 1.9998s0 type)) 0.9999s0)
for rlist = (multiple-value-list (atanh (complex 0.0s0 x1)))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(typep y `(complex ,type)))
collect (list x rlist)))
nil)
;;; FIXME
;;; Add accuracy tests here
;;; Error tests
(deftest atanh.error.1
(signals-error (atanh) program-error)
t)
(deftest atanh.error.2
(signals-error (atanh 1.0 1.0) program-error)
t)
(deftest atanh.error.3
(loop for x in *mini-universe*
unless (or (numberp x)
(eval `(signals-error (atanh ',x) type-error)))
collect x)
nil)
......@@ -153,6 +153,9 @@
always (numberp y))
t)
;;; FIXME
;;; More accuracy tests here
;;; Error tests
(deftest cos.error.1
......
......@@ -33,7 +33,10 @@
(load "sinh.lsp")
(load "cosh.lsp")
(load "tanh.lsp")
(load "asinh.lsp")
(load "acosh.lsp")
(load "atanh.lsp")
(load "times.lsp")
(load "plus.lsp")
......
......@@ -265,6 +265,7 @@
(defun epsilon (number)
(etypecase number
(complex (* 2 (epsilon (realpart number)))) ;; crude
(short-float short-float-epsilon)
(single-float single-float-epsilon)
(double-float double-float-epsilon)
......@@ -273,6 +274,7 @@
(defun negative-epsilon (number)
(etypecase number
(complex (* 2 (negative-epsilon (realpart number)))) ;; crude
(short-float short-float-negative-epsilon)
(single-float single-float-negative-epsilon)
(double-float double-float-negative-epsilon)
......
......@@ -153,6 +153,9 @@
always (numberp y))
t)
;;; FIXME
;;; More accuracy tests here
;;; Error tests
(deftest sin.error.1
......
......@@ -140,6 +140,9 @@
always (numberp y))
t)
;;; FIXME
;;; More accuracy tests here
;;; Error tests
(deftest tan.error.1
......
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Wed Feb 11 19:16:35 2004
;;;; Contains: Tests of TANH
(in-package :cl-test)
(deftest tanh.1
(let ((result (tanh 0)))
(or (eqlt result 0)
(eqlt result 0.0)))
t)
(deftest tanh.2
(loop for type in '(short-float single-float double-float long-float)
for zero = (coerce 0 type)
unless (equal (multiple-value-list (tanh zero))
(list zero))
collect type)
nil)
(deftest tanh.3
(loop for type in '(short-float single-float double-float long-float)
for zero = (coerce 0 `(complex ,type))
unless (equal (multiple-value-list (tanh zero))
(list zero))
collect type)
nil)
(deftest tanh.4
(loop for den = (1+ (random 10000))
for num = (random (* 10 den))
for x = (/ num den)
for rlist = (multiple-value-list (tanh x))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(numberp y))
collect (list x rlist))
nil)
(deftest tanh.5
(loop for type in '(short-float single-float double-float long-float)
nconc
(loop
for x = (- (random (coerce 20 type)) 10)
for rlist = (multiple-value-list (tanh x))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(typep y type))
collect (list x rlist)))
nil)
(deftest tanh.6
(loop for type in '(short-float single-float double-float long-float)
nconc
(loop
for x1 = (- (random (coerce 20 type)) 10)
for x2 = (- (random (coerce 20 type)) 10)
for rlist = (multiple-value-list (tanh (complex x1 x2)))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(typep y `(complex ,type)))
collect (list x rlist)))
nil)
;;; FIXME
;;; Add accuracy tests here
;;; Error tests
(deftest tanh.error.1
(signals-error (tanh) program-error)
t)
(deftest tanh.error.2
(signals-error (tanh 1.0 1.0) program-error)
t)
(deftest tanh.error.3
(loop for x in *mini-universe*
unless (or (numberp x)
(eval `(signals-error (tanh ',x) type-error)))
collect x)
nil)
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