changeset 5895:b9c45e0cf685

[project @ 2006-07-19 01:57:44 by jwe]
author jwe
date Wed, 19 Jul 2006 01:58:47 +0000
parents acf8b96ca9c9
children fc22530e985b
files src/ChangeLog src/ov-base.h src/ov-complex.h src/ov-cx-mat.h src/ov-cx-sparse.h src/ov-int16.h src/ov-int32.h src/ov-int64.h src/ov-int8.h src/ov-intx.h src/ov-range.h src/ov-re-mat.h src/ov-re-sparse.h src/ov-scalar.h src/ov-uint16.h src/ov-uint32.h src/ov-uint64.h src/ov-uint8.h src/ov.h
diffstat 19 files changed, 136 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,35 @@
+2006-07-18  John W. Eaton  <jwe@octave.org>
+
+	* ov.h (octave_value::is_int8_type, octave_value::is_int16_type,
+	octave_value::is_int32_type, octave_value::is_int64_type,
+	octave_value::is_uint8_type, octave_value::is_uint16_type,
+	octave_value::is_uint32_type, octave_value::is_uint64_type):
+	New functions. 
+	* ov-base.h (octave_base_value::is_int8_type,
+	octave_base_value::is_int16_type,
+	octave_base_value::is_int32_type,
+	octave_base_value::is_int64_type,
+	octave_base_value::is_uint8_type,
+	octave_base_value::is_uint16_type,
+	octave_base_value::is_uint32_type,
+	octave_base_value::is_uint64_type): New functions.
+	* ov-int8.h, ov-int16.h, ov-int32.h, ov-int16.h, ov-uint8.h,
+	ov-uint16.h, ov-uint32.h, ov-uint16.h: Define OCTAVE_BASE_INT_T.
+	* ov-intx.h: Use OCTAVE_BASE_INT_T to define type-specific predicate.
+
+	* ov.h (octave_value::is_double_type, octave_value::is_single_type):
+	New functions.
+	* ov-base.h (octave_base_value::is_double_type,
+	octave_base_value::is_single_type): New functions.
+	* ov-re-mat.h (octave_matrix::is_double_type): New function.
+	* ov-cx-mat.h (octave_matrix::is_double_type): New function.
+	* ov-scalar.h (octave_scalar::is_double_type): New function.
+	* ov-complex.h (octave_complex::is_double_type): New function.
+	* ov-range.h (octave_range::is_double_type): New function.
+	* ov-re-sparse.h (octave_sparse_matrix::is_double_type): New function.
+	* ov-cx-sparse.h (octave_sparse_complex_matrix::is_double_type):
+	New function.
+	
 2006-07-15  John W. Eaton  <jwe@octave.org>
 
 	* ov-typeinfo.cc: Also instantiate arrays of assignany_ops.
--- a/src/ov-base.h
+++ b/src/ov-base.h
@@ -229,6 +229,26 @@
 
   virtual octave_value any (int = 0) const;
 
+  virtual bool is_double_type (void) const { return false; }
+
+  virtual bool is_single_type (void) const { return false; }
+
+  virtual bool is_int8_type (void) const { return false; }
+
+  virtual bool is_int16_type (void) const { return false; }
+
+  virtual bool is_int32_type (void) const { return false; }
+
+  virtual bool is_int64_type (void) const { return false; }
+
+  virtual bool is_uint8_type (void) const { return false; }
+
+  virtual bool is_uint16_type (void) const { return false; }
+
+  virtual bool is_uint32_type (void) const { return false; }
+
+  virtual bool is_uint64_type (void) const { return false; }
+
   virtual bool is_bool_type (void) const { return false; }
 
   virtual bool is_real_type (void) const { return false; }
--- a/src/ov-complex.h
+++ b/src/ov-complex.h
@@ -89,6 +89,8 @@
 
   bool is_complex_type (void) const { return true; }
 
+  bool is_double_type (void) const { return true; }
+
   // FIXME ???
   bool valid_as_scalar_index (void) const { return false; }
   bool valid_as_zero_index (void) const { return false; }
--- a/src/ov-cx-mat.h
+++ b/src/ov-cx-mat.h
@@ -95,6 +95,8 @@
 
   bool is_complex_type (void) const { return true; }
 
+  bool is_double_type (void) const { return true; }
+
   bool valid_as_scalar_index (void) const;
 
   double double_value (bool = false) const;
--- a/src/ov-cx-sparse.h
+++ b/src/ov-cx-sparse.h
@@ -90,6 +90,8 @@
 
   bool is_complex_type (void) const { return true; }
 
+  bool is_double_type (void) const { return true; }
+
   bool valid_as_scalar_index (void) const;
 
   double double_value (bool = false) const;
--- a/src/ov-int16.h
+++ b/src/ov-int16.h
@@ -32,6 +32,8 @@
 #define OCTAVE_INT_T octave_int16
 #define OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION int16_scalar_value
 
+#define OCTAVE_TYPE_PREDICATE_FUNCTION is_int16_type
+
 #include "ov-intx.h"
 
 #undef OCTAVE_VALUE_INT_MATRIX_T
@@ -42,6 +44,8 @@
 #undef OCTAVE_INT_T
 #undef OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION
 
+#undef OCTAVE_TYPE_PREDICATE_FUNCTION
+
 #endif
 
 /*
--- a/src/ov-int32.h
+++ b/src/ov-int32.h
@@ -32,6 +32,8 @@
 #define OCTAVE_INT_T octave_int32
 #define OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION int32_scalar_value
 
+#define OCTAVE_TYPE_PREDICATE_FUNCTION is_int32_type
+
 #include "ov-intx.h"
 
 #undef OCTAVE_VALUE_INT_MATRIX_T
@@ -42,6 +44,8 @@
 #undef OCTAVE_INT_T
 #undef OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION
 
+#undef OCTAVE_TYPE_PREDICATE_FUNCTION
+
 #endif
 
 /*
--- a/src/ov-int64.h
+++ b/src/ov-int64.h
@@ -32,6 +32,8 @@
 #define OCTAVE_INT_T octave_int64
 #define OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION int64_scalar_value
 
+#define OCTAVE_TYPE_PREDICATE_FUNCTION is_int64_type
+
 #include "ov-intx.h"
 
 #undef OCTAVE_VALUE_INT_MATRIX_T
@@ -42,6 +44,8 @@
 #undef OCTAVE_INT_T
 #undef OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION
 
+#undef OCTAVE_TYPE_PREDICATE_FUNCTION
+
 #endif
 
 /*
--- a/src/ov-int8.h
+++ b/src/ov-int8.h
@@ -32,6 +32,8 @@
 #define OCTAVE_INT_T octave_int8
 #define OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION int8_scalar_value
 
+#define OCTAVE_TYPE_PREDICATE_FUNCTION is_int8_type
+
 #include "ov-intx.h"
 
 #undef OCTAVE_VALUE_INT_MATRIX_T
@@ -42,6 +44,8 @@
 #undef OCTAVE_INT_T
 #undef OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION
 
+#undef OCTAVE_TYPE_PREDICATE_FUNCTION
+
 #endif
 
 /*
--- a/src/ov-intx.h
+++ b/src/ov-intx.h
@@ -58,6 +58,8 @@
   octave_base_value *empty_clone (void) const
     { return new OCTAVE_VALUE_INT_MATRIX_T (); }
 
+  bool OCTAVE_TYPE_PREDICATE_FUNCTION (void) { return true; }
+
   int8NDArray
   int8_array_value (void) const { return int8NDArray (matrix); }
 
@@ -203,6 +205,8 @@
       return retval;
     }
 
+  bool OCTAVE_TYPE_PREDICATE_FUNCTION (void) { return true; }
+
   octave_int8
   int8_scalar_value (void) const { return octave_int8 (scalar); }
 
--- a/src/ov-range.h
+++ b/src/ov-range.h
@@ -127,6 +127,8 @@
 
   bool is_real_type (void) const { return true; }
 
+  bool is_double_type (void) const { return true; }
+
   bool valid_as_scalar_index (void) const
     {
       double b = range.base ();
--- a/src/ov-re-mat.h
+++ b/src/ov-re-mat.h
@@ -94,6 +94,8 @@
 
   bool is_real_type (void) const { return true; }
 
+  bool is_double_type (void) const { return true; }
+
   bool valid_as_scalar_index (void) const;
 
   int8NDArray
--- a/src/ov-re-sparse.h
+++ b/src/ov-re-sparse.h
@@ -88,6 +88,8 @@
 
   bool is_real_type (void) const { return true; }
 
+  bool is_double_type (void) const { return true; }
+
   bool valid_as_scalar_index (void) const;
 
   double double_value (bool = false) const;
--- a/src/ov-scalar.h
+++ b/src/ov-scalar.h
@@ -83,6 +83,8 @@
 
   bool is_real_type (void) const { return true; }
 
+  bool is_double_type (void) const { return true; }
+
   bool valid_as_scalar_index (void) const
     {
       return (! xisnan (scalar)
--- a/src/ov-uint16.h
+++ b/src/ov-uint16.h
@@ -32,6 +32,8 @@
 #define OCTAVE_INT_T octave_uint16
 #define OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION uint16_scalar_value
 
+#define OCTAVE_TYPE_PREDICATE_FUNCTION is_uint16_type
+
 #include "ov-intx.h"
 
 #undef OCTAVE_VALUE_INT_MATRIX_T
@@ -42,6 +44,8 @@
 #undef OCTAVE_INT_T
 #undef OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION
 
+#undef OCTAVE_TYPE_PREDICATE_FUNCTION
+
 #endif
 
 /*
--- a/src/ov-uint32.h
+++ b/src/ov-uint32.h
@@ -32,6 +32,8 @@
 #define OCTAVE_INT_T octave_uint32
 #define OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION uint32_scalar_value
 
+#define OCTAVE_TYPE_PREDICATE_FUNCTION is_uint32_type
+
 #include "ov-intx.h"
 
 #undef OCTAVE_VALUE_INT_MATRIX_T
@@ -42,6 +44,8 @@
 #undef OCTAVE_INT_T
 #undef OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION
 
+#undef OCTAVE_TYPE_PREDICATE_FUNCTION
+
 #endif
 
 /*
--- a/src/ov-uint64.h
+++ b/src/ov-uint64.h
@@ -32,6 +32,8 @@
 #define OCTAVE_INT_T octave_uint64
 #define OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION uint64_scalar_value
 
+#define OCTAVE_TYPE_PREDICATE_FUNCTION is_uint64_type
+
 #include "ov-intx.h"
 
 #undef OCTAVE_VALUE_INT_MATRIX_T
@@ -42,6 +44,8 @@
 #undef OCTAVE_INT_T
 #undef OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION
 
+#undef OCTAVE_TYPE_PREDICATE_FUNCTION
+
 #endif
 
 /*
--- a/src/ov-uint8.h
+++ b/src/ov-uint8.h
@@ -32,6 +32,8 @@
 #define OCTAVE_INT_T octave_uint8
 #define OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION uint8_scalar_value
 
+#define OCTAVE_TYPE_PREDICATE_FUNCTION is_uint8_type
+
 #include "ov-intx.h"
 
 #undef OCTAVE_VALUE_INT_MATRIX_T
@@ -42,6 +44,8 @@
 #undef OCTAVE_INT_T
 #undef OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION
 
+#undef OCTAVE_TYPE_PREDICATE_FUNCTION
+
 #endif
 
 /*
--- a/src/ov.h
+++ b/src/ov.h
@@ -441,6 +441,40 @@
   octave_value any (int dim = 0) const
     { return rep->any (dim); }
 
+  // Floating point types.
+
+  bool is_double_type (void) const
+    { return rep->is_double_type (); }
+
+  bool is_single_type (void) const
+    { return rep->is_single_type (); }
+
+  // Integer types.
+
+  bool is_int8_type (void) const
+    { return rep->is_int8_type (); }
+
+  bool is_int16_type (void) const
+    { return rep->is_int16_type (); }
+
+  bool is_int32_type (void) const
+    { return rep->is_int32_type (); }
+
+  bool is_int64_type (void) const
+   { return rep->is_int64_type (); }
+
+  bool is_uint8_type (void) const
+    { return rep->is_uint8_type (); }
+
+  bool is_uint16_type (void) const
+    { return rep->is_uint16_type (); }
+
+  bool is_uint32_type (void) const
+    { return rep->is_uint32_type (); }
+
+  bool is_uint64_type (void) const
+    { return rep->is_uint64_type (); }
+
   // Other type stuff.
 
   bool is_bool_type (void) const