[lisplab-cvs] r122 - in src: core matrix

Jørn Inge Vestgården jivestgarden at common-lisp.net
Sun Dec 13 15:17:43 UTC 2009


Author: jivestgarden
Date: Sun Dec 13 10:17:43 2009
New Revision: 122

Log:
changed function matrix constructors from macro to function

Modified:
   src/core/level0-permutation.lisp
   src/matrix/level2-constructors.lisp

Modified: src/core/level0-permutation.lisp
==============================================================================
--- src/core/level0-permutation.lisp	(original)
+++ src/core/level0-permutation.lisp	Sun Dec 13 10:17:43 2009
@@ -1,4 +1,4 @@
-;;; Level2-funmat.lisp 
+;;; Level2-permutations.lisp 
 ;;; Permutation of matrix indices. 
 
 ;;; Copyright (C) 2009 Joern Inge Vestgaarden

Modified: src/matrix/level2-constructors.lisp
==============================================================================
--- src/matrix/level2-constructors.lisp	(original)
+++ src/matrix/level2-constructors.lisp	Sun Dec 13 10:17:43 2009
@@ -180,28 +180,24 @@
 
 ;;; Function matrix
 
-(defmacro funmat (dim args &body body)
-  "Creates a read only function matrix"
-  (let ((rows2 (gensym "rows"))
-	(cols2 (gensym "cols"))
-	(i (gensym))
-	(r (gensym))
-	(c (gensym)))
-  `(let ((,rows2 (first ,dim))
-	 (,cols2 (second ,dim)))
-     (make-instance 'function-matrix 
-		    :rows ,rows2
-		    :cols ,cols2
-		    :mref (lambda (self , at args) 
-			   #+sbcl(declare (sb-ext::muffle-conditions style-warning))  
-			   , at body)
-		    :vref (lambda (self ,i)
-			    ;; Default self vector reference in column major order
-			    (multiple-value-bind (,r ,c) (floor ,i ,rows2)
-			      (mref self ,r ,c)))))))
+(defun funmat (dim fun)
+  "Creates a read only function matrix with column major order."
+  (let ((rows (first dim))
+	(cols (second dim)))
+    (make-instance 'function-matrix 
+		   :rows rows
+		   :cols cols
+		   :mref (lambda (self i j) 			   			   
+			   (funcall fun i j))
+		   :vref (lambda (self i)
+			   (multiple-value-bind (c r)			       
+			       (floor i rows)
+			     (funcall fun r c))))))
 
-(defmacro fmat (type dim args &body body)
-  `(convert (funmat ,dim ,args , at body)
-	    ,type))
+(defun fmat (type dim fun)
+  "Creates a matrix of of type type, dim dim from the function definition. 
+Row major order"
+  (convert (funmat dim fun)
+	    type))
 
 




More information about the lisplab-cvs mailing list