Commit 149844bb authored by Liam Healy's avatar Liam Healy

Complex functions

Additional definition of functions of complex numbers and/or returning
complex numbers.  Most of these duplicate functions that Lisp has
already, so everything is defined with a "cx-" prefix.  No effort has
been made to unify the interface; this requires some thought.  A fix
has been made to body-expand; previously, it would not properly
compile a function that returned a structure by value but didn't have
structures by value as arguments.
parent da11ae0a
;; Expand the body of a defmfun
;; Liam Healy 2009-04-13 22:07:13EDT body-expand.lisp
;; Time-stamp: <2009-05-03 16:31:28EDT body-expand.lisp>
;; Time-stamp: <2009-05-03 17:59:45EDT body-expand.lisp>
;; $Id: $
(in-package :gsl)
......@@ -96,7 +96,8 @@
(lambda (s)
(member s (arglist-plain-and-categories arglist nil)))
(variables-used-in-c-arguments c-arguments))))
(pbv (variables-passed-by-value c-arguments)) ; passed by value
(pbv ; passed by value
(variables-passed-by-value (cons creturn-st c-arguments)))
(clret (or ; better as a symbol macro
(substitute
(st-symbol creturn-st) :c-return
......
;; Functions of complex numbers
;; Liam Healy 2009-01-13 21:19:38EST complex.lisp
;; Time-stamp: <2009-01-15 14:14:07EST complex.lisp>
;; Time-stamp: <2009-05-03 18:13:48EDT complex.lisp>
;; $Id: $
(in-package :gsl)
;; /usr/include/gsl/gsl_complex_math.h
;;;;****************************************************************************
;;; Properties
;;;;****************************************************************************
......@@ -39,4 +41,302 @@
;;;;****************************************************************************
;;; The GSL functions provided duplicate what CL has built-in.
;;; These should have better thought-out names, but it's not clear
;;; that this will ever be used, because CL already does this.
(defmfun cx-add (c1 c2)
"gsl_complex_add"
((c1 complex-double-c) (c2 complex-double-c))
:c-return complex-double-c)
(defmfun cx-sub (c1 c2)
"gsl_complex_sub"
((c1 complex-double-c) (c2 complex-double-c))
:c-return complex-double-c)
(defmfun cx-mul (c1 c2)
"gsl_complex_mul"
((c1 complex-double-c) (c2 complex-double-c))
:c-return complex-double-c)
(defmfun cx-div (c1 c2)
"gsl_complex_div"
((c1 complex-double-c) (c2 complex-double-c))
:c-return complex-double-c)
(defmfun cx-add-real (c1 num)
"gsl_complex_add_real"
((c1 complex-double-c) (num :double))
:c-return complex-double-c)
(defmfun cx-sub-real (c1 num)
"gsl_complex_sub_real"
((c1 complex-double-c) (num :double))
:c-return complex-double-c)
(defmfun cx-mul-real (c1 num)
"gsl_complex_mul_real"
((c1 complex-double-c) (num :double))
:c-return complex-double-c)
(defmfun cx-div-real (c1 num)
"gsl_complex_div_real"
((c1 complex-double-c) (num :double))
:c-return complex-double-c)
(defmfun cx-add-imag (c1 num)
"gsl_complex_add_imag"
((c1 complex-double-c) (num :double))
:c-return complex-double-c)
(defmfun cx-sub-imag (c1 num)
"gsl_complex_sub_imag"
((c1 complex-double-c) (num :double))
:c-return complex-double-c)
(defmfun cx-mul-imag (c1 num)
"gsl_complex_mul_imag"
((c1 complex-double-c) (num :double))
:c-return complex-double-c)
(defmfun cx-div-imag (c1 num)
"gsl_complex_div_imag"
((c1 complex-double-c) (num :double))
:c-return complex-double-c)
(defmfun cx-conjugate (c1)
"gsl_complex_conjugate"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-inverse (c1)
"gsl_complex_inverse"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-negative (c1)
"gsl_complex_negative"
((c1 complex-double-c))
:c-return complex-double-c)
;;;;****************************************************************************
;;; Complex functions
;;;;****************************************************************************
;;; The GSL functions provided duplicate what CL has built-in.
;;; These should have better thought-out names/interfaces, but it's not clear
;;; that this will ever be used, because CL already does this.
(defmfun cx-sqrt (c1)
"gsl_complex_sqrt"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-sqrt-real (num)
"gsl_complex_sqrt_real"
((num :double))
:c-return complex-double-c)
(defmfun cx-expt (c1 c2)
"gsl_complex_pow"
((c1 complex-double-c) (c2 complex-double-c))
:c-return complex-double-c)
(defmfun cx-expt-real (c1 num)
"gsl_complex_pow_real"
((c1 complex-double-c) (num :double))
:c-return complex-double-c)
(defmfun cx-exp (c1)
"gsl_complex_exp"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-log (c1)
"gsl_complex_log"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-log10 (c1)
"gsl_complex_log10"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-logb (c1 c2)
"gsl_complex_log_b"
((c1 complex-double-c) (c2 complex-double-c))
:c-return complex-double-c)
;;;;****************************************************************************
;;; Trigonometric functions
;;;;****************************************************************************
;;; The GSL functions provided duplicate what CL has built-in.
;;; These should have better thought-out names/interfaces, but it's not clear
;;; that this will ever be used, because CL already does this.
(defmfun cx-sin (c1)
"gsl_complex_sin"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-cos (c1)
"gsl_complex_cos"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-sec (c1)
"gsl_complex_sec"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-csc (c1)
"gsl_complex_csc"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-tan (c1)
"gsl_complex_tan"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-cot (c1)
"gsl_complex_cot"
((c1 complex-double-c))
:c-return complex-double-c)
;;;;****************************************************************************
;;; Inverse trigonometric functions
;;;;****************************************************************************
;;; The GSL functions provided duplicate what CL has built-in.
;;; These should have better thought-out names/interfaces, but it's not clear
;;; that this will ever be used, because CL already does this.
(defmfun cx-arcsin (c1)
"gsl_complex_arcsin"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-arcsin-real (num)
"gsl_complex_arcsin_real"
((num :double))
:c-return complex-double-c)
(defmfun cx-arccos (c1)
"gsl_complex_arccos"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-arccos-real (num)
"gsl_complex_arccos_real"
((num :double))
:c-return complex-double-c)
(defmfun cx-arcsec (c1)
"gsl_complex_arcsec"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-arcsec-real (num)
"gsl_complex_arcsec_real"
((num :double))
:c-return complex-double-c)
(defmfun cx-arccsc (c1)
"gsl_complex_arccsc"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-arccsc-real (num)
"gsl_complex_arccsc_real"
((num :double))
:c-return complex-double-c)
(defmfun cx-arctan (c1)
"gsl_complex_arctan"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-arccot (c1)
"gsl_complex_arccot"
((c1 complex-double-c))
:c-return complex-double-c)
;;;;****************************************************************************
;;; Hyperbolic functions
;;;;****************************************************************************
(defmfun cx-sinh (c1)
"gsl_complex_sinh"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-cosh (c1)
"gsl_complex_cosh"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-sech (c1)
"gsl_complex_sech"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-csch (c1)
"gsl_complex_csch"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-tanh (c1)
"gsl_complex_tanh"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-coth (c1)
"gsl_complex_coth"
((c1 complex-double-c))
:c-return complex-double-c)
;;;;****************************************************************************
;;; Inverse trigonometric functions
;;;;****************************************************************************
(defmfun cx-arcsinh (c1)
"gsl_complex_arcsinh"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-arccosh (c1)
"gsl_complex_arccosh"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-arccosh-real (num)
"gsl_complex_arccosh_real"
((num :double))
:c-return complex-double-c)
(defmfun cx-arcsech (c1)
"gsl_complex_arcsech"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-arccsch (c1)
"gsl_complex_arccsch"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-arctanh (c1)
"gsl_complex_arctanh"
((c1 complex-double-c))
:c-return complex-double-c)
(defmfun cx-arctanh-real (num)
"gsl_complex_arctanh_real"
((num :double))
:c-return complex-double-c)
(defmfun cx-arccoth (c1)
"gsl_complex_arccoth"
((c1 complex-double-c))
:c-return complex-double-c)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment