updated version, but need to update installation scripts
[cls.git] / tests / complex.lsp
blob2dfb5f5031e6a0ff23de375f611105021ad9185d
1 ; tests of complex number arithmetic
2 (setf eps 1.e-12)
4 (check #'= (+ #c(2 3) #c(4 2)) #c(6 5))
5 (check #'= (+ (- #c(2 3)) #c(4 2)) #c(2 -1))
6 (check #'= (- #c(2 3) #c(4 2)) (- #c(2 -1)))
7 (check #'= (* (- #c(3 4)) #c(1 -2)) (- #c(11 -2)))
8 (check #'< (abs (- (/ #c(2 1) #c(1 2)) (/ 4 5) (/ 3 #c(0 5)))) eps)
9 (check #'< (abs (- (imagpart (* #c(3.4 2.5) #c(3.4 -2.5))) 0)) eps)
10 (check #'< (abs (- (abs #c(2 -2)) (sqrt 8))) eps)
11 (check #'< (abs (- (realpart (- #c(1.77 -3))) -1.77)) eps)
12 (check #'< (abs (- (conjugate #c(9.03 -3.6)) #c(9.03 3.6))) eps)
13 (check #'< (abs (- (phase #c(2 2)) (/ pi 4))) eps)
14 (check #'= (complex 0 7) #c(0 7))
15 (check #'eql (if (complexp #c(4 0)) t nil) nil)
16 (check #'eql (if (complexp #c(4.5 0)) t nil) t)
17 (check #'= (cos (list pi (* 2 pi))) (cos (list (- pi) (- (* 2 pi)))))