Comparison with NaN

Jaroslav Hajek highegg at gmail.com
Mon May 11 00:35:17 CDT 2009


On Sun, May 10, 2009 at 10:43 PM, Michael Goffioul
<michael.goffioul at gmail.com> wrote:
> Hi,
>
> After running the test suite, I get a couple of errors. All of these
> seem to be related to comparing/sorting with NaN. For instance:
>
> assert (sort ([NaN, 1, -1, 2, Inf], 2),[-1, 1, 2, Inf, NaN]) expected
>    -1     1     2   Inf   NaN
> but got
>   NaN    -1     1     2   Inf
>
> Can anybody tell me what is the expected behavior?
>

The assertion result indicates the expected behavior. I can't
reproduce the problem. Hmmm. Can you try the attached test patch and
tell me whether the message gets printed after running `sort ([NaN, 1,
-1, 2, Inf], 2)' ? (it will be only printed once, so if you have some
startup scripts calling sort with doubles, it should get printed
earlier).

Plus, please tell me the status of HAVE_CMATH_ISNAN in your config.h.

cheers

-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz

diff --git a/liboctave/Array-d.cc b/liboctave/Array-d.cc
--- a/liboctave/Array-d.cc
+++ b/liboctave/Array-d.cc
@@ -40,6 +40,12 @@
 inline bool
 sort_isnan<double> (double x)
 {
+  static bool first_time = true;
+  if (first_time)
+    {
+      std::cerr << "sort_isnan<double> correctly specialized.\n";
+      first_time = false;
+    }
   return xisnan (x);
 }



More information about the Octave-maintainers mailing list