[lisplab-cvs] r193 - in trunk/src: matrix2 vector2

Jørn Inge Vestgården jivestgarden at common-lisp.net
Tue Nov 16 20:07:54 UTC 2010


Author: jivestgarden
Date: Tue Nov 16 15:07:54 2010
New Revision: 193

Log:
Change implmentation of matrix creation.

Modified:
   trunk/src/matrix2/level2-constructors.lisp
   trunk/src/vector2/level2-list.lisp

Modified: trunk/src/matrix2/level2-constructors.lisp
==============================================================================
--- trunk/src/matrix2/level2-constructors.lisp	(original)
+++ trunk/src/matrix2/level2-constructors.lisp	Tue Nov 16 15:07:54 2010
@@ -24,7 +24,6 @@
 
 (in-package :lisplab)
 
-
 ;;; Creates matrices with general structure, e.g., #md((1 2) (3 4))
 
 ;;; TODO: error check is important here!
@@ -104,16 +103,8 @@
 			value))
 
 (defun mmat (type x)
-  "Creates a matrix from the list of lists. 
-For a macro use #mm((..) (..) ..) instead."
-  (unless (consp (car x)) 
-    ;; It is a list. Create a column vector.
-    (setf x (mapcar #'list x)))
-  (let* ((cols (length (car x)))
-	 (rows (length x))
-	 (m (make-matrix-instance type (list rows cols) 0)))
-    (fill-matrix-with-list m x)
-    m))
+  "Creates a matrix from the supplied contents."
+  (convert x type))
 
 (defun mcol (type &rest args)
   "Creates a column matrix."
@@ -130,9 +121,8 @@
   (mmap t #'random (dnew 1d0 rows cols)))
 
 (defun dmat (args)
-  "Creates a matrix-dge from the list of lists. 
-For macro: use #md((..) (..) ..) instead."
-  (mmat 'matrix-dge args))
+  "Creates a matrix-dge from supplied contents."
+  (convert args 'matrix-dge))
 
 (defun dcol (&rest args)
   "Creates a matrix-dge column matrix."
@@ -192,9 +182,8 @@
 ;;; Constructors for matrix-zge
 
 (defun zmat (args)
-  "Creates a matrix-zge from the list of lists. 
-For macro: use #mz((..) (..) ..) instead."
-  (mmat 'matrix-zge args))
+  "Creates a matrix-zge from the supplied contents."
+  (convert args 'matrix-zge))
 
 (defun zcol (&rest args)
   "Creates a matrix-zge column matrix."

Modified: trunk/src/vector2/level2-list.lisp
==============================================================================
--- trunk/src/vector2/level2-list.lisp	(original)
+++ trunk/src/vector2/level2-list.lisp	Tue Nov 16 15:07:54 2010
@@ -22,7 +22,11 @@
 (in-package :lisplab)
 
 (defmethod convert ((x cons) type)
-  (mmat type x)) 
+  (let* ((cols (length (car x)))
+	 (rows (length x))
+	 (m (make-matrix-instance type (list rows cols) 0)))
+    (fill-matrix-with-list m x)
+    m))
 
 (defmethod .mul ((x cons) (y cons))
   (mapcar #'.mul x y))




More information about the lisplab-cvs mailing list