[lisplab-cvs] r101 - in src: io matrix

Jørn Inge Vestgården jivestgarden at common-lisp.net
Fri Oct 16 18:29:21 UTC 2009


Author: jivestgarden
Date: Fri Oct 16 14:29:21 2009
New Revision: 101

Log:
minor fix

Modified:
   src/io/level3-io.lisp
   src/matrix/level2-constructors.lisp

Modified: src/io/level3-io.lisp
==============================================================================
--- src/io/level3-io.lisp	(original)
+++ src/io/level3-io.lisp	Fri Oct 16 14:29:21 2009
@@ -25,6 +25,10 @@
 
 (in-package :lisplab)
 
+(defmethod dlmwrite ((x number) out &key (printer #'prin1) dlm)
+  (declare (ignore dlm))
+  (dlmwrite (dcol x) out :printer printer))
+
 (defmethod dlmwrite ((a matrix-base) 
 		     (stream stream)
 		     &key 
@@ -176,58 +180,3 @@
 	    (format out "~2,'0X" c)))
 	(format out "~%"))
       (format out "showpage~%"))))
-
-
-;;;; Trash
-
-
-#+nil (defun dlmwrite (a &optional (out t)
-		 &key 
-		 (dlm " ")
-		 (fmt "~S"))
-  "Write matrix as a delimited anscii test file."
-  (let* ((out (if (eq out t) *standard-output* out)))
-    (flet ((printit (out)
-	     (if (scalar? a)
-		 (prin1 a out)
-		 (progn
-		   (format out "~&")
-		   (dotimes (i (rows a))
-		     (dotimes (j (cols a))
-		       (format out fmt (mref a i j))
-		       (when (< j (1- (cols a)))
-			 (princ dlm out)))
-		     (when (< i (1- (rows a)))
-		       (princ #\Newline out))))))) 
-      (if (streamp out)
-	  (printit out)
-	  (with-open-file (out out :direction :output :if-exists :supersede)
-	    (printit out))))))
-
-#+nil (defun dlmread (class &optional (in t))
-  "Reads a delimited anscii test file and returns a matrix. Currently only space delimited."
-  ;; TODO: Fixit. Non-space formated matrices
-  (let* ((in (if (eq in t) *standard-input* in))
-	 (end (gensym))
-	 (rows nil))
-    (labels ((line (in) (let ((line (read-line in nil end nil)))
-			  (if (eq line end)
-			      end
-			      (if (eql (char line 0) #\#)
-				  (line in) 
-				  line))))
-	     (element (in) (read in nil end nil))
-	     (getit (in)
-	       (do ((line (line in) (line in)))
-		   ((eq line end))
-		 (let ((s (make-string-input-stream line))
-		       (cols nil))
-		   (do ((elm (element s) (element s)))
-		       ((eq elm end))
-		     (push elm cols))
-		   (push (reverse cols) rows)))))
-      (if (streamp in)
-	  (getit in)
-	  (with-open-file (in in :direction :input)
-	    (getit in))))
-    (convert (reverse rows) class)))

Modified: src/matrix/level2-constructors.lisp
==============================================================================
--- src/matrix/level2-constructors.lisp	(original)
+++ src/matrix/level2-constructors.lisp	Fri Oct 16 14:29:21 2009
@@ -148,6 +148,17 @@
   "Creates a matrix-zge matrix"
   (mnew 'matrix-zge value rows cols))
 
+(defun zgrid (xv yv)
+  (let* ((r (size xv))
+         (c (size yv))
+         (x (znew 0 r c))
+         (y (znew 0 r c)))
+    (dotimes (i r)
+      (dotimes (j c)
+        (setf (mref x i j) (vref xv i)
+              (mref y i j) (vref yv j))))
+    (list x y)))
+
 
 ;;; Function matrix
 
@@ -164,7 +175,7 @@
 		    :rows ,rows2
 		    :cols ,cols2
 		    :mref (lambda (self , at args) 
-			   #+cbcl(declare (sb-ext::muffle-conditions style-warning))  
+			   #+sbcl(declare (sb-ext::muffle-conditions style-warning))  
 			   , at body)
 		    :vref (lambda (self ,i)
 			    ;; Default self vector reference in column major order




More information about the lisplab-cvs mailing list