[lisplab-cvs] r76 - src/matrix

Jørn Inge Vestgården jivestgarden at common-lisp.net
Sat Aug 8 18:26:56 UTC 2009


Author: jivestgarden
Date: Sat Aug  8 14:26:56 2009
New Revision: 76

Log:
Refactored function names

Modified:
   src/matrix/level2-generic.lisp
   src/matrix/level2-interface.lisp
   src/matrix/level2-matrix-dge.lisp

Modified: src/matrix/level2-generic.lisp
==============================================================================
--- src/matrix/level2-generic.lisp	(original)
+++ src/matrix/level2-generic.lisp	Sat Aug  8 14:26:56 2009
@@ -79,6 +79,12 @@
       (return-from .every nil)))
   t)
       
+(defmethod mmap ((type (eql t)) f (a matrix-base) &rest args)
+  (apply #'mmap (type-of a) f a args)) 
+
+(defmethod mmap ((type symbol) f (a matrix-base) &rest args)
+  (apply #'mmap (find-class type) f a args)) 
+
 (defmethod mmap (type f (a matrix-base) &rest args)  
   (let ((b (make-matrix-instance type (dim a) 0)))
     (cond ((not args)
@@ -95,7 +101,7 @@
 					       args))))))
     b))
 
-(defmethod .map (f (a matrix-base) &rest args)
+#+nil (defmethod .map (f (a matrix-base) &rest args)
   (apply #'mmap (class-name (class-of a)) f a args))
 
 (defmethod msum ((m matrix-base))

Modified: src/matrix/level2-interface.lisp
==============================================================================
--- src/matrix/level2-interface.lisp	(original)
+++ src/matrix/level2-interface.lisp	Sat Aug  8 14:26:56 2009
@@ -27,7 +27,8 @@
 	  mnew 
 	  mcreate
 	  copy-contents 
-	  .map mmap mfill	   
+;         .map 
+	  mmap mfill	   
 ;	  dlmwrite dlmread 
 	  to-vector! to-vector
 	  to-matrix! to-matrix
@@ -139,15 +140,16 @@
 ;;;; Single-element operations
 
 (defgeneric mmap (type f m &rest args)
-  (:documentation "Generalization of map"))
-
-(defgeneric .map (f m &rest rest)
-  (:documentation "Maps the function on each element. The returned 
-object has dimensionality of the first object"))
+  (:documentation "Generalization of map, where type = t gives output 
+type equals type of m."))
 
 (defgeneric mfill (a value)
   (:documentation "Sets each element to the value. Destructive"))
 
+#+nil (defgeneric .map (f m &rest rest)
+  (:documentation "Maps the function on each element. The returned 
+object has dimensionality of the first object"))
+
 
 ;;; Helpers
 

Modified: src/matrix/level2-matrix-dge.lisp
==============================================================================
--- src/matrix/level2-matrix-dge.lisp	(original)
+++ src/matrix/level2-matrix-dge.lisp	Sat Aug  8 14:26:56 2009
@@ -31,7 +31,16 @@
 		 :rows (rows matrix)
 		 :cols (cols matrix)))
 
-(defmethod .map (f (a matrix-base-dge) &rest args)
+(defmethod mmap ((type matrix-base-dge) f (a matrix-base-dge) &rest args)
+  (let ((b (copy a)))
+    (apply #'map-into 
+	   (matrix-store b) 
+	   (lambda (&rest args)
+	     (coerce (apply f args) 'double-float))
+	   (matrix-store a) (mapcar #'matrix-store args))
+    b))
+
+#+nil (defmethod .map (f (a matrix-base-dge) &rest args)
   (let ((b (copy a)))
     (apply #'map-into 
 	   (matrix-store b) 




More information about the lisplab-cvs mailing list