[lisplab-cvs] r194 - trunk/src/matrix2
Jørn Inge Vestgården
jivestgarden at common-lisp.net
Tue Nov 16 20:52:33 UTC 2010
Author: jivestgarden
Date: Tue Nov 16 15:52:32 2010
New Revision: 194
Log:
Implmented generic get-row and get-col
Modified:
trunk/src/matrix2/matrix2-generic.lisp
Modified: trunk/src/matrix2/matrix2-generic.lisp
==============================================================================
--- trunk/src/matrix2/matrix2-generic.lisp (original)
+++ trunk/src/matrix2/matrix2-generic.lisp Tue Nov 16 15:52:32 2010
@@ -51,7 +51,7 @@
(setf (mref b i j) (funcall converter (mref a i j))))
b))
-(defmethod sub-matrix (m rr cc)
+(defmethod sub-matrix ((m matrix-base) rr cc)
(unless (cddr rr)
(setf rr (cons (car rr) (cons 1 (cdr rr)))))
(unless (cddr cc)
@@ -68,9 +68,17 @@
(dotimes (i rows)
(dotimes (j cols)
(setf (mref m1 i j)
- (mref m (+ r0 (* r-step i)) (+ c0 (* c-step j))))))
+ (mref m
+ (+ r0 (* r-step i))
+ (+ c0 (* c-step j))))))
m1))))
+(defmethod get-row ((m matrix-base) row)
+ (sub-matrix m (list row row) (list 0 (1- (cols m)))))
+
+(defmethod get-col ((m matrix-base) col)
+ (sub-matrix m (list 0 (1- (rows m))) (list col col)))
+
(defmethod circ-shift ((A matrix-base) shift)
;; TODO move to level3
(let ((B (mcreate A))
More information about the lisplab-cvs
mailing list