;;; Lisplab, level1-zge.lisp ;;; General, complex double-float matrices ;;; 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) ;;; Complex double float general matrices (defclass matrix-base-zge (structure-general vector-z implementation-base) ()) (defmethod initialize-instance :after ((m matrix-base-zge) &key dim (value 0)) (with-slots (rows cols size store) m (setf rows (car dim) cols (cadr dim) size (* rows cols)) (unless store (setf store (allocate-complex-store size value))))) (defclass matrix-lisp-zge (implementation-lisp matrix-base-zge) () (:documentation "A full matrix (rows x cols) with complex double float elements. Executes in lisp only.")) (defclass matrix-foreign-zge (implementation-foreign matrix-lisp-zge) () (:documentation "A full matrix (rows x cols) with complex double float matrix elements. Executes in FFI if possible. If not it executes in lisp.")) (defclass matrix-zge (matrix-foreign-zge) () (:documentation "A full matrix (rows x cols) with complex double float matrix elements. Executes in FFI if possible. If not it executes in lisp.")) (defmethod make-matrix-class ((a (eql :z)) (b (eql :ge)) (c (eql :base))) (find-class 'matrix-base-zge)) (defmethod make-matrix-class ((a (eql :z)) (b (eql :ge)) (c (eql :lisp))) (find-class 'matrix-lisp-zge)) (defmethod make-matrix-class ((a (eql :z)) (b (eql :ge)) (c (eql :foreign))) (find-class 'matrix-zge)) (defmethod make-matrix-class ((a (eql :z)) (b (eql :ge)) (c (eql :any))) (find-class 'matrix-zge)) ;;; Level1 methods specialized for zge (defmethod print-object ((matrix matrix-base-zge) stream) (if (not *lisplab-print-size*) (call-next-method) (progn (format stream "~&#mz(" ) (print-matrix-contents matrix :stream stream :pr (if *lisplab-element-printer* *lisplab-element-printer* (lambda (x stream) (format stream "#c(~8,2g ~8,2g)" (realpart x) (imagpart x)))) :rmax (if (eq *lisplab-print-size* t) (rows matrix) *lisplab-print-size*) :cmax (if (eq *lisplab-print-size* t) (cols matrix) *lisplab-print-size*) :indent 4 :braket-p t) (format stream ")" )))) (defmethod mref ((matrix matrix-base-zge) row col) (ref-blas-complex-store (slot-value matrix 'store) row col (slot-value matrix 'rows))) (defmethod (setf mref) (value (matrix matrix-base-zge) row col) (let ((val2 (coerce value '(complex double-float)))) (declare (type (complex double-float) val2)) (setf (ref-blas-complex-store (slot-value matrix 'store) row col (slot-value matrix 'rows)) val2) val2))