;;;; level0-default.lisp ;;; Default implmenations for those generic functions that need such thing. ;;; 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) (defmethod type-spec (object) :any) (defmethod type-spec ((object float)) :d ;; Currently unable to handle single floats #+nil (typecase object (double-float :d) (t :f))) (defmethod type-spec ((object complex)) :z ;; Currently unable to handle complex single floats (typecase object ((complex double-float) :z) (t :c))) (defmethod function-output-type-spec (fun input-spec) ;; The default is the same as the input! input-spec) ;;; Some known exepctions (defmethod function-output-type-spec ((fun (eql '.ln)) (input-spec (eql :d))) :z) (defmethod function-output-type-spec ((fun (eql '.sqrt)) (input-spec (eql :d))) :z) (defmethod function-output-type-spec ((fun (eql '.asin)) (input-spec (eql :d))) :z) (defmethod function-output-type-spec ((fun (eql '.acos)) (input-spec (eql :d))) :z) (defmethod function-output-type-spec ((fun (eql '.atanh)) (input-spec (eql :d))) :z) (defmethod function-output-type-spec ((fun (eql '.besh1)) (input-spec (eql :d))) :z) (defmethod function-output-type-spec ((fun (eql '.besh2)) (input-spec (eql :d))) :z) (defmethod function-output-type-spec ((fun (eql '.re)) (input-spec (eql :z))) :d) (defmethod function-output-type-spec ((fun (eql '.im)) (input-spec (eql :z))) :d) (defmethod function-output-type-spec ((fun (eql '.abs)) (input-spec (eql :z))) :d) (defmethod operator-output-type-spec (fun input-spec1 input-spec2) ;; The default is the the argument spec input-spec1) (defmethod operator-output-type-spec (fun (a (eql :d)) (b (eql :z))) ;; If one is real, anohtother complex, guess complex :z) (defmethod operator-output-type-spec (fun (a (eql :z)) (b (eql :d))) ;; If one is real, anohtother complex, guess complex :z)