changeset 6961:b559b4bcf51f

[project @ 2007-10-05 19:35:21 by jwe]
author jwe
date Fri, 05 Oct 2007 19:35:22 +0000
parents d5339f9f5f9c
children 9ac23c7f1c37
files liboctave/ChangeLog liboctave/lo-specfun.cc liboctave/lo-specfun.h src/ChangeLog src/defun.h src/mappers.cc
diffstat 6 files changed, 49 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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  <jwe@octave.org>
+
+	* lo-specfun.cc (zlgamma): New function.
+
 2007-10-04  John W. Eaton  <jwe@octave.org>
 
 	* oct-sort.cc (octave_sort<T>::binarysort): Remove register
--- 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);
 
--- 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);
--- 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  <jwe@octave.org>
+
+	* 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  <jwe@octave.org>
 
 	* DLD-FUNCTIONS/symrcm.cc: Move static functions to top of file to
--- 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.
--- 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\