diff liboctave/oct-inttypes.h @ 7789:82be108cc558

First attempt at single precision tyeps * * * corrections to qrupdate single precision routines * * * prefer demotion to single over promotion to double * * * Add single precision support to log2 function * * * Trivial PROJECT file update * * * Cache optimized hermitian/transpose methods * * * Add tests for tranpose/hermitian and ChangeLog entry for new transpose code
author David Bateman <dbateman@free.fr>
date Sun, 27 Apr 2008 22:34:17 +0200
parents a89b3fa632ee
children 935be827eaf8
line wrap: on
line diff
--- a/liboctave/oct-inttypes.h	Wed May 14 18:09:56 2008 +0200
+++ b/liboctave/oct-inttypes.h	Sun Apr 27 22:34:17 2008 +0200
@@ -132,7 +132,7 @@
 inline T
 octave_int_fit_to_range (const double& x, const T& mn, const T& mx)
 {
-  return (lo_ieee_isnan (x) ? 0 : (x > mx ? mx : (x < mn ? mn : static_cast<T> (x))));
+  return (__lo_ieee_isnan (x) ? 0 : (x > mx ? mx : (x < mn ? mn : static_cast<T> (x))));
 }
 
 // If X is unsigned and the new type is signed, then we only have to
@@ -450,7 +450,7 @@
 {
   double tb = static_cast<double> (b.value ());
   double r = pow (a, tb);
-  r = lo_ieee_isnan (r) ? 0 : xround (r);
+  r = __lo_ieee_isnan (r) ? 0 : xround (r);
   return OCTAVE_INT_FIT_TO_RANGE (r, T);
 }
 
@@ -460,7 +460,7 @@
 {
   double ta = static_cast<double> (a.value ());
   double r = pow (ta, b);
-  r = lo_ieee_isnan (r) ? 0 : xround (r);
+  r = __lo_ieee_isnan (r) ? 0 : xround (r);
   return OCTAVE_INT_FIT_TO_RANGE (r, T);
 }
 
@@ -524,7 +524,7 @@
   { \
     double tx = static_cast<double> (x.value ()); \
     double r = xround (tx OP y); \
-    r = lo_ieee_isnan (r) ? 0 : xround (r); \
+    r = __lo_ieee_isnan (r) ? 0 : xround (r); \
     return OCTAVE_INT_FIT_TO_RANGE (r, T); \
   }
 
@@ -540,7 +540,7 @@
   { \
     double ty = static_cast<double> (y.value ()); \
     double r = x OP ty; \
-    r = lo_ieee_isnan (r) ? 0 : xround (r); \
+    r = __lo_ieee_isnan (r) ? 0 : xround (r); \
     return OCTAVE_INT_FIT_TO_RANGE (r, T); \
   }
 
@@ -581,6 +581,70 @@
 OCTAVE_DOUBLE_INT_CMP_OP (==)
 OCTAVE_DOUBLE_INT_CMP_OP (!=)
 
+#define OCTAVE_INT_FLOAT_BIN_OP(OP) \
+  template <class T> \
+  octave_int<T> \
+  operator OP (const octave_int<T>& x, float y) \
+  { \
+    double tx = static_cast<double> (x.value ()); \
+    double r = xround (tx OP y); \
+    r = __lo_ieee_isnan (r) ? 0 : xround (r); \
+    return OCTAVE_INT_FIT_TO_RANGE (r, T); \
+  }
+
+OCTAVE_INT_FLOAT_BIN_OP(+)
+OCTAVE_INT_FLOAT_BIN_OP(-)
+OCTAVE_INT_FLOAT_BIN_OP(*)
+OCTAVE_INT_FLOAT_BIN_OP(/)
+
+#define OCTAVE_FLOAT_INT_BIN_OP(OP) \
+  template <class T> \
+  octave_int<T> \
+  operator OP (float x, const octave_int<T>& y) \
+  { \
+    double ty = static_cast<double> (y.value ()); \
+    double r = x OP ty; \
+    r = __lo_ieee_isnan (r) ? 0 : xround (r); \
+    return OCTAVE_INT_FIT_TO_RANGE (r, T); \
+  }
+
+OCTAVE_FLOAT_INT_BIN_OP(+)
+OCTAVE_FLOAT_INT_BIN_OP(-)
+OCTAVE_FLOAT_INT_BIN_OP(*)
+OCTAVE_FLOAT_INT_BIN_OP(/)
+
+#define OCTAVE_INT_FLOAT_CMP_OP(OP) \
+  template <class T> \
+  bool \
+  operator OP (const octave_int<T>& x, const float& y) \
+  { \
+    double tx = static_cast<double> (x.value ()); \
+    return tx OP y; \
+  }
+
+OCTAVE_INT_FLOAT_CMP_OP (<)
+OCTAVE_INT_FLOAT_CMP_OP (<=)
+OCTAVE_INT_FLOAT_CMP_OP (>=)
+OCTAVE_INT_FLOAT_CMP_OP (>)
+OCTAVE_INT_FLOAT_CMP_OP (==)
+OCTAVE_INT_FLOAT_CMP_OP (!=)
+
+#define OCTAVE_FLOAT_INT_CMP_OP(OP) \
+  template <class T> \
+  bool \
+  operator OP (const float& x, const octave_int<T>& y) \
+  { \
+    double ty = static_cast<double> (y.value ()); \
+    return x OP ty; \
+  }
+
+OCTAVE_FLOAT_INT_CMP_OP (<)
+OCTAVE_FLOAT_INT_CMP_OP (<=)
+OCTAVE_FLOAT_INT_CMP_OP (>=)
+OCTAVE_FLOAT_INT_CMP_OP (>)
+OCTAVE_FLOAT_INT_CMP_OP (==)
+OCTAVE_FLOAT_INT_CMP_OP (!=)
+
 #define OCTAVE_INT_BITCMP_OP(OP) \
   template <class T> \
   octave_int<T> \