# HG changeset patch # User John W. Eaton # Date 1205202289 14400 # Node ID 7ebdc99a0babb6a33a585337b9e5165801c383ae # Parent d20a2f261306cf26375717c45d40736fb1c0a1ac new isfloat function diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,16 @@ 2008-03-10 John W. Eaton + * data.cc (Fisfloat): New function. + * ov.h (octave_value::is_float_type): Ditto. + * ov-base.h (octave_base_value::is_float_type): Ditto. + * ov-complex.h (octave_complex): Ditto. + * ov-cx-mat.h (octave_complex_matrix): Ditto. + * ov-cx-sparse.h (octave_sparse_complex_matrix): Ditto. + * ov-range.h (octave_range): Ditto. + * ov-re-mat.h (octave_matrix): Ditto. + * ov-re-sparse.h (octave_sparse_matrix): Ditto. + * ov-scalar.h (octave_scalar): Ditto. + * mxarray.h.in (mxLogical): Use unsigned char instead of int. From Antwerpen, G. (Gert) van . diff --git a/src/data.cc b/src/data.cc --- a/src/data.cc +++ b/src/data.cc @@ -1870,6 +1870,22 @@ return retval; } +DEFUN (isfloat, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} isfloat (@var{x})\n\ +Return true if @var{x} is a floating-point numeric object.\n\ +@end deftypefn") +{ + octave_value retval; + + if (args.length () == 1) + retval = args(0).is_float_type (); + else + print_usage (); + + return retval; +} + // FIXME -- perhaps this should be implemented with an // octave_value member function? diff --git a/src/ov-base.h b/src/ov-base.h --- a/src/ov-base.h +++ b/src/ov-base.h @@ -242,6 +242,8 @@ virtual bool is_single_type (void) const { return false; } + virtual bool is_float_type (void) const { return false; } + virtual bool is_int8_type (void) const { return false; } virtual bool is_int16_type (void) const { return false; } diff --git a/src/ov-complex.h b/src/ov-complex.h --- a/src/ov-complex.h +++ b/src/ov-complex.h @@ -91,6 +91,8 @@ bool is_double_type (void) const { return true; } + bool is_float_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 --git a/src/ov-cx-mat.h b/src/ov-cx-mat.h --- a/src/ov-cx-mat.h +++ b/src/ov-cx-mat.h @@ -98,6 +98,8 @@ bool is_double_type (void) const { return true; } + bool is_float_type (void) const { return true; } + bool valid_as_scalar_index (void) const; double double_value (bool = false) const; diff --git a/src/ov-cx-sparse.h b/src/ov-cx-sparse.h --- a/src/ov-cx-sparse.h +++ b/src/ov-cx-sparse.h @@ -104,6 +104,8 @@ bool is_double_type (void) const { return true; } + bool is_float_type (void) const { return true; } + bool valid_as_scalar_index (void) const; double double_value (bool = false) const; diff --git a/src/ov-range.h b/src/ov-range.h --- a/src/ov-range.h +++ b/src/ov-range.h @@ -143,6 +143,8 @@ bool is_double_type (void) const { return true; } + bool is_float_type (void) const { return true; } + bool valid_as_scalar_index (void) const { double b = range.base (); diff --git a/src/ov-re-mat.h b/src/ov-re-mat.h --- a/src/ov-re-mat.h +++ b/src/ov-re-mat.h @@ -97,6 +97,8 @@ bool is_double_type (void) const { return true; } + bool is_float_type (void) const { return true; } + bool valid_as_scalar_index (void) const; int8NDArray diff --git a/src/ov-re-sparse.h b/src/ov-re-sparse.h --- a/src/ov-re-sparse.h +++ b/src/ov-re-sparse.h @@ -100,6 +100,8 @@ bool is_double_type (void) const { return true; } + bool is_float_type (void) const { return true; } + bool valid_as_scalar_index (void) const; double double_value (bool = false) const; diff --git a/src/ov-scalar.h b/src/ov-scalar.h --- a/src/ov-scalar.h +++ b/src/ov-scalar.h @@ -87,6 +87,8 @@ bool is_double_type (void) const { return true; } + bool is_float_type (void) const { return true; } + bool valid_as_scalar_index (void) const { return (! xisnan (scalar) diff --git a/src/ov.h b/src/ov.h --- a/src/ov.h +++ b/src/ov.h @@ -482,6 +482,9 @@ bool is_single_type (void) const { return rep->is_single_type (); } + bool is_float_type (void) const + { return rep->is_float_type (); } + // Integer types. bool is_int8_type (void) const