changeset 6969:0a64abe792f4

[project @ 2007-10-06 14:15:19 by jwe]
author jwe
date Sat, 06 Oct 2007 14:15:20 +0000
parents c8fc3487ed2c
children 3113e481833f
files ChangeLog configure.in liboctave/ChangeLog liboctave/lo-specfun.cc liboctave/lo-specfun.h src/ChangeLog src/mappers.cc
diffstat 7 files changed, 34 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Oct 06 12:57:59 2007 +0000
+++ b/ChangeLog	Sat Oct 06 14:15:20 2007 +0000
@@ -1,3 +1,7 @@
+2007-10-06  John W. Eaton  <jwe@octave.org>
+
+	* configure.in: Check for lgamma and tgamma.
+
 2007-10-04  John W. Eaton  <jwe@octave.org>
 
 	* configure.in (UGLY_DEFS): Delete special case for darwin.
--- a/configure.in	Sat Oct 06 12:57:59 2007 +0000
+++ b/configure.in	Sat Oct 06 14:15:20 2007 +0000
@@ -29,7 +29,7 @@
 EXTERN_CXXFLAGS="$CXXFLAGS"
 
 AC_INIT
-AC_REVISION($Revision: 1.578 $)
+AC_REVISION($Revision: 1.579 $)
 AC_PREREQ(2.57)
 AC_CONFIG_SRCDIR([src/octave.cc])
 AC_CONFIG_HEADER(config.h)
@@ -1432,12 +1432,12 @@
 AC_CHECK_FUNCS(atexit basename bcopy bzero canonicalize_file_name chmod \
   dup2 endgrent endpwent execvp fcntl fork getcwd getegid geteuid \
   getgid getgrent getgrgid getgrnam getpgrp getpid getppid getpwent \
-  getpwuid gettimeofday getuid getwd _kbhit kill link localtime_r \
+  getpwuid gettimeofday getuid getwd _kbhit kill lgamma link localtime_r \
   lstat memmove mkdir mkfifo mkstemp on_exit pipe poll putenv raise \
   readlink realpath rename resolvepath rindex rmdir round select setgrent \
   setlocale setpwent setvbuf sigaction siglongjmp sigpending sigprocmask \
   sigsuspend snprintf stat strcasecmp strdup strerror stricmp \
-  strncasecmp strnicmp strptime strsignal symlink tempnam umask \
+  strncasecmp strnicmp strptime strsignal symlink tempnam tgamma umask \
   uname unlink usleep utime vfprintf vsprintf vsnprintf waitpid \
   _chmod _snprintf x_utime _utime32)
 
--- a/liboctave/ChangeLog	Sat Oct 06 12:57:59 2007 +0000
+++ b/liboctave/ChangeLog	Sat Oct 06 14:15:20 2007 +0000
@@ -1,3 +1,11 @@
+2007-10-06  John W. Eaton  <jwe@octave.org>
+
+	* lo-specfun.cc: (zlgamma): Delete.
+	(xgamma): Use C library gamma function if available.
+	(xlgamma): Use C library lgamma function if available.
+	(xlgamma) [! HAVE_LGAMMA]: Allow calculation for any value of X
+	other than NaN or Inf.
+
 2007-10-05  John W. Eaton  <jwe@octave.org>
 
 	* lo-specfun.cc (zlgamma): New function.
--- a/liboctave/lo-specfun.cc	Sat Oct 06 12:57:59 2007 +0000
+++ b/liboctave/lo-specfun.cc	Sat Oct 06 14:15:20 2007 +0000
@@ -160,6 +160,9 @@
 double
 xgamma (double x)
 {
+#if defined (HAVE_TGAMMA)
+  return tgamma (x);
+#else
   double result;
 
   if (xisnan (x))
@@ -168,42 +171,29 @@
     result = octave_Inf;
   else
     F77_XFCN (xdgamma, XDGAMMA, (x, result));
+
   return result;
+#endif
 }
 
 double
 xlgamma (double x)
 {
+#if defined (HAVE_LGAMMA)
+  return lgamma (x);
+#else
   double result;
   double sgngam;
 
   if (xisnan (x))
     result = x;
-  else if (x <= 0 || xisinf (x))
+  else if (xisinf (x))
     result = octave_Inf;
   else
     F77_XFCN (dlgams, DLGAMS, (x, result, sgngam));
 
   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;
+#endif
 }
 
 static inline Complex
--- a/liboctave/lo-specfun.h	Sat Oct 06 12:57:59 2007 +0000
+++ b/liboctave/lo-specfun.h	Sat Oct 06 14:15:20 2007 +0000
@@ -59,7 +59,6 @@
 
 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	Sat Oct 06 12:57:59 2007 +0000
+++ b/src/ChangeLog	Sat Oct 06 14:15:20 2007 +0000
@@ -1,3 +1,9 @@
+2007-10-06  John W. Eaton  <jwe@octave.org>
+
+	* mappers.cc (install_mapper_functions): Undo previous change.
+	Fix doc string for lgamma.
+	(xzlgamma): Delete.
+
 2007-10-05  John W. Eaton  <jwe@octave.org>
 
 	* graphics.h.in (axes::properties): New property, colororder.
--- a/src/mappers.cc	Sat Oct 06 12:57:59 2007 +0000
+++ b/src/mappers.cc	Sat Oct 06 14:15:20 2007 +0000
@@ -172,21 +172,6 @@
   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)
 {
@@ -542,11 +527,12 @@
 Return 1 for characters that are hexadecimal digits.\n\
 @end deftypefn");
 
-  DEFUN_MAPPER (lgamma, 0, 0, 0, xlgamma, 0, xzlgamma, 0.0, octave_Inf, 0, 1,
+  DEFUN_MAPPER (lgamma, 0, 0, 0, xlgamma, 0, 0, 0.0, 0.0, 0, 0,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} lgamma (@var{x})\n\
 @deftypefnx {Mapping Function} {} gammaln (@var{x})\n\
-Return the natural logarithm of the gamma function.\n\
+Return the natural logarithm of the absolute value of the gamma\n\
+function of @var{x}.\n\
 @seealso{gamma, gammai}\n\
 @end deftypefn");