[lisplab-cvs] r34 - in src: core matrix test
Jørn Inge Vestgården
jivestgarden at common-lisp.net
Thu May 21 19:40:40 UTC 2009
Author: jivestgarden
Date: Thu May 21 15:40:40 2009
New Revision: 34
Log:
added some more tests and some more exports
Modified:
src/core/level0-const.lisp
src/matrix/level1-classes.lisp
src/test/lisplab-test.lisp
Modified: src/core/level0-const.lisp
==============================================================================
--- src/core/level0-const.lisp (original)
+++ src/core/level0-const.lisp Thu May 21 15:40:40 2009
@@ -19,12 +19,15 @@
(in-package :lisplab)
+(export '(%i %e -%i))
+
;;; Float and complex constants
(define-constant %e (exp 1.0))
(define-constant %i #C(0.0 1.0))
(define-constant -%i #C(0.0 -1.0))
;;; Type constants
+;;; TODO: throw them out or use deftype in stead
(define-constant %df 'double-float)
(define-constant %cdf '(complex double-float))
(define-constant %sb32 '(signed-byte 32))
@@ -32,7 +35,9 @@
-;;;; Constants from gsl
+;;;; Constants from gsl.
+
+;;; TODO: throw them out
(define-constant +lisplab-dbl-epsilon+ 2.2204460492503131e-16)
(define-constant +lisplab-sqrt-dbl-epsilon+ 1.4901161193847656e-08)
Modified: src/matrix/level1-classes.lisp
==============================================================================
--- src/matrix/level1-classes.lisp (original)
+++ src/matrix/level1-classes.lisp Thu May 21 15:40:40 2009
@@ -23,6 +23,13 @@
(in-package :lisplab)
+(export '(matrix-base
+ matrix-dge
+ matrix-zge
+ function-matrix
+ ;; Do we need the others?
+ ))
+
(defclass matrix-base () ())
;;; The matrix element tells the element type of the matrix
Modified: src/test/lisplab-test.lisp
==============================================================================
--- src/test/lisplab-test.lisp (original)
+++ src/test/lisplab-test.lisp Thu May 21 15:40:40 2009
@@ -1,102 +1,36 @@
-(defpackage "LISPLAB.TEST"
+#+nil (defpackage "LISPLAB.TEST"
(:use "COMMON-LISP" "ORG.ANCAR.CLUNIT"))
-(in-package :lisplab.test)
+(in-package :org.ancar.CLUnit)
-(defparameter *a22* #2a((1 4) (1 -2)))
-(defparameter *a33* #2a((1 4 7) (3 4 2) (1 -2 -8)))
+#+nil (in-package :lisplab.test)
-(defparameter *r22* (ll:rmat (1 4) (1 -2)))
-(defparameter *r33* (ll:rmat (1 4 7) (3 4 2) (1 -2 -8)))
-
-(defparameter *c22* (ll:cmat (1 4) (1 -2)))
-(defparameter *c33* (ll:cmat (1 4 7) (3 4 2) (1 -2 -8)))
-
-(deftest "level0 .="
- :test-fn (lambda ()
- (ll:.= 0 0)
- (ll:.= 42 42.0)
- (ll:.= 'x 'x)))
-
-(deftest "level0 .+"
- :test-fn (lambda ()
- (= 4 (ll:.+ 0 4))
- (= 7 (ll:.+ 3 4))
- (= 0.5 (ll:.+ 1 -0.25 -0.25))
- (= 10.3 (ll:.+ 6.3 4))
- (= 3/4 (ll:.+ 1/2 1/4))
- ))
-
-(deftest "level0 .-"
- :test-fn (lambda ()
- (= -4 (ll:.- 0 4))
- (= -1 (ll:.- 3 4))
- (= 1.5 (ll:.- 1 -0.25 -0.25))
- (= 2.3 (ll:.- 6.3 4))
- (= 1/4 (ll:.- 1/2 1/4))
- ))
-
-(deftest "level0 .*"
+(deftest "level1-dge-new"
:test-fn (lambda ()
- (= 0 (ll:.* 0 4))
- (= 12 (ll:.* 3 4))
- (= 1.5 (ll:.* 1 -0.25 -6))
- (= 26 (ll:.* 6.5 4))
- (= 12/10 (ll:.* 4/5 3/2))
- ))
+ (and
+ (equalp (ll:dim (ll:mnew 'll:matrix-dge 0 3 7)) '(3 7))
+ (equalp (ll:dim (ll:mnew '(:d :ge :any) 0 3 7)) '(3 7))
+ (equalp (ll:dim (ll:dnew 0 3 7)) '(3 7)))))
-(deftest "level0 ./"
+(deftest "level1-zge-new"
:test-fn (lambda ()
- (= 0 (ll:./ 0 4))
- (= 3/4 (ll:./ 3 4))
- (= 1.5 (ll:./ 1 -0.25 -6))
- (= 26 (ll:./ 6.5 4))
- (= 8/15 (ll:./ 4/5 3/2))
- ))
+ (and
+ (equalp (ll:dim (ll:mnew 'll:matrix-zge 0 3 7)) '(3 7))
+ (equalp (ll:dim (ll:mnew '(:z :ge :any) 0 3 7)) '(3 7))
+ (equalp (ll:dim (ll:znew 0 3 7)) '(3 7)) )))
-(deftest "level0 .^"
+(deftest "level1-dge-mref"
:test-fn (lambda ()
- (= 1 (ll:.^ 7 0))
- (= 64 (ll:.^ 4 3))
- (= 15.620749173070115 (ll:.^ 2.3 3.3))
- (= 9/49 (ll:.^ 3/7 2))
- ))
+ (let ((A (ll:dnew 42 3 7)))
+ (setf (ll:mref A 2 2) 7)
+ (and (= 42 (ll:mref A 0 1))
+ (= 7 (ll:mref A 2 2))))))
-(deftest "level1 blas-real"
+(deftest "level1-zge-mref"
:test-fn (lambda ()
- (let ((x1 (ll:rnew 1 3 4))
- (x2 (ll:rmat (4 3) (-1 4)))
- (c1 (ll:rrow 2 7 8))
- (c2 (ll:rcol 3 2 4)))
- (and (= 1 (ll:vref x1 1))
- (= -1 (ll:vref x2 1)) ; row major order
- (= 8 (ll:mref c1 0 2))
- (= 4 (ll:mref c2 2 0))
- (= 3 (ll:mref x2 0 1))))))
-
-(deftest "level1 blas-complex"
- :test-fn (lambda ()
- (let ((x1 (ll:cnew 1 3 4))
- (x2 (ll:cmat (4 3) (-1 4)))
- (c1 (ll:crow 2 7 8))
- (c2 (ll:ccol 3 2 4)))
- (and (= 1 (ll:vref x1 1))
- (= -1 (ll:vref x2 1)) ; row major order
- (= 8 (ll:mref c1 0 2))
- (= 4 (ll:mref c2 2 0))
- (= 3 (ll:mref x2 0 1))))))
-
-(deftest "level1 array"
- :test-fn (lambda ()
- (let ((x2 #2a((4 3) (-1 4)))
- (c1 #a(2 7 8)))
- (and (= 1 (ll:vref x1 1))
- (= -1 (ll:vref x2 1)) ; row major order
- (= 8 (ll:mref c1 0 2))
- (= 4 (ll:mref c2 2 0))
- (= 3 (ll:mref x2 0 1))))))
-
-
-
+ (let ((A (ll:znew ll:%i 3 7)))
+ (setf (ll:mref A 2 2) 7)
+ (and (= ll:%i (ll:mref A 0 1))
+ (= 7 (ll:mref A 2 2))))))
\ No newline at end of file
More information about the lisplab-cvs
mailing list