# HG changeset patch # User jwe # Date 1191612922 0 # Node ID b559b4bcf51f6d2fb142348e3aaa1cb7f3811818 # Parent d5339f9f5f9c4338974e155108b2080e00edae40 [project @ 2007-10-05 19:35:21 by jwe] diff -r d5339f9f5f9c -r b559b4bcf51f liboctave/ChangeLog --- a/liboctave/ChangeLog Fri Oct 05 15:03:10 2007 +0000 +++ b/liboctave/ChangeLog Fri Oct 05 19:35:22 2007 +0000 @@ -1,3 +1,7 @@ +2007-10-05 John W. Eaton + + * lo-specfun.cc (zlgamma): New function. + 2007-10-04 John W. Eaton * oct-sort.cc (octave_sort::binarysort): Remove register diff -r d5339f9f5f9c -r b559b4bcf51f liboctave/lo-specfun.cc --- a/liboctave/lo-specfun.cc Fri Oct 05 15:03:10 2007 +0000 +++ b/liboctave/lo-specfun.cc Fri Oct 05 19:35:22 2007 +0000 @@ -187,6 +187,25 @@ return result; } +Complex +zlgamma (double x) +{ + Complex result; + + if (xisnan (x)) + result = x; + else if (x > 0) + result = xlgamma (x); + else + { + double tmp = xgamma (x); + + result = tmp < 0 ? std::log (Complex (tmp)) : log (tmp); + } + + return result; +} + static inline Complex zbesj (const Complex& z, double alpha, int kode, octave_idx_type& ierr); diff -r d5339f9f5f9c -r b559b4bcf51f liboctave/lo-specfun.h --- a/liboctave/lo-specfun.h Fri Oct 05 15:03:10 2007 +0000 +++ b/liboctave/lo-specfun.h Fri Oct 05 19:35:22 2007 +0000 @@ -59,6 +59,7 @@ extern OCTAVE_API double xgamma (double x); extern OCTAVE_API double xlgamma (double x); +extern OCTAVE_API Complex zlgamma (double x); extern OCTAVE_API Complex besselj (double alpha, const Complex& x, bool scaled, octave_idx_type& ierr); diff -r d5339f9f5f9c -r b559b4bcf51f src/ChangeLog --- a/src/ChangeLog Fri Oct 05 15:03:10 2007 +0000 +++ b/src/ChangeLog Fri Oct 05 19:35:22 2007 +0000 @@ -1,3 +1,10 @@ +2007-10-05 John W. Eaton + + * mappers.cc (xzlgamma): New static function. + (install_mapper_functions): Pass xzlgamma for c_c_map for lgamma + mapper. Pass 1 for can_ret_cmplx_for_real and set hi to + octave_Inf. + 2007-10-04 John W. Eaton * DLD-FUNCTIONS/symrcm.cc: Move static functions to top of file to diff -r d5339f9f5f9c -r b559b4bcf51f src/defun.h --- a/src/defun.h Fri Oct 05 15:03:10 2007 +0000 +++ b/src/defun.h Fri Oct 05 19:35:22 2007 +0000 @@ -87,8 +87,8 @@ // d_d_map is a pointer to a function that should be called for real // arguments that are expected to create real results. // -// d_c_map is a pointer to a function that should be called for real -// arguments that are expected to create complex results. +// d_c_map is a pointer to a function that should be called for +// complex arguments that are expected to create real results. // // c_c_map is a pointer to a function that should be called for // complex arguments that are expected to create complex results. diff -r d5339f9f5f9c -r b559b4bcf51f src/mappers.cc --- a/src/mappers.cc Fri Oct 05 15:03:10 2007 +0000 +++ b/src/mappers.cc Fri Oct 05 19:35:22 2007 +0000 @@ -172,6 +172,21 @@ return 0; } +// FIXME -- maybe our mapper function structure should alow for +// functions that take real arguments and produce complex values. +static Complex +xzlgamma (const Complex& x) +{ + Complex retval; + + if (x.imag () != 0) + error ("lgamma: expecting real arguments"); + else + retval = zlgamma (x.real ()); + + return retval; +} + void install_mapper_functions (void) { @@ -527,7 +542,7 @@ Return 1 for characters that are hexadecimal digits.\n\ @end deftypefn"); - DEFUN_MAPPER (lgamma, 0, 0, 0, xlgamma, 0, 0, 0.0, 0.0, 0, 0, + DEFUN_MAPPER (lgamma, 0, 0, 0, xlgamma, 0, xzlgamma, 0.0, octave_Inf, 0, 1, "-*- texinfo -*-\n\ @deftypefn {Mapping Function} {} lgamma (@var{x})\n\ @deftypefnx {Mapping Function} {} gammaln (@var{x})\n\