;;; 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-user) (defgeneric sub-matrix (m rr cc) (:documentation "Copies a sub matrix of m. The format of rr = (start stop) or rr = (start step stop) and the same for the columns.")) (defgeneric mnew (class value rows &optional cols) (:documentation "General matrix constructor. Creates a new matrix filled with numeric arguments.")) (defgeneric mcreate (a &optional value dim) (:documentation "Creates a new matrix of the same type and with the same value as the other, but with all elements set to value.")) (defgeneric mcreate* (a &key value dim element-type structure implementation) (:documentation "Extended version of mcreate. Creates a new matrix of the same type and with the same value as the other, but with all elements set to value.")) (defgeneric diag (v) (:documentation "Creates a diagnoal matrix from the vector.")) (defgeneric to-vector! (a) (:documentation "Reshape the object to 1D. Destructive")) (defgeneric to-vector (a) (:documentation "Reshape the object to 1D")) (defgeneric to-matrix! (a rows) (:documentation "Reshape the object to 2D. Destructive")) (defgeneric to-matrix (a rows) (:documentation "Reshape the object to 2D")) (defgeneric reshape! (a shape) (:documentation "Reshapes the object. Detructive")) (defgeneric reshape (a shape) (:documentation "Reshapes the object")) (defgeneric get-row! (matrix row) (:documentation "Gets rows. Destructive")) (defgeneric get-row (matrix row) (:documentation "Gets rows. Destructive")) (defgeneric get-col! (matrix col) (:documentation "Gets rows. Destructive")) (defgeneric get-col (matrix col) (:documentation "Gets rows. Destructive")) ;;; Row operations. TODO remove these (defgeneric row-swap! (matrix i j) (:documentation "Swaps row i and j of matrix. Destructive.")) (defgeneric row-mul! (matrix i number) (:documentation "Multiplies row i with number. Destructive.")) (defgeneric row-add! (matrix i j number) (:documentation "Adds a multiplicum of row j to row i. A_ic=A_ic+number*A_jc. Destructive.")) ;;; Column operations. (defgeneric col-swap! (matrix i j) (:documentation "Swaps row i and j of matrix. Destructive.")) (defgeneric col-smul! (matrix i number) (:documentation "Multiplies row i with a scalar. Destructive.")) (defgeneric col-sum (matrix i) (:documentation "Multiplies row i with a scalar. Destructive.")) (defgeneric col-col-mul-sum (a i b j) (:documentation "The dot product of column i of a and column j of b.")) ;;;; Views (defgeneric view-row (matrix row) (:documentation "Returns a shared structure view of the row")) (defgeneric view-col (matrix col) (:documentation "Returns a shared structure view of the row")) (defgeneric view-matrix (matrix dim &optional (type)) (:documentation "Returns a shared structure view of the matrix")) (defgeneric view-transpose (a) (:documentation "Returns a transposed matrix with same (shared) elements")) (defgeneric circ-shift (m shifts) (:documentation "Shifts the matrix with periodic indices")) (defgeneric pad-shift (m shifts &optional value) (:documentation "Shifts the matrix and pads results"))