Commit af2866c2 authored by Liam Healy's avatar Liam Healy

Create vector-only and matrix-only tests

Create vector-only and matrix-only tests, and eliminate old comments
and test definitions.  Define outputs and returns for some vector and
matrix functions that didn't have them.
parent 32b971a4
;; Tests of array functions
;; Liam Healy 2008-10-20 22:41:48EDT array-tests.lisp
;; Time-stamp: <2008-11-08 19:04:34EST array-tests.lisp>
;; Time-stamp: <2008-11-08 22:27:39EST array-tests.lisp>
;; $Id: $
;;; Generate each file with #'write-test-to-file, e.g.
......@@ -190,3 +190,72 @@
(minmax-index m1)))
;;; No test for mzerop yet.
;;;;****************************************************************************
;;;; Vector-only function definitions
;;;;****************************************************************************
(generate-all-array-tests set-basis t
(letm ((v1 (array-default 8)))
(set-basis v1 2)
(cl-array v1)))
(generate-all-array-tests swap-elements t
(letm ((v1 (array-default 8)))
(swap-elements v1 2 5)
(cl-array v1)))
(generate-all-array-tests vector-reverse t
(letm ((v1 (array-default 8)))
(cl-array (vector-reverse v1))))
;;;;****************************************************************************
;;;; Matrix-only function definitions
;;;;****************************************************************************
(generate-all-array-tests set-identity t
(letm ((m1 (array-default '(3 3))))
(set-identity m1)))
(generate-all-array-tests row t
(letm ((m1 (array-default '(3 3)))
(row (array-default 3 t)))
(cl-array (row row m1 1))))
(generate-all-array-tests setf-row t
(letm ((m1 (array-default '(3 3)))
(row (array-default 3)))
(setf (row m1 2) row)
(cl-array m1)))
(generate-all-array-tests column t
(letm ((m1 (array-default '(3 3)))
(col (array-default 3 t)))
(cl-array (column col m1 1))))
(generate-all-array-tests setf-column t
(letm ((m1 (array-default '(3 3)))
(col (array-default 3)))
(setf (column m1 2) col)
(cl-array m1)))
(generate-all-array-tests swap-rows t
(letm ((m1 (array-default '(3 3))))
(cl-array (swap-rows m1 0 1))))
(generate-all-array-tests swap-columns t
(letm ((m1 (array-default '(3 3))))
(cl-array (swap-columns m1 1 2))))
(generate-all-array-tests swap-row-column t
(letm ((m1 (array-default '(3 3))))
(cl-array (swap-row-column m1 0 2))))
(generate-all-array-tests matrix-transpose t
(letm ((m1 (array-default '(3 3))))
(cl-array (matrix-transpose m1))))
(generate-all-array-tests matrix-transpose-copy t
(letm ((m1 (array-default '(3 3)))
(m2 (array-default '(3 3) t)))
(cl-array (matrix-transpose-copy m2 m1))))
;; Matrices
;; Liam Healy 2008-04-15 21:57:52EDT matrix-ffa.lisp
;; Time-stamp: <2008-06-30 22:53:27EDT matrix.lisp>
;; Time-stamp: <2008-11-08 22:33:17EST matrix.lisp>
;; $Id$
(in-package :gsl)
......@@ -34,6 +34,7 @@
(((mpointer matrix) :pointer))
:definition :generic
:c-return :void
:outputs (matrix)
:return (matrix)
:documentation ; FDL
"Set the elements of the matrix to the
......@@ -49,6 +50,8 @@
("gsl_matrix" :type "_get_row")
(((mpointer vector) :pointer) ((mpointer matrix) :pointer) (i sizet))
:definition :generic
:inputs (matrix)
:outputs (vector)
:return (vector)
:documentation ; FDL
"Copy the elements of the ith row of the matrix
......@@ -59,6 +62,7 @@
("gsl_matrix" :type "_set_row")
(((mpointer matrix) :pointer) (i sizet) ((mpointer vector) :pointer))
:definition :generic
:inputs (vector matrix)
:return (vector) ;setf should return
:documentation ; FDL
"Copy the elements of the vector into the jth column of the matrix.
......@@ -68,6 +72,8 @@
("gsl_matrix" :type "_get_col")
(((mpointer vector) :pointer) ((mpointer matrix) :pointer) (i sizet))
:definition :generic
:inputs (matrix)
:outputs (vector)
:return (vector)
:documentation ; FDL
"Copy the elements of the ith column of the matrix
......@@ -78,6 +84,7 @@
("gsl_matrix" :type "_set_col")
(((mpointer matrix) :pointer) (i sizet) ((mpointer vector) :pointer))
:definition :generic
:outputs (matrix)
:return (vector) ;setf should return
:documentation ; FDL
"Copy the elements of the vector into the ith column of the matrix.
......@@ -142,88 +149,3 @@
"Make the destination matrix the transpose of the source matrix
by copying the elements. The dimensions of the destination
matrix must match the transposed dimensions of the source.")
;;;;****************************************************************************
;;;; Examples and unit test
;;;;****************************************************************************
#|
(letm ((mat (matrix-double-float (els (2.0d0 -23.1d0) (55.0d0 -1.0d0)) t)))
(minmax mat))
|#
#|
(make-tests matrix-signed-byte-32
(letm ((intmat (matrix-signed-byte-32 2 2))) ;(setf maref), maref
(setf (maref intmat 0 1) 77)
(maref intmat 0 1))
(letm ((intmat (matrix-signed-byte-32 2 2))) ;(setf data)
(setf (data intmat) #2A((4 6) (8 2)))
(data intmat))
(letm ((intmat (matrix-signed-byte-32 2 2))) ;set-zero
(set-zero intmat)
(data intmat))
(letm ((intmat (matrix-signed-byte-32 2 2))) ;set-all
(set-all intmat 44)
(data intmat))
(letm ((intmat (matrix-signed-byte-32 2 2))) ;set-identity
(set-identity intmat)
(data intmat))
(letm ((intmat (matrix-signed-byte-32 #2A((4 6) (8 2)))) ;row
(vect (vector-signed-byte-32 2)))
(row vect intmat 0)
(data vect))
(letm ((intmat (matrix-signed-byte-32 #2A((4 6) (8 2)))) ;column
(vect (vector-signed-byte-32 2)))
(column vect intmat 1)
(data vect))
(letm ((intmat (matrix-signed-byte-32 #2A((-1 -12) (8 3))))) ;gsl-min
(gsl-min intmat))
(letm ((intmat (matrix-signed-byte-32 #2A((-1 -12) (8 3))))) ;gsl-max
(gsl-max intmat))
(letm ((intmat (matrix-signed-byte-32 #2A((-1 -12) (8 3))))) ;gsl-minmax
(multiple-value-list (gsl-minmax intmat)))
(letm ((intmat (matrix-signed-byte-32 #2A((-1 -12) (8 3))))) ;gsl-min-index
(gsl-min-index intmat))
(letm ((intmat (matrix-signed-byte-32 #2A((-1 -12) (8 3))))) ;gsl-max-index
(gsl-max-index intmat))
(letm ((intmat (matrix-signed-byte-32 #2A((-1 -12) (8 3))))) ;gsl-minmax-index
(multiple-value-list (gsl-minmax-index intmat)))
(letm ((intmat1 (matrix-signed-byte-32 #2A((1 2)(3 4)))) ;copy
(intmat2 (matrix-signed-byte-32 2 2)))
(copy intmat2 intmat1)
(data intmat2))
(letm ((intmat1 (matrix-signed-byte-32 #2A((1 2)(3 4)))) ;swap
(intmat2 (matrix-signed-byte-32 #2A((5 6) (7 8)))))
(swap intmat1 intmat2)
(data intmat1))
(letm ((intmat1 (matrix-signed-byte-32 #2A((1 2)(3 4))))) ;swap-rows
(swap-rows intmat1 0 1)
(data intmat1))
(letm ((intmat1 (matrix-signed-byte-32 #2A((1 2)(3 4))))) ;swap-columns
(swap-columns intmat1 0 1)
(data intmat1))
(letm ((intmat1 (matrix-signed-byte-32 #2A((1 2)(3 4))))) ;swap-rowcol
(swap-rowcol intmat1 0 1)
(data intmat1)))
|#
#|
(make-tests
matrix-double
(letm ((mat (matrix-double-float 10 3)))
(loop for i from 0 below 10
do
(loop for j from 0 below 3
do (setf (maref mat i j) (+ 0.23d0 j (* 100 i)))))
(data mat))
(letm ((mat (matrix-double-float #2A((1.0d0 2.0d0) (3.0d0 4.0d0))))
(ans (matrix-double-float 2 2)))
(copy ans mat)
(data ans))
(letm ((mat (matrix-double-float #2A((1.0d0 2.0d0) (3.0d0 4.0d0)))))
(m* mat mat)
(data mat))
(letm ((mat (matrix-double-float #2A((1.0d0 2.0d0) (-3.0d0 4.0d0)))))
(list (maref mat 0 0) (maref mat 0 1) (maref mat 1 0) (maref mat 1 1))))
|#
;; Vectors
;; Liam Healy 2008-04-13 09:39:02EDT vector-ffa.lisp
;; Time-stamp: <2008-08-28 21:41:15EDT vector.lisp>
;; Time-stamp: <2008-11-08 21:08:10EST vector.lisp>
;; $Id$
(in-package :gsl)
......@@ -36,6 +36,8 @@
:definition :generic
:inputs (object)
:outputs (object)
:return (object)
:outputs (object)
:documentation ; FDL
"Set the index element to 1, and the rest to 0.")
......@@ -58,122 +60,3 @@
:return (vec)
:documentation ; FDL
"Reverse the order of the elements of the vector vec.")
;;;;****************************************************************************
;;;; Examples and unit tests
;;;;****************************************************************************
#|
(let ((ac (make-array* 3 'double-float :initial-contents '(2.0d0 -23.1d0 55.0d0))))
(letm ((a (vector-double-float ac t))
(b (vector-double-float 3)))
(set-all b 12.0d0)
(m+ a b))
ac)
|#
;;;;;;;;;;;;;; TEST
#|
(letm ((a (vector-double-float x)))
blah)
(letm ((a (vector-double-float x t))
(b (vector-double-float #(3 4 5 1 2))))
(blah blah) blah)
(letm ((a (vector-signed-byte-16 #(1 2 3 4)))
(b (vector-signed-byte-16 #(3 4 5 1))))
(m+ a b))
;;; Example with double-float
(let ((a-array
(make-array*
'(3)
'double-float :initial-contents #(-3.21d0 1.0d0 12.8d0))))
(letm ((a (vector-double-float a-array)))
(set-all a 111.3d0)
(list (maref a 0) (maref a 1) (maref a 2))))
;;; Example with (unsigned-byte 8)
(let ((a-array
(make-array*
'(3)
'(unsigned-byte 8) :initial-contents #(5 6 4))))
(letm ((a (vector-unsigned-byte-8 a-array)))
(set-all a 1)
(list (maref a 0) (maref a 1) (maref a 2))))
|#
#|
(make-tests
vector-signed-byte-32
(letm ((intvec (vector-signed-byte-32 4))) ;(setf maref), maref
(setf (maref intvec 1) 77)
(maref intvec 1))
(letm ((intvec (vector-signed-byte-32 4))) ;(setf data)
(setf (data intvec) #(4 6 8 2))
(data intvec))
(letm ((intvec (vector-signed-byte-32 4))) ;set-zero
(set-zero intvec)
(data intvec))
(letm ((intvec (vector-signed-byte-32 4))) ;set-all
(set-all intvec 44)
(data intvec))
(letm ((intvec (vector-signed-byte-32 4))) ;set-basis
(set-basis intvec 1)
(data intvec))
(letm ((intvec (vector-signed-byte-32 #(1 2 3 4)))) ;vector-reverse
(vector-reverse intvec)
(data intvec))
(letm ((intvec (vector-signed-byte-32 #(-1 -12 8 3)))) ;gsl-min
(gsl-min intvec))
(letm ((intvec (vector-signed-byte-32 #(-1 -12 8 3)))) ;gsl-max
(gsl-max intvec))
(letm ((intvec (vector-signed-byte-32 #(-1 -12 8 3)))) ;gsl-minmax
(multiple-value-list (gsl-minmax intvec)))
(letm ((intvec (vector-signed-byte-32 #(-1 -12 8 3)))) ;gsl-min-index
(gsl-min-index intvec))
(letm ((intvec (vector-signed-byte-32 #(-1 -12 8 3)))) ;gsl-max-index
(gsl-max-index intvec))
(letm ((intvec (vector-signed-byte-32 #(-1 -12 8 3)))) ;gsl-minmax-index
(multiple-value-list (gsl-minmax-index intvec)))
(letm ((intvec1 (vector-signed-byte-32 #(1 2 3 4))) ;copy
(intvec2 (vector-signed-byte-32 4)))
(copy intvec2 intvec1)
(data intvec2))
(letm ((intvec1 (vector-signed-byte-32 #(1 2 3 4))) ;swap
(intvec2 (vector-signed-byte-32 #(5 6 7 8))))
(swap intvec2 intvec1)
(concatenate 'vector (data intvec1) (data intvec2)))
(letm ((intvec (vector-signed-byte-32 #(1 2 3 4)))) ;swap-elements
(swap-elements intvec 1 3)
(data intvec)))
|#
#|
(make-tests
vector-double
(letm ((vec (vector-double-float 3)))
(setf (maref vec 0) -3.21d0
(maref vec 1) 1.0d0
(maref vec 2) 12.8d0
(cl-invalid vec) t)
(data vec))
(letm ((vec (vector-double-float 3)))
(setf (data vec) #(-3.21d0 1.0d0 12.8d0))
(data vec))
(letm ((vec (vector-double-float #(-3.21d0 1.0d0 12.8d0))))
(data vec))
(letm ((base (vector-double-float 5)))
(set-basis base 1)
(data base))
(letm ((vec1 (vector-double-float #(-3.21d0 1.0d0 12.8d0)))
(vec2 (vector-double-float 3)))
(copy vec2 vec1)
(data vec2)))
|#
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment