# HG changeset patch # User jwe # Date 1153274327 0 # Node ID b9c45e0cf685bbc489690659ac32e8804dab126e # Parent acf8b96ca9c96d48a9b797a06c0aaded2689a0ce [project @ 2006-07-19 01:57:44 by jwe] diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ChangeLog --- a/src/ChangeLog Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ChangeLog Wed Jul 19 01:58:47 2006 +0000 @@ -1,3 +1,35 @@ +2006-07-18 John W. Eaton + + * 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 * ov-typeinfo.cc: Also instantiate arrays of assignany_ops. diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-base.h --- a/src/ov-base.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-base.h Wed Jul 19 01:58:47 2006 +0000 @@ -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; } diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-complex.h --- a/src/ov-complex.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-complex.h Wed Jul 19 01:58:47 2006 +0000 @@ -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; } diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-cx-mat.h --- a/src/ov-cx-mat.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-cx-mat.h Wed Jul 19 01:58:47 2006 +0000 @@ -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; diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-cx-sparse.h --- a/src/ov-cx-sparse.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-cx-sparse.h Wed Jul 19 01:58:47 2006 +0000 @@ -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; diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-int16.h --- a/src/ov-int16.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-int16.h Wed Jul 19 01:58:47 2006 +0000 @@ -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 /* diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-int32.h --- a/src/ov-int32.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-int32.h Wed Jul 19 01:58:47 2006 +0000 @@ -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 /* diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-int64.h --- a/src/ov-int64.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-int64.h Wed Jul 19 01:58:47 2006 +0000 @@ -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 /* diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-int8.h --- a/src/ov-int8.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-int8.h Wed Jul 19 01:58:47 2006 +0000 @@ -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 /* diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-intx.h --- a/src/ov-intx.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-intx.h Wed Jul 19 01:58:47 2006 +0000 @@ -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); } diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-range.h --- a/src/ov-range.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-range.h Wed Jul 19 01:58:47 2006 +0000 @@ -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 (); diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-re-mat.h --- a/src/ov-re-mat.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-re-mat.h Wed Jul 19 01:58:47 2006 +0000 @@ -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 diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-re-sparse.h --- a/src/ov-re-sparse.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-re-sparse.h Wed Jul 19 01:58:47 2006 +0000 @@ -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; diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-scalar.h --- a/src/ov-scalar.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-scalar.h Wed Jul 19 01:58:47 2006 +0000 @@ -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) diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-uint16.h --- a/src/ov-uint16.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-uint16.h Wed Jul 19 01:58:47 2006 +0000 @@ -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 /* diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-uint32.h --- a/src/ov-uint32.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-uint32.h Wed Jul 19 01:58:47 2006 +0000 @@ -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 /* diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-uint64.h --- a/src/ov-uint64.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-uint64.h Wed Jul 19 01:58:47 2006 +0000 @@ -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 /* diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov-uint8.h --- a/src/ov-uint8.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov-uint8.h Wed Jul 19 01:58:47 2006 +0000 @@ -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 /* diff -r acf8b96ca9c9 -r b9c45e0cf685 src/ov.h --- a/src/ov.h Sun Jul 16 22:15:44 2006 +0000 +++ b/src/ov.h Wed Jul 19 01:58:47 2006 +0000 @@ -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