octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #44206] test complex.tst fails in MXE-octave


From: Rik
Subject: [Octave-bug-tracker] [bug #44206] test complex.tst fails in MXE-octave
Date: Thu, 19 Mar 2015 15:49:06 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0

Follow-up Comment #5, bug #44206 (project octave):

I have also wondered why we have two functions that do sorting, rather than
just one.  I think long term that is a problem as we are maintaining two
pieces of code that can go out of sync, as they have already done here.

The sort routine in oct-sort.cc is fine because it defines a generic sort
operation but the definition of the comparison operators like '>' or '<' is
overloaded.  The overloaded definition of comparison operators for complex
values is in oct-cmplx.h.  Extracting the definition:


#define DEF_COMPLEXR_COMP(OP, OPS) \
template <class T> \
inline bool operator OP (const std::complex<T>& a, const std::complex<T>& b)
\
{ \
  FLOAT_TRUNCATE const T ax = std::abs (a); \
  FLOAT_TRUNCATE const T bx = std::abs (b); \
  if (ax == bx) \
    { \
      FLOAT_TRUNCATE const T ay = std::arg (a); \
      FLOAT_TRUNCATE const T by = std::arg (b); \
      if (ay == static_cast<T> (-M_PI)) \
        { \
          if (by != static_cast<T> (-M_PI)) \
            return static_cast<T> (M_PI) OP by; \
        } \
      else if (by == static_cast<T> (-M_PI)) \
        { \
          return ay OP static_cast<T> (M_PI); \
        } \
      return ay OP by; \
    } \
  else \
    return ax OPS bx; \
} \


As you can see, it already uses FLOAT_TRUNCATE and comparisons to static
compiler-time values.

I think the short term fix is to add FLOAT_TRUNCATE, and maybe static_cast
calls, to Array-C.cc and Array-fC.cc.  Longer term, I would ditch one of the
sort routines and consolidate.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?44206>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]