96 |
collect (list i c r)) |
collect (list i c r)) |
97 |
nil) |
nil) |
98 |
|
|
99 |
|
;;; This test will fail if you compute complex reciprocals |
100 |
|
;;; naively. If z = a + bi, the naive approach computes |
101 |
|
;;; z^-1 = c + di as c = a/(a^2+b^2), d = -b/(a^2+b^2). |
102 |
|
;;; That loses precision, however. Instead, the implementation |
103 |
|
;;; should do c = 1/(a+b/a), d = -1/(a/b+b). |
104 |
|
|
105 |
(deftest /.7 |
(deftest /.7 |
106 |
(loop for bound in (list 1.0s5 1.0f10 1.0d20 1.0l20) |
(loop for bound in (list 1.0s5 1.0f10 1.0d20 1.0l20) |
107 |
nconc |
nconc |
108 |
(loop for i = (1+ (random bound)) |
(loop for i = (1+ (random bound)) |
109 |
for c = (complex 0 i) |
for c = (complex 0 i) |
110 |
for r = (/ c) |
for r = (/ c) |
111 |
repeat 10000 |
repeat 1000 |
112 |
unless (eql r (complex 0 (- (/ i)))) |
unless (= r (complex 0 (- (/ i)))) |
113 |
collect (list i c r))) |
collect (list i c r (complex 0 (- (/ i)))))) |
114 |
nil) |
nil) |
115 |
|
|
116 |
(deftest /.8 |
(deftest /.8 |