comparison liboctave/array/Array-fC.cc @ 19831:d9c0b08e3da6

Fix complex compare operation for issorted float values (bug #44071). * Array-fC.cc (nan_ascending_compare, nan_descending_compare): Fix typo where comparison was made between x and x rather than between x and y.
author Rik <rik@octave.org>
date Mon, 26 Jan 2015 22:36:58 -0800
parents fb09907f4e49
children bdf90710dddf
comparison
equal deleted inserted replaced
19830:884e0c55d92c 19831:d9c0b08e3da6
45 nan_ascending_compare (const FloatComplex& x, const FloatComplex& y) 45 nan_ascending_compare (const FloatComplex& x, const FloatComplex& y)
46 { 46 {
47 return (xisnan (y) 47 return (xisnan (y)
48 ? ! xisnan (x) 48 ? ! xisnan (x)
49 : ((std::abs (x) < std::abs (x)) 49 : ((std::abs (x) < std::abs (x))
50 || ((std::abs (x) == std::abs (x)) && (arg (x) < arg (x))))); 50 || ((std::abs (x) == std::abs (y)) && (arg (x) < arg (y)))));
51 } 51 }
52 52
53 static bool 53 static bool
54 nan_descending_compare (const FloatComplex& x, const FloatComplex& y) 54 nan_descending_compare (const FloatComplex& x, const FloatComplex& y)
55 { 55 {
56 return (xisnan (x) 56 return (xisnan (x)
57 ? ! xisnan (y) 57 ? ! xisnan (y)
58 : ((std::abs (x) > std::abs (x)) 58 : ((std::abs (x) > std::abs (x))
59 || ((std::abs (x) == std::abs (x)) && (arg (x) > arg (x))))); 59 || ((std::abs (x) == std::abs (y)) && (arg (x) > arg (y)))));
60 } 60 }
61 61
62 Array<FloatComplex>::compare_fcn_type 62 Array<FloatComplex>::compare_fcn_type
63 safe_comparator (sortmode mode, const Array<FloatComplex>& a, bool allow_chk) 63 safe_comparator (sortmode mode, const Array<FloatComplex>& a, bool allow_chk)
64 { 64 {