;;; Lisplab, level2-generic.lisp ;;; Level2, non-specialized methods for 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) (defmacro def-each-element-function (name) (let ((a (gensym))) `(defmethod ,name ((,a vector-base)) (mmap t #',name ,a)))) (define-constant +ordinary-functions-number-to-number-list+ '(.sin .cos .tan .asin .acos .atan .sinh .cosh .tanh .asinh .acosh .atanh .re .im .abs .sgn .exp .ln .sqr .sqrt .conj .not)) (defmacro expand-each-element-ordinary-functions () (cons 'progn (mapcar (lambda (name) `(def-each-element-function ,name)) +ordinary-functions-number-to-number-list+ ))) (expand-each-element-ordinary-functions) ;;; Some special functions. Should maybe be separated out. (defmethod .erf ((a vector-base)) (mmap t #'.erf a)) (defmethod .erfc ((a vector-base)) (mmap t #'.erfc a)) (defmethod .gamma ((a vector-base)) (mmap t #'.gamma a)) (defmethod .besj (n (a vector-base)) (mmap t #'(lambda (x) (.besj n x)) a)) (defmethod .besj (n (a vector-base)) (mmap t #'(lambda (x) (.besj n x)) a)) (defmethod .besj (n (a vector-base)) (mmap t #'(lambda (x) (.besj n x)) a)) (defmethod .besy (n (a vector-base)) (mmap t #'(lambda (x) (.besy n x)) a)) (defmethod .besi (n (a vector-base)) (mmap t #'(lambda (x) (.besi n x)) a)) (defmethod .besk (n (a vector-base)) (mmap t #'(lambda (x) (.besk n x)) a)) (defmethod .besh1 (n (a vector-base)) (mmap t #'(lambda (x) (.besh1 n x)) a)) (defmethod .besh2 (n (a vector-base)) (mmap t #'(lambda (x) (.besh2 n x)) a))