(defun choose-distance-objects (dist) "choose-distant-objects: chooses the two longest away object thingies through ancient magic" (let ((o.b 0) (o.a 0) (vlist 0)) (dotimes (i 5) ;5 is suggested by Faloutsos & Lin (setf o.a (dist dist o.b)) (setf o.b (dist dist o.a))) (setf vlist (list o.a o.b)))) (deftest test-ancillary() "Tests the ancillary functions necessary for the completion of fastmap and k-means." (combine-results (test-set-distance-matrix) (test-set-distance-matrix2) (test-choose-distance-objects))) (deftest test-choose-distance-objects() (check (let ((x (choose-distance-objects (set-distance-matrix (make-array '(5 3) :initial-contents '((1 2 3) (4 5 6) (7 8 9) (-500 -500 -500) (500 500 500))))))) (and (or (= (first x) 3) (= (first x) 4)) (or (= (second x) 3) (= (second x) 4)))))) (deftest test-set-distance-matrix2() (check (let ((x (set-distance-matrix2 (make-array '(2 2) :initial-contents '((0 0) (0 1))) (make-array '(2 2) :initial-contents '((1 0) (1 1))))) (z (make-array '(2 2) :initial-contents '((1 1.4142135) (1.4142135 1))))) (equalp x z)))) (deftest test-set-distance-matrix() (check (let ((x (set-distance-matrix (make-array '(4 2) :initial-contents '((0 0) (0 1) (1 0) (1 1))))) (z (make-array '(4 4) :initial-contents '((0 1 1 1.4142135) (1 0 1.4142135 1) (1 1.4142135 0 1) (1.4142135 1 1 0))))) (equalp x z))))