# HG changeset patch # User Jaroslav Hajek
# Date 1207216326 -7200 # Branch release-3-0-x # Node ID e59865910475a48f4b7d97af070e8ae4443f551d # Parent 9dc1f54b3233f25b542b1acf8c3c13e4e7d3927a fix to enable compiling with Intel C++ diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-04-03 Jaroslav Hajek + + * DLD-FUNCTIONS/sort.cc (Fsort): quick fix to enable compiling with + Intel C++ + 2008-04-02 John W. Eaton * graphics.cc, graphics.h.in (class axes): diff --git a/src/DLD-FUNCTIONS/sort.cc b/src/DLD-FUNCTIONS/sort.cc --- a/src/DLD-FUNCTIONS/sort.cc +++ b/src/DLD-FUNCTIONS/sort.cc @@ -38,7 +38,6 @@ #include "data-conv.h" #include "ov-cx-mat.h" #include "ov-cell.h" -#include "oct-sort.cc" enum sortmode { UNDEFINED, ASCENDING, DESCENDING }; @@ -78,6 +77,47 @@ { return (a->vec > b->vec); } + +// std::abs(Inf) returns NaN!! +static inline double +xabs (const Complex& x) +{ + return (xisinf (x.real ()) || xisinf (x.imag ())) ? octave_Inf : abs (x); +} + +template <> +bool +ascending_compare (Complex a, Complex b) +{ + return (xisnan (b) || (xabs (a) < xabs (b)) + || ((xabs (a) == xabs (b)) && (arg (a) < arg (b)))); +} + +bool +operator < (const Complex& a, const Complex& b) +{ + return (xisnan (b) || (xabs (a) < xabs (b)) + || ((xabs (a) == xabs (b)) && (arg (a) < arg (b)))); +} + +template <> +bool +descending_compare (Complex a, Complex b) +{ + return (xisnan (a) || (xabs (a) > xabs (b)) + || ((xabs (a) == xabs (b)) && (arg (a) > arg (b)))); +} + +bool +operator > (const Complex& a, const Complex& b) +{ + return (xisnan (a) || (xabs (a) > xabs (b)) + || ((xabs (a) == xabs (b)) && (arg (a) > arg (b)))); +} + +// This file must be included after the < and > operators are +// defined to avoid errors with the Intel C++ compiler. +#include "oct-sort.cc" template