-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcis.lsp
51 lines (43 loc) · 1.24 KB
/
cis.lsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sat Sep 6 18:42:15 2003
;;;; Contains: Tests of CIS
(in-package :cl-test)
(compile-and-load "numbers-aux.lsp")
(deftest cis.error.1
(signals-error (cis) program-error)
t)
(deftest cis.error.2
(signals-error (cis 0 nil) program-error)
t)
(deftest cis.1
(let ((result (cis 0)))
(or (=t result 1)
(eqlt #c(1.0 0.0))))
t)
(deftest cis.2
(loop for x in '(0.0s0 0.0f0 0.0d0 0.0l0)
for vals = (multiple-value-list (cis x))
for c = (car vals)
unless (and (= (length vals) 1)
(eql c (complex (float 1 x) x)))
collect (cons x vals))
nil)
(deftest cis.3
(loop for x = (random (* 2 pi))
for c = (cis x)
repeat 1000
unless (and (complexp c)
(approx= (imagpart c) (sin x))
(approx= (realpart c) (cos x)))
collect (list x c (cos x) (sin x)))
nil)
(deftest cis.4
(loop for x = (random (coerce (* 2 pi) 'single-float))
for c = (cis x)
repeat 1000
unless (and (complexp c)
(approx= (imagpart c) (sin x))
(approx= (realpart c) (cos x)))
collect (list x c (cos x) (sin x)))
nil)