;;; Lisplab, level2-interface.lisp ;;; Level2 intefaces. ;;; 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. ;;; TODO sort and possibly move to other levels (in-package :lisplab) (defgeneric export-list (m) (:documentation "Exports the elements of the matrix to a list.")) (defgeneric import-list (m list) (:documentation "Imports the elements of the matrix from a list.")) (defgeneric .some (pred a &rest matrices) (:documentation "Generalizes some")) (defgeneric .every (pred a &rest matrices) (:documentation "Generalizes every.")) (defgeneric copy-contents (a b &optional converter) (:documentation "Copies all elements from a to b.")) ;;;; Single-element operations (defgeneric mmap (type f m &rest args) (:documentation "Generalization of map, where type = t gives output type equals type of m.")) (defgeneric mmap-into (result f m &rest args) (:documentation "Generalization of map-into.")) (defgeneric mfill (a value) (:documentation "Sets each element to the value. Destructive")) (defgeneric mmap-operator (f a b output) (:documentation "Calls the operator, e.g., .add, .mul, on the elements of the matrices.")) ;;; Helpers (defgeneric msum (m) (:documentation "Sums all matrix elements.")) (defgeneric mmin (m) (:documentation "Returns the smallest matrix element and its vector index.")) (defgeneric mmax (m) (:documentation "Returns the largest matrix element and its vector index.")) (defgeneric mabsmin (m) (:documentation "Returns the matrix element closest to zero and its vector index.")) (defgeneric mabsmax (m) (:documentation "Returns the matrix element with largest absolute value and its vector index.")) (defgeneric mminmax (m) (:documentation "Returns a list with (minimum maximum)")) (defgeneric mreverse (m) (:documentation "Reverts elements of matrix or vector. Similar to cl:reverse")) ;; Some vector functions (defgeneric vcross (a b) (:documentation "Cross product. Must be a vectors of length 3")) (defgeneric vdot (a b) (:documentation "Dot product of vectors")) (defgeneric vnorm (a) (:documentation "The vector norm"))