changeset 5701:252b6754e545

[project @ 2006-03-21 18:15:42 by jwe]
author jwe
date Tue, 21 Mar 2006 18:15:46 +0000
parents 67118c88cee7
children fee0874a24d8
files libcruft/ChangeLog libcruft/misc/f77-fcn.h liboctave/ChangeLog liboctave/lo-specfun.cc
diffstat 4 files changed, 21 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libcruft/ChangeLog	Tue Mar 21 17:31:45 2006 +0000
+++ b/libcruft/ChangeLog	Tue Mar 21 18:15:46 2006 +0000
@@ -1,3 +1,8 @@
+2006-03-21  John W. Eaton  <jwe@octave.org>
+
+	* misc/f77-fcn.h (F77_XFCN): Save octave_interrupt_immediately and
+	restore it if an exception occurs that causes a longjmp.
+
 2005-11-01  John W. Eaton  <jwe@octave.org>
 
 	* ranlib/ignbin.f, ranlib/ignpoi.f: Avoid arithmetic IF statements.
--- a/libcruft/misc/f77-fcn.h	Tue Mar 21 17:31:45 2006 +0000
+++ b/libcruft/misc/f77-fcn.h	Tue Mar 21 18:15:46 2006 +0000
@@ -54,9 +54,11 @@
     { \
       octave_jmp_buf saved_context; \
       f77_exception_encountered = 0; \
+      sig_atomic_t saved_octave_interrupt_immediately = octave_interrupt_immediately; \
       octave_save_current_context ((char *) saved_context); \
       if (octave_set_current_context) \
 	{ \
+	  octave_interrupt_immediately = saved_octave_interrupt_immediately; \
           octave_restore_current_context ((char *) saved_context); \
 	  if (f77_exception_encountered) \
 	    F77_XFCN_ERROR (f, F); \
--- a/liboctave/ChangeLog	Tue Mar 21 17:31:45 2006 +0000
+++ b/liboctave/ChangeLog	Tue Mar 21 18:15:46 2006 +0000
@@ -5,8 +5,8 @@
 
 2006-03-21  David Bateman  <dbateman@free.fr>
 
-	* lo-specfun.cc (xlgamma): Require arg strictly greater than 0.
-	Use F77_XFCN instead of F77_FUNC for call to dlgams.
+	* lo-specfun.cc (xlgamma, xgamma): Trap special values.
+	(xlgamma): Use F77_XFCN instead of F77_FUNC for call to dlgams.
 
 	* dSparse.cc (solve): Add argument singular_fallback, to allow
 	fallback to QR solvers to be optional.
--- a/liboctave/lo-specfun.cc	Tue Mar 21 17:31:45 2006 +0000
+++ b/liboctave/lo-specfun.cc	Tue Mar 21 18:15:46 2006 +0000
@@ -37,6 +37,7 @@
 #include "lo-ieee.h"
 #include "lo-specfun.h"
 #include "mx-inlines.cc"
+#include "lo-mappers.h"
 
 #ifndef M_PI
 #define M_PI 3.14159265358979323846
@@ -160,7 +161,13 @@
 xgamma (double x)
 {
   double result;
-  F77_XFCN (xdgamma, XDGAMMA, (x, result));
+
+  if (xisnan (x))
+    result = x;
+  else if ((x <= 0 && D_NINT (x) == x) || xisinf (x))
+    result = octave_Inf;
+  else
+    F77_XFCN (xdgamma, XDGAMMA, (x, result));
   return result;
 }
 
@@ -170,9 +177,10 @@
   double result;
   double sgngam;
 
-  if (x <= 0)
-    (*current_liboctave_error_handler)
-      ("xlgamma: argument must be nonnegative");
+  if (xisnan (x))
+    result = x;
+  else if (x <= 0 || xisinf (x))
+    result = octave_Inf;
   else
     F77_XFCN (dlgams, DLGAMS, (x, result, sgngam));