comparison liboctave/mx-inlines.cc @ 9578:7dafdb8b062f

refactor comparison ops implementations
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 27 Aug 2009 11:19:33 +0200
parents 0c72d9284087
children 1be3c73ed7b5
comparison
equal deleted inserted replaced
9577:b03062e16c6f 9578:7dafdb8b062f
101 DEFMXCMPOP (mx_inline_le, <=) 101 DEFMXCMPOP (mx_inline_le, <=)
102 DEFMXCMPOP (mx_inline_gt, >) 102 DEFMXCMPOP (mx_inline_gt, >)
103 DEFMXCMPOP (mx_inline_ge, >=) 103 DEFMXCMPOP (mx_inline_ge, >=)
104 DEFMXCMPOP (mx_inline_eq, ==) 104 DEFMXCMPOP (mx_inline_eq, ==)
105 DEFMXCMPOP (mx_inline_ne, !=) 105 DEFMXCMPOP (mx_inline_ne, !=)
106
107 // For compatibility with certain loserware, cmp ops on complex nums only
108 // compare real parts, although "sort" defines ordering on complex numbers!
109
110 #define DEFCMPLXCMOP(F, OP) \
111 template <class X, class Y> \
112 inline void F (size_t n, bool *r, const std::complex<X> *x, const Y *y) \
113 { for (size_t i = 0; i < n; i++) r[i] = real (x[i]) OP real (y[i]); } \
114 template <class X, class Y> \
115 inline void F (size_t n, bool *r, const std::complex<X> *x, Y y) \
116 { for (size_t i = 0; i < n; i++) r[i] = real (x[i]) OP y; } \
117 template <class X, class Y> \
118 inline void F (size_t n, bool *r, X x, const std::complex<Y> *y) \
119 { for (size_t i = 0; i < n; i++) r[i] = x OP real (y[i]); }
120 106
121 // Convert to logical value, for logical op purposes. 107 // Convert to logical value, for logical op purposes.
122 template <class T> inline bool logical_value (T x) { return x; } 108 template <class T> inline bool logical_value (T x) { return x; }
123 template <class T> inline bool logical_value (const octave_int<T>& x) 109 template <class T> inline bool logical_value (const octave_int<T>& x)
124 { return x.value (); } 110 { return x.value (); }