Update of /project/cl-gsl/cvsroot/cl-gsl/test In directory common-lisp.net:/tmp/cvs-serv2190
Modified Files: test-vector.lisp Log Message: Added several new unit tests.
Date: Thu Apr 7 04:37:55 2005 Author: edenny
Index: cl-gsl/test/test-vector.lisp diff -u cl-gsl/test/test-vector.lisp:1.1 cl-gsl/test/test-vector.lisp:1.2 --- cl-gsl/test/test-vector.lisp:1.1 Tue Mar 15 04:21:49 2005 +++ cl-gsl/test/test-vector.lisp Thu Apr 7 04:37:55 2005 @@ -25,41 +25,51 @@ :test-fn #'(lambda () (let ((v (gsl-vector:make-vector 5 :element-type 'double-float))) - (and (= (gsl-vector:gsl-vec-size v) 5) - (eq (gsl-vector:gsl-vec-element-type v) 'double-float))))) + (prog1 + (and (= (gsl-vector:gsl-vec-size v) 5) + (eq (gsl-vector:gsl-vec-element-type v) 'double-float)) + (gsl-vector:free v)))))
(deftest "make-vector-single-float" :category +vector+ :test-fn #'(lambda () (let ((v (gsl-vector:make-vector 5 :element-type 'single-float))) - (and (= (gsl-vector:gsl-vec-size v) 5) - (eq (gsl-vector:gsl-vec-element-type v) 'single-float))))) + (prog1 + (and (= (gsl-vector:gsl-vec-size v) 5) + (eq (gsl-vector:gsl-vec-element-type v) 'single-float)) + (gsl-vector:free v)))))
(deftest "make-vector-integer" :category +vector+ :test-fn #'(lambda () (let ((v (gsl-vector:make-vector 5 :element-type 'integer))) - (and (= (gsl-vector:gsl-vec-size v) 5) - (eq (gsl-vector:gsl-vec-element-type v) 'integer))))) + (prog1 + (and (= (gsl-vector:gsl-vec-size v) 5) + (eq (gsl-vector:gsl-vec-element-type v) 'integer)) + (gsl-vector:free v)))))
(deftest "make-vector-complex-double-float" :category +vector+ :test-fn #'(lambda () (let ((v (gsl-vector:make-vector 5 :element-type '(complex (double-float))))) - (and (= (gsl-vector:gsl-vec-size v) 5) - (equal (gsl-vector:gsl-vec-element-type v) - '(complex (double-float))))))) + (prog1 + (and (= (gsl-vector:gsl-vec-size v) 5) + (equal (gsl-vector:gsl-vec-element-type v) + '(complex (double-float)))) + (gsl-vector:free v)))))
(deftest "make-vector-complex-single-float" :category +vector+ :test-fn #'(lambda () (let ((v (gsl-vector:make-vector 5 :element-type '(complex (single-float))))) - (and (= (gsl-vector:gsl-vec-size v) 5) - (equal (gsl-vector:gsl-vec-element-type v) - '(complex (single-float))))))) + (prog1 + (and (= (gsl-vector:gsl-vec-size v) 5) + (equal (gsl-vector:gsl-vec-element-type v) + '(complex (single-float)))) + (gsl-vector:free v)))))
;; ----------------------------------------------------------------------
@@ -72,7 +82,9 @@ (ret t)) (dotimes (i 5 ret) (unless (= (gsl-vector:get-element v i) 1.0d0) - (setq ret nil)))))) + (setq ret nil))) + (gsl-vector:free v) + ret)))
(deftest "make-vector-single-float-initial-element" :category +vector+ @@ -84,7 +96,9 @@ (ret t)) (dotimes (i 5 ret) (unless (= (gsl-vector:get-element v i) 1.0) - (setq ret nil)))))) + (setq ret nil))) + (gsl-vector:free v) + ret)))
(deftest "make-vector-integer-initial-element" :category +vector+ @@ -96,7 +110,9 @@ (ret t)) (dotimes (i 5 ret) (unless (= (gsl-vector:get-element v i) 1) - (setq ret nil)))))) + (setq ret nil))) + (gsl-vector:free v) + ret)))
(deftest "make-vector-complex-double-float-initial-element" :category +vector+ :test-fn @@ -109,7 +125,9 @@ (ret t)) (dotimes (i 5 ret) (unless (= (gsl-vector:get-element v i) (complex 1.0d0 1.0d0)) - (setq ret nil)))))) + (setq ret nil))) + (gsl-vector:free v) + ret)))
(deftest "make-vector-complex-single-float-initial-element" :category +vector+ :test-fn @@ -121,4 +139,628 @@ (ret t)) (dotimes (i 5 ret) (unless (= (gsl-vector:get-element v i) (complex 1.0 1.0)) - (setq ret nil)))))) + (setq ret nil))) + (gsl-vector:free v) + ret))) + +;; ---------------------------------------------------------------------- + +(deftest "make-vector-double-float-initial-contents" :category +vector+ + :test-fn + #'(lambda () + (let ((v (gsl-vector:make-vector + 5 + :element-type 'double-float + :initial-contents (list 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0))) + (ret t) + (val 0.0d0)) + (dotimes (i 5 ret) + (unless (= (gsl-vector:get-element v i) (incf val 1.0d0)) + (setq ret nil))) + (gsl-vector:free v) + ret))) + + +(deftest "make-vector-single-float-initial-contents" :category +vector+ + :test-fn + #'(lambda () + (let ((v (gsl-vector:make-vector + 5 + :element-type 'single-float + :initial-contents (vector -1.0 -2.0 -3.0 -4.0 -5.0))) + (ret t) + (val 0.0)) + (dotimes (i 5 ret) + (unless (= (gsl-vector:get-element v i) (decf val 1.0)) + (setq ret nil))) + (gsl-vector:free v) + ret))) + + +(deftest "make-vector-integer-initial-contents" :category +vector+ + :test-fn + #'(lambda () + (let ((v (gsl-vector:make-vector + 5 + :element-type 'integer + :initial-contents (list 1 2 3 4 5))) + (ret t) + (val 0)) + (dotimes (i 5 ret) + (unless (= (gsl-vector:get-element v i) (incf val)) + (setq ret nil))) + (gsl-vector:free v) + ret))) + +(deftest "make-vector-complex-double-float-initial-contents" :category +vector+ + :test-fn + #'(lambda () + (let ((v (gsl-vector:make-vector + 5 + :element-type '(complex (double-float)) + :initial-contents + (vector (complex 1.0d0 1.0d0) (complex 2.0d0 2.0d0) + (complex 3.0d0 3.0d0) (complex 4.0d0 4.0d0) + (complex 5.0d0 5.0d0)))) + (ret t) + (val (complex 0.0d0 0.0d0))) + (dotimes (i 5 ret) + (unless (= (gsl-vector:get-element v i) + (incf val (complex 1.0d0 1.0d0))) + (setq ret nil))) + (gsl-vector:free v) + ret))) + +(deftest "make-vector-complex-single-float-initial-contents" :category +vector+ + :test-fn + #'(lambda () + (let ((v (gsl-vector:make-vector + 5 + :element-type '(complex (single-float)) + :initial-contents + (list (complex -1.0 -1.0) (complex -2.0 -2.0) + (complex -3.0 -3.0) (complex -4.0 -4.0) + (complex -5.0 -5.0)))) + (ret t) + (val (complex 0.0 0.0))) + (dotimes (i 5 ret) + (unless (= (gsl-vector:get-element v i) + (decf val (complex 1.0 1.0))) + (setq ret nil))) + (gsl-vector:free v) + ret))) + +;; ---------------------------------------------------------------------- + +(deftest "set-all-double-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector (v 5 :element-type 'double-float) + (gsl-vector:set-all v 5.0d0) + (let ((ret t)) + (dotimes (i 5 ret) + (unless (= (gsl-vector:get-element v i) 5.0d0) + (setq ret nil))))))) + + +(deftest "set-all-single-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector (v 5 :element-type 'single-float) + (gsl-vector:set-all v 5.0) + (let ((ret t)) + (dotimes (i 5 ret) + (unless (= (gsl-vector:get-element v i) 5.0) + (setq ret nil))))))) + +(deftest "set-all-integer" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector (v 5 :element-type 'integer) + (gsl-vector:set-all v 5) + (let ((ret t)) + (dotimes (i 5 ret) + (unless (= (gsl-vector:get-element v i) 5) + (setq ret nil))))))) + +(deftest "set-all-complex-double-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector + (v 5 :element-type '(complex (double-float))) + (gsl-vector:set-all v (complex 5.0d0 4.0d0)) + (let ((ret t)) + (dotimes (i 5 ret) + (unless (= (gsl-vector:get-element v i) + (complex 5.0d0 4.0d0)) + (setq ret nil))))))) + +(deftest "set-all-complex-single-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector + (v 5 :element-type '(complex (single-float))) + (gsl-vector:set-all v (complex 5.0 4.0)) + (let ((ret t)) + (dotimes (i 5 ret) + (unless (= (gsl-vector:get-element v i) (complex 5.0 4.0)) + (setq ret nil))))))) + +;; ---------------------------------------------------------------------- + +(deftest "set-zero-double-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector (v 5 :element-type 'double-float) + (gsl-vector:set-all v 5.0d0) + (gsl-vector:set-zero v) + (let ((ret t)) + (dotimes (i 5 ret) + (unless (= (gsl-vector:get-element v i) 0.0d0) + (setq ret nil))))))) + + +(deftest "set-zero-single-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector (v 5 :element-type 'single-float) + (gsl-vector:set-all v 5.0) + (gsl-vector:set-zero v) + (let ((ret t)) + (dotimes (i 5 ret) + (unless (= (gsl-vector:get-element v i) 0.0) + (setq ret nil))))))) + +(deftest "set-zero-integer" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector (v 5 :element-type 'integer) + (gsl-vector:set-all v 5) + (gsl-vector:set-zero v) + (let ((ret t)) + (dotimes (i 5 ret) + (unless (= (gsl-vector:get-element v i) 0) + (setq ret nil))))))) + +(deftest "set-zero-complex-double-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector + (v 5 :element-type '(complex (double-float))) + (gsl-vector:set-all v (complex 5.0d0 4.0d0)) + (gsl-vector:set-zero v) + (let ((ret t)) + (dotimes (i 5 ret) + (unless (= (gsl-vector:get-element v i) + (complex 0.0d0 0.0d0)) + (setq ret nil))))))) + +(deftest "set-zero-complex-single-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector + (v 5 :element-type '(complex (single-float))) + (gsl-vector:set-all v (complex 5.0 4.0)) + (gsl-vector:set-zero v) + (let ((ret t)) + (dotimes (i 5 ret) + (unless (= (gsl-vector:get-element v i) (complex 0.0 0.0)) + (setq ret nil))))))) + +;; ---------------------------------------------------------------------- + +(deftest "set-basis-double-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector (v 5 :element-type 'double-float) + (gsl-vector:set-basis v 3) + (let ((ret t)) + (dotimes (i 5 ret) + (if (= i 3) + (unless (= (gsl-vector:get-element v i) 1.0d0) + (setq ret nil)) + (unless (= (gsl-vector:get-element v i) 0.0d0) + (setq ret nil)))))))) + +(deftest "set-basis-single-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector (v 5 :element-type 'single-float) + (gsl-vector:set-basis v 2) + (let ((ret t)) + (dotimes (i 5 ret) + (if (= i 2) + (unless (= (gsl-vector:get-element v i) 1.0) + (setq ret nil)) + (unless (= (gsl-vector:get-element v i) 0.0) + (setq ret nil)))))))) + +(deftest "set-basis-integer" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector (v 5 :element-type 'integer) + (gsl-vector:set-basis v 1) + (let ((ret t)) + (dotimes (i 5 ret) + (if (= i 1) + (unless (= (gsl-vector:get-element v i) 1) + (setq ret nil)) + (unless (= (gsl-vector:get-element v i) 0) + (setq ret nil)))))))) + +(deftest "set-basis-complex-double-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector + (v 5 :element-type '(complex (double-float))) + (gsl-vector:set-basis v 4) + (let ((ret t)) + (dotimes (i 5 ret) + (if (= i 4) + (unless (= (gsl-vector:get-element v i) + (complex 1.0d0 0.0d0)) + (setq ret nil)) + (unless (= (gsl-vector:get-element v i) + (complex 0.0d0 0.0d0)) + (setq ret nil)))))))) + +(deftest "set-basis-complex-single-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector + (v 5 :element-type '(complex (single-float))) + (gsl-vector:set-basis v 0) + (let ((ret t)) + (dotimes (i 5 ret) + (if (= i 0) + (unless (= (gsl-vector:get-element v i) + (complex 1.0 0.0)) + (setq ret nil)) + (unless (= (gsl-vector:get-element v i) + (complex 0.0 0.0)) + (setq ret nil)))))))) + + +;; ---------------------------------------------------------------------- + +(deftest "set-element-double-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector (v 5 :element-type 'double-float) + (gsl-vector:set-zero v) + (gsl-vector:set-element v 3 6.0d0) + (let ((ret t)) + (dotimes (i 5 ret) + (if (= i 3) + (unless (= (gsl-vector:get-element v i) 6.0d0) + (setq ret nil)) + (unless (= (gsl-vector:get-element v i) 0.0d0) + (setq ret nil)))))))) + + +(deftest "set-element-single-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector (v 5 :element-type 'single-float) + (gsl-vector:set-zero v) + (gsl-vector:set-element v 2 6.0) + (let ((ret t)) + (dotimes (i 5 ret) + (if (= i 2) + (unless (= (gsl-vector:get-element v i) 6.0) + (setq ret nil)) + (unless (= (gsl-vector:get-element v i) 0.0) + (setq ret nil)))))))) + +(deftest "set-element-integer" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector (v 5 :element-type 'integer) + (gsl-vector:set-zero v) + (gsl-vector:set-element v 1 6) + (let ((ret t)) + (dotimes (i 5 ret) + (if (= i 1) + (unless (= (gsl-vector:get-element v i) 6) + (setq ret nil)) + (unless (= (gsl-vector:get-element v i) 0) + (setq ret nil)))))))) + +(deftest "set-element-complex-double-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector + (v 5 :element-type '(complex (double-float))) + (gsl-vector:set-zero v) + (gsl-vector:set-element v 4 (complex 6.0d0 7.0d0)) + (let ((ret t)) + (dotimes (i 5 ret) + (if (= i 4) + (unless (= (gsl-vector:get-element v i) + (complex 6.0d0 7.0d0)) + (setq ret nil)) + (unless (= (gsl-vector:get-element v i) + (complex 0.0d0 0.0d0)) + (setq ret nil)))))))) + +(deftest "set-element-complex-single-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector + (v 5 :element-type '(complex (single-float))) + (gsl-vector:set-zero v) + (gsl-vector:set-element v 0 (complex 6.0 7.0)) + (let ((ret t)) + (dotimes (i 5 ret) + (if (= i 0) + (unless (= (gsl-vector:get-element v i) + (complex 6.0 7.0)) + (setq ret nil)) + (unless (= (gsl-vector:get-element v i) + (complex 0.0 0.0)) + (setq ret nil)))))))) + +;; ---------------------------------------------------------------------- + +(deftest "isnull-double-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector (v 5 :element-type 'double-float) + (gsl-vector:set-zero v) + (gsl-vector:isnull v)))) + + +(deftest "isnull-single-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector (v 5 :element-type 'single-float) + (gsl-vector:set-basis v 0) + (not (gsl-vector:isnull v))))) + + +(deftest "isnull-integer" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector (v 5 :element-type 'integer) + (gsl-vector:set-zero v) + (gsl-vector:isnull v)))) + +(deftest "isnull-complex-double-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector + (v 5 :element-type '(complex (double-float))) + (gsl-vector:set-basis v 1) + (not (gsl-vector:isnull v))))) + +(deftest "isnull-complex-single-float" :category +vector+ + :test-fn + #'(lambda () + (gsl-vector:with-vector + (v 5 :element-type '(complex (single-float))) + (gsl-vector:set-zero v) + (gsl-vector:isnull v)))) + +;; ---------------------------------------------------------------------- + +(deftest "reverse-double-float" :category +vector+ + :test-fn + #'(lambda () + (let ((vec (vector 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0))) + (gsl-vector:with-vector + (v 5 :element-type 'double-float :initial-contents vec) + (equalp (reverse vec) + (gsl-vector:gsl-vector->lisp-vector + (gsl-vector:reverse-vector v))))))) + +(deftest "reverse-single-float" :category +vector+ + :test-fn + #'(lambda () + (let ((vec (vector 1.0 2.0 3.0 4.0 5.0))) + (gsl-vector:with-vector + (v 5 :element-type 'single-float :initial-contents vec) + (equalp (reverse vec) + (gsl-vector:gsl-vector->lisp-vector + (gsl-vector:reverse-vector v))))))) + +(deftest "reverse-integer" :category +vector+ + :test-fn + #'(lambda () + (let ((vec (vector 1 2 3 4 5))) + (gsl-vector:with-vector + (v 5 :element-type 'integer :initial-contents vec) + (equalp (reverse vec) + (gsl-vector:gsl-vector->lisp-vector + (gsl-vector:reverse-vector v))))))) + + +(deftest "reverse-complex-double-float" :category +vector+ + :test-fn + #'(lambda () + (let ((vec (vector (complex 1.0d0 1.0d0) (complex 2.0d0 2.0d0) + (complex 3.0d0 3.0d0) (complex 4.0d0 4.0d0) + (complex 5.0d0 5.0d0)))) + (gsl-vector:with-vector + (v 5 :element-type '(complex (double-float)) + :initial-contents vec) + (equalp (reverse vec) + (gsl-vector:gsl-vector->lisp-vector + (gsl-vector:reverse-vector v))))))) + + +(deftest "reverse-complex-single-float" :category +vector+ + :test-fn + #'(lambda () + (let ((vec (vector (complex -1.0 -1.0) (complex -2.0 -2.0) + (complex -3.0 -3.0) (complex -4.0 -4.0) + (complex -5.0 -5.0)))) + (gsl-vector:with-vector + (v 5 :element-type '(complex (single-float)) + :initial-contents vec) + (equalp (reverse vec) + (gsl-vector:gsl-vector->lisp-vector + (gsl-vector:reverse-vector v))))))) + +;; ---------------------------------------------------------------------- + +(deftest "read-write-double-float" :category +vector+ + :test-fn + #'(lambda () + (let ((vec (vector 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0))) + (gsl-vector:with-vector + (v1 5 :element-type 'double-float :initial-contents vec) + (gsl-vector:write-to-file "/tmp/test.txt" v1) + (gsl-vector:with-vector + (v2 5 :element-type 'double-float + :from-file "/tmp/test.txt") + (and (equalp vec + (gsl-vector:gsl-vector->lisp-vector v1)) + (equalp vec + (gsl-vector:gsl-vector->lisp-vector v2)))))))) + +(deftest "read-write-single-float" :category +vector+ + :test-fn + #'(lambda () + (let ((vec (vector 1.0 2.0 3.0 4.0 5.0))) + (gsl-vector:with-vector + (v1 5 :element-type 'single-float :initial-contents vec) + (gsl-vector:write-to-file "/tmp/test.txt" v1) + (gsl-vector:with-vector + (v2 5 :element-type 'single-float + :from-file "/tmp/test.txt") + (and (equalp vec + (gsl-vector:gsl-vector->lisp-vector v1)) + (equalp vec + (gsl-vector:gsl-vector->lisp-vector v2)))))))) + +(deftest "read-write-integer" :category +vector+ + :test-fn + #'(lambda () + (let ((vec (vector 1 2 3 4 5))) + (gsl-vector:with-vector + (v1 5 :element-type 'integer :initial-contents vec) + (gsl-vector:write-to-file "/tmp/test.txt" v1) + (gsl-vector:with-vector + (v2 5 :element-type 'integer :from-file "/tmp/test.txt") + (and (equalp vec + (gsl-vector:gsl-vector->lisp-vector v1)) + (equalp vec + (gsl-vector:gsl-vector->lisp-vector v2)))))))) + +(deftest "read-write-complex-double-float" :category +vector+ + :test-fn + #'(lambda () + (let ((vec (vector (complex 1.0d0 1.0d0) (complex 2.0d0 2.0d0) + (complex 3.0d0 3.0d0) (complex 4.0d0 4.0d0) + (complex 5.0d0 5.0d0)))) + (gsl-vector:with-vector + (v1 5 :element-type '(complex (double-float)) + :initial-contents vec) + (gsl-vector:write-to-file "/tmp/test.txt" v1) + (gsl-vector:with-vector + (v2 5 :element-type '(complex (double-float)) + :from-file "/tmp/test.txt") + (and (equalp vec + (gsl-vector:gsl-vector->lisp-vector v1)) + (equalp vec + (gsl-vector:gsl-vector->lisp-vector v2)))))))) + +(deftest "read-write-complex-single-float" :category +vector+ + :test-fn + #'(lambda () + (let ((vec (vector (complex 1.0 1.0) (complex 2.0 2.0) + (complex 3.0 3.0) (complex 4.0 4.0) + (complex 5.0 5.0)))) + (gsl-vector:with-vector + (v1 5 :element-type '(complex (single-float)) + :initial-contents vec) + (gsl-vector:write-to-file "/tmp/test.txt" v1) + (gsl-vector:with-vector + (v2 5 :element-type '(complex (single-float)) + :from-file "/tmp/test.txt") + (and (equalp vec + (gsl-vector:gsl-vector->lisp-vector v1)) + (equalp vec + (gsl-vector:gsl-vector->lisp-vector v2)))))))) + + +;; ---------------------------------------------------------------------- + +(deftest "read-write-binary-double-float" :category +vector+ + :test-fn + #'(lambda () + (let ((vec (vector 1.0000000000001d0 2.0d0 3.0d0 4.0d0 5.0d0))) + (gsl-vector:with-vector + (v1 5 :element-type 'double-float :initial-contents vec) + (gsl-vector:write-to-binary-file "/tmp/test.bin" v1) + (gsl-vector:with-vector (v2 5 :element-type 'double-float + :from-binary-file "/tmp/test.bin") + (and (equalp vec + (gsl-vector:gsl-vector->lisp-vector v1)) + (equalp vec + (gsl-vector:gsl-vector->lisp-vector v2)))))))) + +(deftest "read-write-binary-single-float" :category +vector+ + :test-fn + #'(lambda () + (let ((vec (vector 1.0 2.0 3.0 4.0 5.0))) + (gsl-vector:with-vector + (v1 5 :element-type 'single-float :initial-contents vec) + (gsl-vector:write-to-binary-file "/tmp/test.bin" v1) + (gsl-vector:with-vector (v2 5 :element-type 'single-float + :from-binary-file "/tmp/test.bin") + (and (equalp vec + (gsl-vector:gsl-vector->lisp-vector v1)) + (equalp vec + (gsl-vector:gsl-vector->lisp-vector v2)))))))) + + +(deftest "read-write-binary-integer" :category +vector+ + :test-fn + #'(lambda () + (let ((vec (vector 1 2 3 4 5))) + (gsl-vector:with-vector + (v1 5 :element-type 'integer :initial-contents vec) + (gsl-vector:write-to-binary-file "/tmp/test.bin" v1) + (gsl-vector:with-vector (v2 5 :element-type 'integer + :from-binary-file "/tmp/test.bin") + (and (equalp vec + (gsl-vector:gsl-vector->lisp-vector v1)) + (equalp vec + (gsl-vector:gsl-vector->lisp-vector v2)))))))) + +(deftest "read-write-binary-complex-double-float" :category +vector+ + :test-fn + #'(lambda () + (let ((vec (vector (complex 1.0d0 1.0d0) (complex 2.0d0 2.0d0) + (complex 3.0d0 3.0d0) (complex 4.0d0 4.0d0) + (complex 5.0d0 5.0d0)))) + (gsl-vector:with-vector + (v1 5 :element-type '(complex (double-float)) + :initial-contents vec) + (gsl-vector:write-to-binary-file "/tmp/test.bin" v1) + (gsl-vector:with-vector + (v2 5 :element-type '(complex (double-float)) + :from-binary-file "/tmp/test.bin") + (and (equalp vec + (gsl-vector:gsl-vector->lisp-vector v1)) + (equalp vec + (gsl-vector:gsl-vector->lisp-vector v2)))))))) + +(deftest "read-write-binary-complex-single-float" :category +vector+ + :test-fn + #'(lambda () + (let ((vec (vector (complex 1.0 1.0) (complex 2.0 2.0) + (complex 3.0 3.0) (complex 4.0 4.0) + (complex 5.0 5.0)))) + (gsl-vector:with-vector + (v1 5 :element-type '(complex (single-float)) + :initial-contents vec) + (gsl-vector:write-to-binary-file "/tmp/test.bin" v1) + (gsl-vector:with-vector + (v2 5 :element-type '(complex (single-float)) + :from-binary-file "/tmp/test.bin") + (and (equalp vec + (gsl-vector:gsl-vector->lisp-vector v1)) + (equalp vec + (gsl-vector:gsl-vector->lisp-vector v2))))))))