changeset 5029:1ec26bdb120c

[project @ 2004-09-23 16:58:57 by jwe]
author jwe
date Thu, 23 Sep 2004 17:01:13 +0000
parents 4e4062bb9807
children 160365410ad4
files liboctave/ChangeLog liboctave/oct-inttypes.h
diffstat 2 files changed, 37 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Thu Sep 23 14:46:17 2004 +0000
+++ b/liboctave/ChangeLog	Thu Sep 23 17:01:13 2004 +0000
@@ -1,3 +1,8 @@
+2004-09-23  David Bateman  <dbateman@free.fr>
+
+	* oct-inttypes.h (OCTAVE_INT_DOUBLE_CMP_OP, OCTAVE_DOUBLE_INT_CMP_OP):
+	New macros.  Use them to define mixed intX-double and double-intX ops.
+
 2004-09-22  Federico Zenith  <zenith@chemeng.ntnu.no>
 
 	* DASPK-opts.in, DASRT-opts.in, ODESSA-opts.in:
--- a/liboctave/oct-inttypes.h	Thu Sep 23 14:46:17 2004 +0000
+++ b/liboctave/oct-inttypes.h	Thu Sep 23 17:01:13 2004 +0000
@@ -462,6 +462,38 @@
 OCTAVE_DOUBLE_INT_BIN_OP(*)
 OCTAVE_DOUBLE_INT_BIN_OP(/)
 
+#define OCTAVE_INT_DOUBLE_CMP_OP(OP) \
+  template <class T> \
+  bool \
+  operator OP (const octave_int<T>& x, const double& y) \
+  { \
+    double tx = static_cast<double> (x.value ()); \
+    return tx OP y.value (); \
+  }
+
+OCTAVE_INT_DOUBLE_CMP_OP (<)
+OCTAVE_INT_DOUBLE_CMP_OP (<=)
+OCTAVE_INT_DOUBLE_CMP_OP (>=)
+OCTAVE_INT_DOUBLE_CMP_OP (>)
+OCTAVE_INT_DOUBLE_CMP_OP (==)
+OCTAVE_INT_DOUBLE_CMP_OP (!=)
+
+#define OCTAVE_DOUBLE_INT_CMP_OP(OP) \
+  template <class T> \
+  bool \
+  operator OP (const double& x, const octave_int<T>& y) \
+  { \
+    double ty = static_cast<double> (y.value ()); \
+    return y.value () OP ty; \
+  }
+
+OCTAVE_DOUBLE_INT_CMP_OP (<)
+OCTAVE_DOUBLE_INT_CMP_OP (<=)
+OCTAVE_DOUBLE_INT_CMP_OP (>=)
+OCTAVE_DOUBLE_INT_CMP_OP (>)
+OCTAVE_DOUBLE_INT_CMP_OP (==)
+OCTAVE_DOUBLE_INT_CMP_OP (!=)
+
 #define OCTAVE_INT_BITCMP_OP(OP) \
  \
   template <class T> \