;;; Lisplab, level0-interface.lisp ;;; Defines the dotted algebra and other fundamental 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 init-threads (num-threads) (:documentation "Request to use a certain number of threads for calculations.")) (defgeneric cleanup-threads () (:documentation "Kills unused threads and frees resources.")) (defgeneric vector-p (x) (:documentation "A vector is a object whose elements are accessible with vref.")) (defgeneric matrix-p (x) (:documentation "A matrix is a object whose elements are accesible with mref.")) (defgeneric copy (a) (:documentation "Copies the elements and structure, but ignore shared state, like fill pointers etc.")) (defgeneric convert (x type) (:documentation "Converts the object to the specified type. Non-destructive.")) (defgeneric .max (a b) (:documentation "Generialized max.")) (defgeneric .min (a b) (:documentation "Generialized min.")) (defgeneric .sgn (a) (:documentation "Generialized signum.")) (defgeneric .abs (a) (:documentation "Generialized abs.")) (defgeneric .re (a) (:documentation "Generialized realpart.")) (defgeneric .im (a) (:documentation "Generialized abs.")) (defgeneric .conj (a) (:documentation "Generalized conjugate.")) (defgeneric .complex (a b) (:documentation "Generalized complex.")) ;;; Binary operators (defgeneric .= (a b) (:documentation "Generalized =.")) (defgeneric ./= (a b) (:documentation "Generalized /=." )) (defgeneric .< (a b) (:documentation "Generalized <." )) (defgeneric .<= (a b) (:documentation "Generalized <=." )) (defgeneric .> (a b) (:documentation "Generalized >." )) (defgeneric .>= (a b) (:documentation "Generalized >=." )) (defgeneric .add (a b) (:documentation "Addes a and b elementwise. Called by .+")) (defgeneric .mul (a b) (:documentation "Multiplies a and b elementwise. Called by .*")) (defgeneric .div (a b) (:documentation "Divides a with b elementwise. Called by ./")) (defgeneric .sub (a b) (:documentation "Subtracts b from a elementwise. Called by .-")) (defgeneric .expt (a b) (:documentation "Rises a to power b elementwise. Called by .^")) (defgeneric .add! (a b)) (defgeneric .mul! (a b)) (defgeneric .div! (a b)) (defgeneric .sub! (a b)) (defgeneric .expt! (a b)) ;;; Ordinary functions (defgeneric .sin (x) (:documentation "Sine function : sin(x).")) (defgeneric .cos (x) (:documentation "Cosine function : cos(x).")) (defgeneric .tan (x) (:documentation "Tangent function : tan(x).")) (defgeneric .asin (x) (:documentation "Inverse sine function : asin(x).")) (defgeneric .acos (x) (:documentation "Inverse cosine function : acos(x).")) (defgeneric .atan (x) (:documentation "Inverse tangent function : atan(x).")) (defgeneric .ln (x) (:documentation "Logarithm function")) (defgeneric .exp (x) (:documentation "Exponential function : exp(x).")) (defgeneric .sqr (x) (:documentation "Square.")) (defgeneric .sqrt (x) (:documentation "Square root.")) (defgeneric .sinh (x) (:documentation "Hyperbolic sine function : sinh(x).")) (defgeneric .cosh (x) (:documentation "Hyperbolic cosine function : cosh(x).")) (defgeneric .tanh (x) (:documentation "Hyperbolic tangent function : tanh(x).")) (defgeneric .asinh (x) (:documentation "Inverse hyperbolic sine function : asinh(x).")) (defgeneric .acosh (x) (:documentation "Inverse hyperbolic cosine function : acosh(x).")) (defgeneric .atanh (x) (:documentation "Inverse hyperbolic tangent function : atanh(x).")) ;;; Special functions (defgeneric .Ai (x) ;; TODO: implement this bastard ) (defgeneric .besj (n x) (:documentation "Bessel functions of the first kind : J_n(x).")) (defgeneric .besy (n x) (:documentation "The Neumann function. Bessel functions of the second kind : Y_n(x).")) (defgeneric .besi (n x) (:documentation "Modified Bessel functions : I_n(x).")) (defgeneric .besk (n x) (:documentation "Modified Bessel functions : K_n(x).")) (defgeneric .besh1 (n x) (:documentation "Hankel function 1. Bessel functions of the third kind : H^(1)_n(x).")) (defgeneric .besh2 (n x) (:documentation "Hankel function 2. Bessel functions of the third kind : H^(2)_n(x).")) (defgeneric .erf (x) (:documentation "The error function : erf(x)")) (defgeneric .erfc (x) (:documentation "The complementary error function : erfc(x)")) (defgeneric .gamma (x) (:documentation "The gamma function : gamma(x)")) ;;; logical operations (defgeneric .not (a) (:documentation "The logical .not operation.")) (defgeneric .and (a b) (:documentation "The logical and operation.")) (defgeneric .nand (a b) (:documentation "The logical nand operation.")) (defgeneric .or (a b) (:documentation "The logical or operation.")) (defgeneric .nor (a b) (:documentation "The logical nor operation.")) (defgeneric .xor (a b) (:documentation "The logical xor operation."))