;;; Lisplab, level3-linalg-interface.lisp ;;; Matrix generic functions. ;;; 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) (defgeneric mtp (matrix) (:documentation "Matrix transpose.")) (defgeneric mtp! (matrix) (:documentation "Matrix transpose. Destructive.")) (defgeneric mct (matrix) (:documentation "Matrix conjugate transpose.")) (defgeneric mct! (matrix) (:documentation "Matrix conjugate transpose. Destructive.")) (defgeneric mtr (matrix) (:documentation "Matrix trace (sum of diagonal elements).")) (defgeneric mdet (matrix) (:documentation "Matrix determinant.") (:method :before (m) (assert (= (rows m) (cols m))))) (defgeneric minv! (a) (:documentation "Matrix inverse. Destructive.")) (defgeneric minv (a) (:documentation "Matrix inverse.") (:method :before (m) (assert (= (rows m) (cols m))))) (defgeneric m* (a b) (:documentation "Matrix multiplication.") (:method :before (a b) (assert (= (cols a) (rows b))))) (defgeneric m*! (a b) (:documentation "Matrix product. Destructive.")) (defgeneric m/ (a b) (:documentation "Short for (m* a (minv b)).")) (defgeneric m/! (a b) (:documentation "Short for (m*! a (minv b)). Destructive.")) (defgeneric LU-factor! (matrix pivotes) (:documentation "LU-factorization with pivoting. Destructive. Ouputs a combined LU matrix where the diagonals belong to U and a permutation vector.")) (defgeneric LU-factor (matrix) (:documentation "LU-factorization with pivoting. Outputs (L U P) where L is low diagonal with unity at diagnoals, U is upper diagnoal and P is an permutation matrix, so that A = P L U.")) (defgeneric LU-solve! (LU x) (:documentation "Solves the linear equation system LUx=b, where LU is an output from LU-factor!.")) (defgeneric lin-solve (A b) (:documentation "Solves the linear system of equations Ax=b.")) (defgeneric eigenvectors (a) (:documentation "Returns (P d) where P is matrix of right eigenvector and d is a vector of eigenvalues.")) (defgeneric eigenvalues (a) (:documentation "Returns the vector of eigenvalues."))