;;; Lisplab, level1-matrix-slice.lisp ;;; Vectors that are slice of matrices, i.e. row or column vectors. ;;; Copyright (C) 2009 Joern Inge Vestgaarden ;;; ;;; This program is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 2 of the License, or ;;; (at your option) any later version. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License along ;;; with this program; if not, write to the Free Software Foundation, Inc., ;;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. (in-package :lisplab) (defclass matrix-slice-base (vector-base) ((off :initarg :off :initform 0) (step :initarg :step :initform 0) (size :initarg :size :initform 0))) (defclass matrix-slice-any (matrix-slice-base) ((store :initarg :store :initform nil :reader vector-store))) (defclass matrix-slice-dge (matrix-slice-base) ((store :initarg :store :initform nil :reader type-blas-store))) ;;; Untyped matrix slices (defmethod vref ((vector matrix-slice-any) idx) (with-slots (store off step size) vector (aref store (column-major-idx off idx step)))) (defmethod (setf vref) (value (vector matrix-slice-any) idx) (with-slots (store off step size) vector (setf (aref store (column-major-idx off idx step)) value)) value) ;;; Double float matrix slices (defmethod vref ((vector matrix-slice-dge) idx) (with-slots (store off step size) vector (declare (type type-blas-store store)) (aref store (column-major-idx off idx step)))) (defmethod (setf vref) (value (vector matrix-slice-dge) idx) (with-slots (store off step size) vector (declare (type type-blas-store store)) (setf (aref store (column-major-idx off idx step)) value)) value)