[lisplab-cvs] r133 - in trunk: . src/matrix
Jørn Inge Vestgården
jivestgarden at common-lisp.net
Tue Feb 23 19:58:51 UTC 2010
Author: jivestgarden
Date: Tue Feb 23 14:58:50 2010
New Revision: 133
Log:
mreverse function
Modified:
trunk/package.lisp
trunk/src/matrix/level2-generic.lisp
trunk/src/matrix/level2-interface.lisp
trunk/src/matrix/level2-matrix-dge.lisp
Modified: trunk/package.lisp
==============================================================================
--- trunk/package.lisp (original)
+++ trunk/package.lisp Tue Feb 23 14:58:50 2010
@@ -196,6 +196,7 @@
"SUB-MATRIX" ; To level3 ?
"CIRC-SHIFT"
"PAD-SHIFT"
+ "MREVERSE"
;; Matrix level 3
;; IO
Modified: trunk/src/matrix/level2-generic.lisp
==============================================================================
--- trunk/src/matrix/level2-generic.lisp (original)
+++ trunk/src/matrix/level2-generic.lisp Tue Feb 23 14:58:50 2010
@@ -215,6 +215,14 @@
(mref A (- i dr) (- j dc)))))
B))
+(defmethod mreverse ((A matrix-base))
+ (let ((B (mcreate A))
+ (len (size A)))
+ (dotimes (i len)
+ (setf (vref B (- len i 1))
+ (vref A i)))
+ B))
+
(defmethod export-list ((m matrix-base))
(let ((res nil))
(dotimes (i (size m))
Modified: trunk/src/matrix/level2-interface.lisp
==============================================================================
--- trunk/src/matrix/level2-interface.lisp (original)
+++ trunk/src/matrix/level2-interface.lisp Tue Feb 23 14:58:50 2010
@@ -139,3 +139,5 @@
(defgeneric pad-shift (m shifts &optional value)
(:documentation "Shifts the matrix and pads results"))
+(defgeneric mreverse (m)
+ (:documentation "Reverts elements of matrix or vector. Similar to cl:reverse"))
\ No newline at end of file
Modified: trunk/src/matrix/level2-matrix-dge.lisp
==============================================================================
--- trunk/src/matrix/level2-matrix-dge.lisp (original)
+++ trunk/src/matrix/level2-matrix-dge.lisp Tue Feb 23 14:58:50 2010
@@ -32,6 +32,13 @@
:store (copy-seq store)
:dim (dim matrix))))
+(defmethod mreverse ((matrix matrix-base-dge))
+ (let ((store (matrix-store matrix)))
+ (declare (type type-blas-store store))
+ (make-instance (class-name (class-of matrix))
+ :store (reverse store)
+ :dim (dim matrix))))
+
(defmethod copy-contents ((a matrix-base-dge) (b matrix-base-dge) &optional (converter nil))
(let ((store-a (matrix-store a))
(store-b (matrix-store b)))
More information about the lisplab-cvs
mailing list