gsl_isnan in eigen/*.c for 1.3

Brian Gough brian.gough@network-theory.co.uk
Wed Jan 1 21:33:00 GMT 2003


Albert Chin writes:
 > Why do eigen/symm.c, eigen/symmv.c, eigen/herm.c, and eigen/hermv.c
 > use gsl_isnan() rather than isnan()? gsl_isnan is defined only when
 > using Microsoft Visual C++ (sys/infnan.c) or if HAVE_IEEE_COMPARISONS
 > is defined. On HP-UX 10.20, HAVE_IEEE_COMPARISONS is not defined. As
 > isnan is defined to gsl_isnan in config.h, why not use isnan()?
 > 
 > Is it really bad for HP-UX 10.20 to fail the HAVE_IEEE_COMPARISONS
 > test?
 > 
 > Ditto for sys/test.c.

It was a bug. The library should use isnan, etc internally, and have
them replaced by gsl_isnan through config.h.  If isnan is available
and IEEE comparisons aren't then gsl_isnan should be defined in terms
of isnan.  Try this patch (untested).


Index: eigen/herm.c
===================================================================
RCS file: /cvs/gsl/gsl/eigen/herm.c,v
retrieving revision 1.5
diff -u -r1.5 herm.c
--- eigen/herm.c	16 Nov 2002 17:57:34 -0000	1.5
+++ eigen/herm.c	1 Jan 2003 21:24:53 -0000
@@ -133,7 +133,7 @@
       
       while (b > 0)
         {
-          if (sd[b - 1] == 0.0 || gsl_isnan(sd[b - 1]))
+          if (sd[b - 1] == 0.0 || isnan(sd[b - 1]))
             {
               b--;
               continue;
Index: eigen/hermv.c
===================================================================
RCS file: /cvs/gsl/gsl/eigen/hermv.c,v
retrieving revision 1.6
diff -u -r1.6 hermv.c
--- eigen/hermv.c	16 Nov 2002 17:57:34 -0000	1.6
+++ eigen/hermv.c	1 Jan 2003 21:24:53 -0000
@@ -173,7 +173,7 @@
       
       while (b > 0)
         {
-          if (sd[b - 1] == 0.0 || gsl_isnan(sd[b - 1]))
+          if (sd[b - 1] == 0.0 || isnan(sd[b - 1]))
             {
               b--;
               continue;
Index: eigen/symm.c
===================================================================
RCS file: /cvs/gsl/gsl/eigen/symm.c,v
retrieving revision 1.5
diff -u -r1.5 symm.c
--- eigen/symm.c	16 Nov 2002 17:57:34 -0000	1.5
+++ eigen/symm.c	1 Jan 2003 21:24:53 -0000
@@ -133,7 +133,7 @@
       
       while (b > 0)
         {
-          if (sd[b - 1] == 0.0 || gsl_isnan(sd[b - 1]))
+          if (sd[b - 1] == 0.0 || isnan(sd[b - 1]))
             {
               b--;
               continue;
Index: eigen/symmv.c
===================================================================
RCS file: /cvs/gsl/gsl/eigen/symmv.c,v
retrieving revision 1.5
diff -u -r1.5 symmv.c
--- eigen/symmv.c	16 Nov 2002 17:57:34 -0000	1.5
+++ eigen/symmv.c	1 Jan 2003 21:24:53 -0000
@@ -150,7 +150,7 @@
       
       while (b > 0)
         {
-          if (sd[b - 1] == 0.0 || gsl_isnan(sd[b - 1]))
+          if (sd[b - 1] == 0.0 || isnan(sd[b - 1]))
             {
               b--;
               continue;
Index: sys/infnan.c
===================================================================
RCS file: /cvs/gsl/gsl/sys/infnan.c,v
retrieving revision 1.4
diff -u -r1.4 infnan.c
--- sys/infnan.c	16 Jan 2002 16:58:33 -0000	1.4
+++ sys/infnan.c	1 Jan 2003 21:24:54 -0000
@@ -100,5 +100,37 @@
   int status = (y == y);
   return status;
 }
+#else
+
+#ifdef HAVE_ISNAN
+int
+gsl_isnan (const double x)
+{
+  return isnan(x);
+}
+#endif
+
+#ifdef HAVE_ISINF
+int
+gsl_isinf (const double x)
+{
+    return isinf(x);
+}
+#endif
+
+#ifdef HAVE_FINITE
+int
+gsl_finite (const double x)
+{
+  return finite(x);
+}
+#elif defined(HAVE_ISFINITE)
+int
+gsl_finite (const double x)
+{
+  return isfinite(x);
+}
+#endif
+
 #endif
 



More information about the Gsl-discuss mailing list