Commit 1518473a authored by Liam Healy's avatar Liam Healy

Tests for BLAS2 and BLAS3

Added tests for all array element types for BLAS2 and BLAS3.  Those
functions that take complex scalars as arguments will not work due to
CFFI's lack of support for passing structs directly.  The rank n
update functions in BLAS2 gives an "Matrix, vector lengths are not
conformant" error (EBADLEN), which needs to be tracked down.
Therefore, none of these tests are defined in either file.  Fixed
arguments to C function in #'matrix-product-symmetric and
#'inverse-matrix-product in BLAS3.
parent 4c095d18
;; BLAS level 2, Matrix-vector operations
;; Liam Healy, Wed Apr 26 2006 - 21:08
;; Time-stamp: <2008-08-09 19:43:20EDT blas2.lisp>
;; Time-stamp: <2008-11-09 18:15:43EST blas2.lisp>
;; $Id$
(in-package :gsl)
......@@ -25,6 +25,7 @@
;;;; Functions
;;;;****************************************************************************
;;; To do: the y should be an optional argument, default to a zero vector.
(defmfun matrix-product
((A matrix) (x vector) (y vector)
&optional (alpha 1) (beta 1) (TransA :notrans) TransB)
......@@ -142,6 +143,8 @@
(defmfun matrix-product-hermitian
((A matrix) (x vector) (y vector)
&optional (alpha 1) (beta 1) (uplo :upper) (side :left))
;; This always signals an error because you can't pass a
;; struct in CFFI yet.
("gsl_blas_" :type "hemv")
((uplo cblas-uplo) (alpha :element-c-type) ((mpointer A) :pointer)
((mpointer x) :pointer) (beta :element-c-type) ((mpointer y) :pointer))
......@@ -305,3 +308,51 @@
;;;; Examples and unit test
;;;;****************************************************************************
(generate-all-array-tests matrix-product :float-complex
(letm ((m1 (array-default '(3 3)))
(v1 (array-default 3))
(answer (array-default 3 t))
(s1 (scalar-default))
(s2 (scalar-default)))
(cl-array (matrix-product m1 v1 answer s1 s2))))
(generate-all-array-tests matrix-product-triangular :float-complex
(letm ((m1 (array-default '(3 3)))
(v1 (array-default 3))
(s1 (scalar-default)))
(cl-array (matrix-product-triangular m1 v1 s1))))
(generate-all-array-tests inverse-matrix-product :float-complex
(letm ((m1 (array-default '(3 3)))
(v1 (array-default 3))
(s1 (scalar-default)))
(cl-array (inverse-matrix-product m1 v1 s1))))
(generate-all-array-tests matrix-product-symmetric :float
(letm ((m1 (array-default '(3 3)))
(v1 (array-default 3))
(answer (array-default 3 t))
(s1 (scalar-default))
(s2 (scalar-default)))
(cl-array (matrix-product-symmetric m1 v1 answer s1 s2))))
(generate-all-array-tests matrix-product-hermitian :complex
(letm ((m1 (array-default '(3 3)))
(v1 (array-default 3))
(answer (array-default 3 t))
(s1 (scalar-default))
(s2 (scalar-default)))
(cl-array (matrix-product-hermitian m1 v1 answer s1 s2))))
#|
;;; Error, needs to be tracked down
;;; Matrix, vector lengths are not conformant invalid length in blas.c at line 1013
;;; [Condition of type EBADLEN]
(generate-all-array-tests rank-1-update :float-complex
(letm ((m1 (array-default '(3 3)))
(v1 (array-default 3))
(v2 (array-default 3))
(s1 (scalar-default)))
(cl-array (rank-1-update s1 v1 v2 m1))))
|#
;; BLAS level 3, Matrix-matrix operations
;; Liam Healy, Wed Apr 26 2006 - 21:08
;; Time-stamp: <2008-08-23 19:49:54EDT blas3.lisp>
;; Time-stamp: <2008-11-09 18:12:05EST blas3.lisp>
;; $Id$
(in-package :gsl)
......@@ -35,7 +35,8 @@
&optional (alpha 1) (beta 1) (uplo :upper) (side :left))
("gsl_blas_" :type "symm")
((side cblas-side) (uplo cblas-uplo) (alpha :element-c-type)
(A :pointer) (B :pointer) (beta :element-c-type) (C :pointer))
((mpointer A) :pointer) ((mpointer B) :pointer)
(beta :element-c-type) ((mpointer C) :pointer))
:definition :methods
:element-types :float-complex
:inputs (A B C)
......@@ -45,6 +46,8 @@
(defmfun matrix-product-hermitian
((A matrix) (B matrix) (C matrix)
&optional (alpha 1) (beta 1) (uplo :upper) (side :left))
;; This always signals an error because you can't pass a
;; struct in CFFI yet.
("gsl_blas_" :type "hemm")
((side cblas-side) (uplo cblas-uplo) (alpha :element-c-type)
((mpointer A) :pointer) ((mpointer B) :pointer)
......@@ -73,9 +76,12 @@
((A matrix) (B matrix)
&optional (alpha 1) (uplo :upper) (TransA :notrans)
(diag :nonunit) (side :left))
;; This signals an error for complex arguments because you can't pass a
;; struct in CFFI yet.
("gsl_blas_" :type "trsm")
((uplo cblas-uplo) (TransA cblas-transpose) (diag cblas-diag)
((mpointer A) :pointer) ((mpointer B) :pointer))
((side cblas-side) (uplo cblas-uplo)
(TransA cblas-transpose) (diag cblas-diag)
(alpha :element-c-type) ((mpointer A) :pointer) ((mpointer B) :pointer))
:definition :methods
:element-types :float-complex
:inputs (A B)
......@@ -140,3 +146,38 @@
;;;; Examples and unit test
;;;;****************************************************************************
(generate-all-array-tests matrix-product :float-complex
(letm ((m1 (array-default '(3 3)))
(m2 (array-default '(3 3)))
(answer (array-default '(3 3) t))
(s1 (scalar-default))
(s2 (scalar-default)))
(cl-array (matrix-product m1 m2 answer s1 s2))))
(generate-all-array-tests matrix-product-triangular :float-complex
(letm ((m1 (array-default '(3 3)))
(m2 (array-default '(3 3)))
(s1 (scalar-default)))
(cl-array (matrix-product-triangular m1 m2 s1))))
(generate-all-array-tests inverse-matrix-product :float-complex
(letm ((m1 (array-default '(3 3)))
(m2 (array-default '(3 3)))
(s1 (scalar-default)))
(cl-array (inverse-matrix-product m1 m2 s1))))
(generate-all-array-tests matrix-product-symmetric :float
(letm ((m1 (array-default '(3 3)))
(m2 (array-default '(3 3)))
(answer (array-default '(3 3) t))
(s1 (scalar-default))
(s2 (scalar-default)))
(cl-array (matrix-product-symmetric m1 m2 answer s1 s2))))
(generate-all-array-tests matrix-product-hermitian :complex
(letm ((m1 (array-default '(3 3)))
(m2 (array-default '(3 3)))
(answer (array-default '(3 3) t))
(s1 (scalar-default))
(s2 (scalar-default)))
(cl-array (matrix-product-hermitian m1 m2 answer s1 s2))))
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