;;; Lisplab, level2-list.lisp ;;; Basic algebra stuff for lists ;;; 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. ;;; Should it be somewhere else. It has nothing to do with matrices, really. (in-package :lisplab) (defmethod convert ((x cons) type) (let* ((cols (length (car x))) (rows (length x)) (m (make-matrix-instance type (list rows cols) 0))) (fill-matrix-with-list m x) m)) (defmethod .mul ((x cons) (y cons)) (mapcar #'.mul x y)) (defmethod .mul ((x cons) (y number)) (mapcar (lambda (x) (.mul x y)) x)) (defmethod .mul ((x number) (y cons)) (mapcar (lambda (y) (.mul x y)) y)) (defmethod .add ((x cons) (y cons)) (mapcar #'.add x y)) (defmethod .add ((x cons) (y number)) (mapcar (lambda (x) (.add x y)) x)) (defmethod .add ((x number) (y cons)) (mapcar (lambda (y) (.add x y)) y)) (defmethod .sub ((x cons) (y cons)) (mapcar #'.sub x y)) (defmethod .sub ((x cons) (y number)) (mapcar (lambda (x) (.sub x y)) x)) (defmethod .sub ((x number) (y cons)) (mapcar (lambda (y) (.sub x y)) y)) (defmethod .div ((x cons) (y cons)) (mapcar #'.div x y)) (defmethod .div ((x cons) (y number)) (mapcar (lambda (x) (.div x y)) x)) (defmethod .div ((x number) (y cons)) (mapcar (lambda (y) (.div x y)) y)) (defmethod .expt ((x cons) (y cons)) (mapcar #'.expt x y)) (defmethod .expt ((x cons) (y number)) (mapcar (lambda (x) (.expt x y)) x)) (defmethod .expt ((x number) (y cons)) (mapcar (lambda (y) (.expt x y)) y))