[cl-gsl-cvs] CVS update: cl-gsl/test/test-vector.lisp
cl-gsl-cvs at common-lisp.net
cl-gsl-cvs at common-lisp.net
Sun Apr 10 02:32:25 UTC 2005
Update of /project/cl-gsl/cvsroot/cl-gsl/test
In directory common-lisp.net:/tmp/cvs-serv27622
Modified Files:
test-vector.lisp
Log Message:
Add several more test. Almost complete except for subvector and
subvector-with-stride tests - which don't work yet.
Date: Sun Apr 10 04:32:24 2005
Author: edenny
Index: cl-gsl/test/test-vector.lisp
diff -u cl-gsl/test/test-vector.lisp:1.2 cl-gsl/test/test-vector.lisp:1.3
--- cl-gsl/test/test-vector.lisp:1.2 Thu Apr 7 04:37:55 2005
+++ cl-gsl/test/test-vector.lisp Sun Apr 10 04:32:24 2005
@@ -49,7 +49,7 @@
(eq (gsl-vector:gsl-vec-element-type v) 'integer))
(gsl-vector:free v)))))
-(deftest "make-vector-complex-double-float" :category +vector+
+v(deftest "make-vector-complex-double-float" :category +vector+
:test-fn
#'(lambda ()
(let ((v (gsl-vector:make-vector 5 :element-type
@@ -550,7 +550,7 @@
(gsl-vector:with-vector
(v 5 :element-type 'double-float :initial-contents vec)
(equalp (reverse vec)
- (gsl-vector:gsl-vector->lisp-vector
+ (gsl-vector:gsl->lisp-vector
(gsl-vector:reverse-vector v)))))))
(deftest "reverse-single-float" :category +vector+
@@ -560,7 +560,7 @@
(gsl-vector:with-vector
(v 5 :element-type 'single-float :initial-contents vec)
(equalp (reverse vec)
- (gsl-vector:gsl-vector->lisp-vector
+ (gsl-vector:gsl->lisp-vector
(gsl-vector:reverse-vector v)))))))
(deftest "reverse-integer" :category +vector+
@@ -570,7 +570,7 @@
(gsl-vector:with-vector
(v 5 :element-type 'integer :initial-contents vec)
(equalp (reverse vec)
- (gsl-vector:gsl-vector->lisp-vector
+ (gsl-vector:gsl->lisp-vector
(gsl-vector:reverse-vector v)))))))
@@ -584,7 +584,7 @@
(v 5 :element-type '(complex (double-float))
:initial-contents vec)
(equalp (reverse vec)
- (gsl-vector:gsl-vector->lisp-vector
+ (gsl-vector:gsl->lisp-vector
(gsl-vector:reverse-vector v)))))))
@@ -598,7 +598,7 @@
(v 5 :element-type '(complex (single-float))
:initial-contents vec)
(equalp (reverse vec)
- (gsl-vector:gsl-vector->lisp-vector
+ (gsl-vector:gsl->lisp-vector
(gsl-vector:reverse-vector v)))))))
;; ----------------------------------------------------------------------
@@ -613,10 +613,8 @@
(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))))))))
+ (and (equalp vec (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec (gsl-vector:gsl->lisp-vector v2))))))))
(deftest "read-write-single-float" :category +vector+
:test-fn
@@ -628,10 +626,8 @@
(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))))))))
+ (and (equalp vec (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec (gsl-vector:gsl->lisp-vector v2))))))))
(deftest "read-write-integer" :category +vector+
:test-fn
@@ -642,10 +638,8 @@
(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))))))))
+ (and (equalp vec (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec (gsl-vector:gsl->lisp-vector v2))))))))
(deftest "read-write-complex-double-float" :category +vector+
:test-fn
@@ -660,10 +654,8 @@
(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))))))))
+ (and (equalp vec (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec (gsl-vector:gsl->lisp-vector v2))))))))
(deftest "read-write-complex-single-float" :category +vector+
:test-fn
@@ -678,10 +670,8 @@
(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))))))))
+ (and (equalp vec (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec (gsl-vector:gsl->lisp-vector v2))))))))
;; ----------------------------------------------------------------------
@@ -695,10 +685,8 @@
(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))))))))
+ (and (equalp vec (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec (gsl-vector:gsl->lisp-vector v2))))))))
(deftest "read-write-binary-single-float" :category +vector+
:test-fn
@@ -709,10 +697,8 @@
(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))))))))
+ (and (equalp vec (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec (gsl-vector:gsl->lisp-vector v2))))))))
(deftest "read-write-binary-integer" :category +vector+
@@ -724,10 +710,8 @@
(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))))))))
+ (and (equalp vec (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec (gsl-vector:gsl->lisp-vector v2))))))))
(deftest "read-write-binary-complex-double-float" :category +vector+
:test-fn
@@ -742,10 +726,8 @@
(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))))))))
+ (and (equalp vec (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec (gsl-vector:gsl->lisp-vector v2))))))))
(deftest "read-write-binary-complex-single-float" :category +vector+
:test-fn
@@ -760,7 +742,599 @@
(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))))))))
+ (and (equalp vec (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec (gsl-vector:gsl->lisp-vector v2))))))))
+
+;; ----------------------------------------------------------------------
+
+(deftest "copy-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec (vector 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0))
+ (v2)
+ (res))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'double-float :initial-contents vec)
+ (setq v2 (gsl-vector:copy v1))
+ (setq res (equalp (gsl-vector:gsl->lisp-vector v1)
+ (gsl-vector:gsl->lisp-vector v2)))
+ (gsl-vector:free v2))
+ res)))
+
+(deftest "copy-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:with-vector-copy (v2 v1)
+ (and (equalp vec (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec (gsl-vector:gsl->lisp-vector v2))))))))
+
+(deftest "copy-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:with-vector-copy (v2 v1)
+ (and (equalp vec (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec (gsl-vector:gsl->lisp-vector v2))))))))
+
+(deftest "copy-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:with-vector-copy (v2 v1)
+ (and (equalp vec (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec (gsl-vector:gsl->lisp-vector v2))))))))
+
+(deftest "copy-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:with-vector-copy (v2 v1)
+ (and (equalp vec (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec (gsl-vector:gsl->lisp-vector v2))))))))
+
+
+;; ----------------------------------------------------------------------
+
+(deftest "swap-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let* ((vec-1 (vector 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0))
+ (vec-2 (reverse vec-1)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'double-float :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type 'double-float :initial-contents vec-2)
+ (gsl-vector:swap v1 v2)
+ (and (equalp vec-2 (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec-1 (gsl-vector:gsl->lisp-vector v2))))))))
+
+(deftest "swap-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let* ((vec-1 (vector 1.0 2.0 3.0 4.0 5.0))
+ (vec-2 (reverse vec-1)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'single-float :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type 'single-float :initial-contents vec-2)
+ (gsl-vector:swap v1 v2)
+ (and (equalp vec-2 (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec-1 (gsl-vector:gsl->lisp-vector v2))))))))
+
+(deftest "swap-integer" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let* ((vec-1 (vector 1 2 3 4 5))
+ (vec-2 (reverse vec-1)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'integer :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type 'integer :initial-contents vec-2)
+ (gsl-vector:swap v1 v2)
+ (and (equalp vec-2 (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec-1 (gsl-vector:gsl->lisp-vector v2))))))))
+
+(deftest "swap-complex-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let* ((vec-1 (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)))
+ (vec-2 (reverse vec-1)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type '(complex (double-float))
+ :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type '(complex (double-float))
+ :initial-contents vec-2)
+ (gsl-vector:swap v1 v2)
+ (and (equalp vec-2 (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec-1 (gsl-vector:gsl->lisp-vector v2))))))))
+
+(deftest "swap-complex-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let* ((vec-1 (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)))
+ (vec-2 (reverse vec-1)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type '(complex (single-float))
+ :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type '(complex (single-float))
+ :initial-contents vec-2)
+ (gsl-vector:swap v1 v2)
+ (and (equalp vec-2 (gsl-vector:gsl->lisp-vector v1))
+ (equalp vec-1 (gsl-vector:gsl->lisp-vector v2))))))))
+
+;; ----------------------------------------------------------------------
+
+(deftest "swap-elements-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0))
+ (vec-2 (vector 1.0d0 2.0d0 4.0d0 3.0d0 5.0d0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'double-float :initial-contents vec-1)
+ (gsl-vector:swap-elements v1 2 3)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1))))))
+
+(deftest "swap-elements-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1.0 2.0 3.0 4.0 5.0))
+ (vec-2 (vector 1.0 2.0 4.0 3.0 5.0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'single-float :initial-contents vec-1)
+ (gsl-vector:swap-elements v1 2 3)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1))))))
+
+(deftest "swap-elements-integer" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1 2 3 4 5))
+ (vec-2 (vector 1 2 4 3 5)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'integer :initial-contents vec-1)
+ (gsl-vector:swap-elements v1 2 3)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1))))))
+
+(deftest "swap-elements-complex-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (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)))
+ (vec-2 (vector (complex 1.0d0 1.0d0) (complex 2.0d0 2.0d0)
+ (complex 4.0d0 4.0d0) (complex 3.0d0 3.0d0)
+ (complex 5.0d0 5.0d0))))
+ (gsl-vector:with-vector
+ (v1 5 :element-type '(complex (double-float))
+ :initial-contents vec-1)
+ (gsl-vector:swap-elements v1 2 3)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1))))))
+
+(deftest "swap-elements-complex-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (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)))
+ (vec-2 (vector (complex 1.0 1.0) (complex 2.0 2.0)
+ (complex 4.0 4.0) (complex 3.0 3.0)
+ (complex 5.0 5.0))))
+ (gsl-vector:with-vector
+ (v1 5 :element-type '(complex (single-float))
+ :initial-contents vec-1)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector
+ (gsl-vector:swap-elements v1 2 3)))))))
+
+;; ----------------------------------------------------------------------
+
+(deftest "add-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0))
+ (vec-2 (vector 2.0d0 4.0d0 6.0d0 8.0d0 10.0d0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'double-float :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type 'double-float :initial-contents vec-1)
+ (gsl-vector:add v1 v2)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1)))))))
+
+(deftest "add-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1.0 2.0 3.0 4.0 5.0))
+ (vec-2 (vector 2.0 4.0 6.0 8.0 10.0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'single-float :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type 'single-float :initial-contents vec-1)
+ (gsl-vector:add v1 v2)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1)))))))
+
+(deftest "add-integer" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1 2 3 4 5))
+ (vec-2 (vector 2 4 6 8 10)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'integer :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type 'integer :initial-contents vec-1)
+ (gsl-vector:add v1 v2)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1)))))))
+
+
+;; ----------------------------------------------------------------------
+
+(deftest "sub-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0))
+ (vec-2 (vector 0.0d0 0.0d0 0.0d0 0.0d0 0.0d0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'double-float :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type 'double-float :initial-contents vec-1)
+ (gsl-vector:sub v1 v2)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1)))))))
+
+(deftest "sub-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1.0 2.0 3.0 4.0 5.0))
+ (vec-2 (vector 0.0 0.0 0.0 0.0 0.0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'single-float :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type 'single-float :initial-contents vec-1)
+ (gsl-vector:sub v1 v2)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1)))))))
+
+(deftest "sub-integer" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1 2 3 4 5))
+ (vec-2 (vector 0 0 0 0 0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'integer :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type 'integer :initial-contents vec-1)
+ (gsl-vector:sub v1 v2)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1)))))))
+
+;; ----------------------------------------------------------------------
+
+(deftest "mul-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0))
+ (vec-2 (vector 1.0d0 4.0d0 9.0d0 16.0d0 25.0d0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'double-float :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type 'double-float :initial-contents vec-1)
+ (gsl-vector:mul v1 v2)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1)))))))
+
+(deftest "mul-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1.0 2.0 3.0 4.0 5.0))
+ (vec-2 (vector 1.0 4.0 9.0 16.0 25.0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'single-float :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type 'single-float :initial-contents vec-1)
+ (gsl-vector:mul v1 v2)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1)))))))
+
+(deftest "mul-integer" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1 2 3 4 5))
+ (vec-2 (vector 1 4 9 16 25)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'integer :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type 'integer :initial-contents vec-1)
+ (gsl-vector:mul v1 v2)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1)))))))
+
+;; ----------------------------------------------------------------------
+
+(deftest "div-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0))
+ (vec-2 (vector 1.0d0 1.0d0 1.0d0 1.0d0 1.0d0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'double-float :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type 'double-float :initial-contents vec-1)
+ (gsl-vector:div v1 v2)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1)))))))
+
+(deftest "div-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1.0 2.0 3.0 4.0 5.0))
+ (vec-2 (vector 1.0 1.0 1.0 1.0 1.0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'single-float :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type 'single-float :initial-contents vec-1)
+ (gsl-vector:div v1 v2)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1)))))))
+
+(deftest "div-integer" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1 2 3 4 5))
+ (vec-2 (vector 1 1 1 1 1)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'integer :initial-contents vec-1)
+ (gsl-vector:with-vector
+ (v2 5 :element-type 'integer :initial-contents vec-1)
+ (gsl-vector:div v1 v2)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1)))))))
+
+
+;; ----------------------------------------------------------------------
+
+(deftest "scale-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0))
+ (vec-2 (vector 10.0d0 20.0d0 30.0d0 40.0d0 50.0d0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'double-float :initial-contents vec-1)
+ (gsl-vector:scale v1 10.0d0)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1))))))
+
+(deftest "scale-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1.0 2.0 3.0 4.0 5.0))
+ (vec-2 (vector 10.0 20.0 30.0 40.0 50.0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'single-float :initial-contents vec-1)
+ (gsl-vector:scale v1 10.0)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1))))))
+
+(deftest "scale-integer" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1 2 3 4 5))
+ (vec-2 (vector 10 20 30 40 50)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'integer :initial-contents vec-1)
+ (gsl-vector:scale v1 10)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1))))))
+
+
+;; ----------------------------------------------------------------------
+
+(deftest "add-constant-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0))
+ (vec-2 (vector 11.0d0 12.0d0 13.0d0 14.0d0 15.0d0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'double-float :initial-contents vec-1)
+ (gsl-vector:add-constant v1 10.0d0)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1))))))
+
+(deftest "add-constant-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1.0 2.0 3.0 4.0 5.0))
+ (vec-2 (vector 11.0 12.0 13.0 14.0 15.0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'single-float :initial-contents vec-1)
+ (gsl-vector:add-constant v1 10.0)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1))))))
+
+(deftest "add-constant-integer" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 1 2 3 4 5))
+ (vec-2 (vector 11 12 13 14 15)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'integer :initial-contents vec-1)
+ (gsl-vector:add-constant v1 10)
+ (equalp vec-2 (gsl-vector:gsl->lisp-vector v1))))))
+
+;; ----------------------------------------------------------------------
+
+(deftest "max-value-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4.0d0 5.0d0 1.0d0 2.0d0 3.0d0))
+ (max-val 5.0d0))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'double-float :initial-contents vec-1)
+ (= max-val (gsl-vector:max-value v1))))))
+
+(deftest "max-value-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4.0 5.0 1.0 2.0 3.0))
+ (max-val 5.0))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'single-float :initial-contents vec-1)
+ (= max-val (gsl-vector:max-value v1))))))
+
+(deftest "max-value-integer" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4 5 1 2 3))
+ (max-val 5))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'integer :initial-contents vec-1)
+ (= max-val (gsl-vector:max-value v1))))))
+
+;; ----------------------------------------------------------------------
+
+(deftest "min-value-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4.0d0 5.0d0 1.0d0 2.0d0 3.0d0))
+ (min-val 1.0d0))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'double-float :initial-contents vec-1)
+ (= min-val (gsl-vector:min-value v1))))))
+
+(deftest "min-value-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4.0 5.0 1.0 2.0 3.0))
+ (min-val 1.0))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'single-float :initial-contents vec-1)
+ (= min-val (gsl-vector:min-value v1))))))
+
+(deftest "min-value-integer" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4 5 1 2 3))
+ (min-val 1))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'integer :initial-contents vec-1)
+ (= min-val (gsl-vector:min-value v1))))))
+
+;; ----------------------------------------------------------------------
+
+(deftest "max-index-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4.0d0 5.0d0 1.0d0 2.0d0 3.0d0))
+ (max-idx 1))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'double-float :initial-contents vec-1)
+ (= max-idx (gsl-vector:max-index v1))))))
+
+(deftest "max-index-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4.0 5.0 1.0 2.0 3.0))
+ (max-idx 1))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'single-float :initial-contents vec-1)
+ (= max-idx (gsl-vector:max-index v1))))))
+
+(deftest "max-index-integer" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4 5 1 2 3))
+ (max-idx 1))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'integer :initial-contents vec-1)
+ (= max-idx (gsl-vector:max-index v1))))))
+
+;; ----------------------------------------------------------------------
+
+(deftest "min-index-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4.0d0 5.0d0 1.0d0 2.0d0 3.0d0))
+ (min-idx 2))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'double-float :initial-contents vec-1)
+ (= min-idx (gsl-vector:min-index v1))))))
+
+(deftest "min-index-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4.0 5.0 1.0 2.0 3.0))
+ (min-idx 2))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'single-float :initial-contents vec-1)
+ (= min-idx (gsl-vector:min-index v1))))))
+
+(deftest "min-index-integer" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4 5 1 2 3))
+ (min-idx 2))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'integer :initial-contents vec-1)
+ (= min-idx (gsl-vector:min-index v1))))))
+
+;; ----------------------------------------------------------------------
+
+(deftest "min-max-indicies-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4.0d0 5.0d0 1.0d0 2.0d0 3.0d0))
+ (min-max-idx '(2 1)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'double-float :initial-contents vec-1)
+ (equal min-max-idx (gsl-vector:min-max-indicies v1))))))
+
+(deftest "min-max-indicies-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4.0 5.0 1.0 2.0 3.0))
+ (min-max-idx '(2 1)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'single-float :initial-contents vec-1)
+ (equal min-max-idx (gsl-vector:min-max-indicies v1))))))
+
+(deftest "min-max-indicies-integer" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4 5 1 2 3))
+ (min-max-idx '(2 1)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'integer :initial-contents vec-1)
+ (equal min-max-idx (gsl-vector:min-max-indicies v1))))))
+
+;; ----------------------------------------------------------------------
+
+(deftest "min-max-values-double-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4.0d0 5.0d0 1.0d0 2.0d0 3.0d0))
+ (min-max-val '(1.0d0 5.0d0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'double-float :initial-contents vec-1)
+ (equal min-max-val (gsl-vector:min-max-values v1))))))
+
+(deftest "min-max-values-single-float" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4.0 5.0 1.0 2.0 3.0))
+ (min-max-val '(1.0 5.0)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'single-float :initial-contents vec-1)
+ (equal min-max-val (gsl-vector:min-max-values v1))))))
+
+(deftest "min-max-values-integer" :category +vector+
+ :test-fn
+ #'(lambda ()
+ (let ((vec-1 (vector 4 5 1 2 3))
+ (min-max-val '(1 5)))
+ (gsl-vector:with-vector
+ (v1 5 :element-type 'integer :initial-contents vec-1)
+ (equal min-max-val (gsl-vector:min-max-values v1))))))
+
More information about the Cl-gsl-cvs
mailing list