# HG changeset patch # User Jaroslav Hajek # Date 1230393712 -3600 # Node ID f00578b495e9512e5c829b0097f9b08efe9667be # Parent 342f72c1df1aef5ff2e5f4b1fd9342d8271263f7 remove valid_as_scalar_index diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,19 @@ +2008-12-27 Jaroslav Hajek + + * oct-obj.h, oct-obj.cc (octave_value_list::valid_scalar_indices): Remove. + * ov-base-diag.cc, ov-base-diag.h, ov-base-scalar.cc, ov-base.h, + ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool-sparse.h, + ov-bool.cc, ov-bool.h, ov-ch-mat.cc, ov-ch-mat.h, ov-colon.h, + ov-complex.cc, ov-complex.h, ov-cx-mat.cc, ov-cx-mat.h, + ov-cx-sparse.cc, ov-cx-sparse.h, ov-float.cc, ov-float.h, + ov-flt-complex.cc, ov-flt-complex.h, ov-flt-cx-mat.cc, + ov-flt-cx-mat.h, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-intx.h, + ov-perm.cc, ov-perm.h, ov-range.h, ov-re-mat.cc, ov-re-mat.h, + ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.cc, ov-scalar.h, + ov-str-mat.cc, ov-str-mat.h, ov.h: + Remove valid_as_scalar_index and valid_as_zero_index methods + from octave_value, octave_base_value and all of its subclasses. + 2008-12-26 Francesco Potortì * data.cc (resize): Add cross reference to postpad. diff --git a/src/oct-obj.cc b/src/oct-obj.cc --- a/src/oct-obj.cc +++ b/src/oct-obj.cc @@ -31,18 +31,6 @@ octave_allocator octave_value_list::allocator (sizeof (octave_value_list)); -bool -octave_value_list::valid_scalar_indices (void) const -{ - octave_idx_type n = length (); - - for (octave_idx_type i = 0; i < n; i++) - if (! data[i].valid_as_scalar_index ()) - return false; - - return true; -} - void octave_value_list::resize (octave_idx_type n, const octave_value& val) { diff --git a/src/oct-obj.h b/src/oct-obj.h --- a/src/oct-obj.h +++ b/src/oct-obj.h @@ -83,8 +83,6 @@ return *this; } - bool valid_scalar_indices (void) const; - // Assignment will resize on range errors. octave_value& operator () (octave_idx_type n) { return elem (n); } diff --git a/src/ov-base-diag.cc b/src/ov-base-diag.cc --- a/src/ov-base-diag.cc +++ b/src/ov-base-diag.cc @@ -219,14 +219,6 @@ return to_dense ().is_true (); } -template -bool -octave_base_diag::valid_as_scalar_index (void) const -{ - // FIXME - return false; -} - // FIXME: this should be achieveable using ::real template inline T helper_getreal (T x) { return x; } template inline T helper_getreal (std::complex x) { return x.real (); } diff --git a/src/ov-base-diag.h b/src/ov-base-diag.h --- a/src/ov-base-diag.h +++ b/src/ov-base-diag.h @@ -116,8 +116,6 @@ bool is_diag_matrix (void) const { return true; } - bool valid_as_scalar_index (void) const; - double double_value (bool = false) const; float float_value (bool = false) const; diff --git a/src/ov-base-scalar.cc b/src/ov-base-scalar.cc --- a/src/ov-base-scalar.cc +++ b/src/ov-base-scalar.cc @@ -75,14 +75,7 @@ case '(': { if (type.length () == 1) - { - if (idx.front().valid_scalar_indices () - && rhs.is_scalar_type () - && rhs.is_numeric_type ()) - retval = rhs; - else - retval = numeric_assign (type, idx, rhs); - } + retval = numeric_assign (type, idx, rhs); else { std::string nm = type_name (); diff --git a/src/ov-base.h b/src/ov-base.h --- a/src/ov-base.h +++ b/src/ov-base.h @@ -302,10 +302,6 @@ virtual bool is_sparse_type (void) const { return false; } - virtual bool valid_as_scalar_index (void) const { return false; } - - virtual bool valid_as_zero_index (void) const { return false; } - virtual bool is_true (void) const { return false; } virtual bool is_null_value (void) const { return false; } diff --git a/src/ov-bool-mat.cc b/src/ov-bool-mat.cc --- a/src/ov-bool-mat.cc +++ b/src/ov-bool-mat.cc @@ -89,13 +89,6 @@ return retval; } -bool -octave_bool_matrix::valid_as_scalar_index (void) const -{ - // FIXME - return false; -} - double octave_bool_matrix::double_value (bool) const { diff --git a/src/ov-bool-mat.h b/src/ov-bool-mat.h --- a/src/ov-bool-mat.h +++ b/src/ov-bool-mat.h @@ -85,8 +85,6 @@ bool is_real_type (void) const { return true; } - bool valid_as_scalar_index (void) const; - int8NDArray int8_array_value (void) const { return int8NDArray (matrix); } diff --git a/src/ov-bool-sparse.cc b/src/ov-bool-sparse.cc --- a/src/ov-bool-sparse.cc +++ b/src/ov-bool-sparse.cc @@ -92,13 +92,6 @@ return retval; } -bool -octave_sparse_bool_matrix::valid_as_scalar_index (void) const -{ - // FIXME - return false; -} - double octave_sparse_bool_matrix::double_value (bool) const { diff --git a/src/ov-bool-sparse.h b/src/ov-bool-sparse.h --- a/src/ov-bool-sparse.h +++ b/src/ov-bool-sparse.h @@ -94,8 +94,6 @@ bool is_real_type (void) const { return true; } - bool valid_as_scalar_index (void) const; - double double_value (bool = false) const; double scalar_value (bool frc_str_conv = false) const diff --git a/src/ov-bool.cc b/src/ov-bool.cc --- a/src/ov-bool.cc +++ b/src/ov-bool.cc @@ -66,43 +66,22 @@ } -static inline bool -valid_scalar_indices (const octave_value_list& args) -{ - int nargin = args.length (); - - for (int i = 0; i < nargin; i++) - if (! args(i).valid_as_scalar_index ()) - return false; - - return true; -} - octave_value octave_bool::do_index_op (const octave_value_list& idx, bool resize_ok) { - octave_value retval; + // FIXME -- this doesn't solve the problem of + // + // a = 1; a([1,1], [1,1], [1,1]) + // + // and similar constructions. Hmm... - if (valid_scalar_indices (idx)) - retval = scalar; - else - { - // FIXME -- this doesn't solve the problem of - // - // a = 1; a([1,1], [1,1], [1,1]) - // - // and similar constructions. Hmm... + // FIXME -- using this constructor avoids narrowing the + // 1x1 matrix back to a scalar value. Need a better solution + // to this problem. - // FIXME -- using this constructor avoids narrowing the - // 1x1 matrix back to a scalar value. Need a better solution - // to this problem. + octave_value tmp (new octave_bool_matrix (bool_matrix_value ())); - octave_value tmp (new octave_bool_matrix (bool_matrix_value ())); - - retval = tmp.do_index_op (idx, resize_ok); - } - - return retval; + return tmp.do_index_op (idx, resize_ok); } octave_value diff --git a/src/ov-bool.h b/src/ov-bool.h --- a/src/ov-bool.h +++ b/src/ov-bool.h @@ -81,10 +81,6 @@ bool is_real_type (void) const { return true; } - bool valid_as_scalar_index (void) const { return scalar; } - - bool valid_as_zero_index (void) const { return ! scalar; } - bool is_true (void) const { return scalar; } int8NDArray diff --git a/src/ov-ch-mat.cc b/src/ov-ch-mat.cc --- a/src/ov-ch-mat.cc +++ b/src/ov-ch-mat.cc @@ -54,14 +54,6 @@ return idx_vector (array_value (true)); } -bool -octave_char_matrix::valid_as_scalar_index (void) const -{ - bool retval = false; - error ("octave_char_matrix::valid_as_scalar_index(): not implemented"); - return retval; -} - double octave_char_matrix::double_value (bool) const { diff --git a/src/ov-ch-mat.h b/src/ov-ch-mat.h --- a/src/ov-ch-mat.h +++ b/src/ov-ch-mat.h @@ -87,8 +87,6 @@ bool is_real_type (void) const { return true; } - bool valid_as_scalar_index (void) const; - double double_value (bool = false) const; float float_value (bool = false) const; diff --git a/src/ov-colon.h b/src/ov-colon.h --- a/src/ov-colon.h +++ b/src/ov-colon.h @@ -67,10 +67,6 @@ bool is_magic_colon (void) const { return true; } - bool valid_as_scalar_index (void) const { return true; } - - bool valid_as_zero_index (void) const { return false; } - void print (std::ostream& os, bool pr_as_read_syntax = false) const; void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; diff --git a/src/ov-complex.cc b/src/ov-complex.cc --- a/src/ov-complex.cc +++ b/src/ov-complex.cc @@ -86,28 +86,19 @@ octave_value octave_complex::do_index_op (const octave_value_list& idx, bool resize_ok) { - octave_value retval; + // FIXME -- this doesn't solve the problem of + // + // a = i; a([1,1], [1,1], [1,1]) + // + // and similar constructions. Hmm... - if (idx.valid_scalar_indices ()) - retval = scalar; - else - { - // FIXME -- this doesn't solve the problem of - // - // a = i; a([1,1], [1,1], [1,1]) - // - // and similar constructions. Hmm... + // FIXME -- using this constructor avoids narrowing the + // 1x1 matrix back to a scalar value. Need a better solution + // to this problem. - // FIXME -- using this constructor avoids narrowing the - // 1x1 matrix back to a scalar value. Need a better solution - // to this problem. + octave_value tmp (new octave_complex_matrix (complex_matrix_value ())); - octave_value tmp (new octave_complex_matrix (complex_matrix_value ())); - - retval = tmp.do_index_op (idx, resize_ok); - } - - return retval; + return tmp.do_index_op (idx, resize_ok); } double diff --git a/src/ov-complex.h b/src/ov-complex.h --- a/src/ov-complex.h +++ b/src/ov-complex.h @@ -95,10 +95,6 @@ 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; } - double double_value (bool = false) const; float float_value (bool = false) const; diff --git a/src/ov-cx-mat.cc b/src/ov-cx-mat.cc --- a/src/ov-cx-mat.cc +++ b/src/ov-cx-mat.cc @@ -132,13 +132,6 @@ matrix.assign (ra_idx, rhs); } -bool -octave_complex_matrix::valid_as_scalar_index (void) const -{ - // FIXME - return false; -} - double octave_complex_matrix::double_value (bool force_conversion) const { 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 @@ -102,8 +102,6 @@ bool is_float_type (void) const { return true; } - bool valid_as_scalar_index (void) const; - double double_value (bool = false) const; float float_value (bool = false) const; diff --git a/src/ov-cx-sparse.cc b/src/ov-cx-sparse.cc --- a/src/ov-cx-sparse.cc +++ b/src/ov-cx-sparse.cc @@ -120,13 +120,6 @@ ::assign (matrix, rhs); } -bool -octave_sparse_complex_matrix::valid_as_scalar_index (void) const -{ - // FIXME - return false; -} - double octave_sparse_complex_matrix::double_value (bool force_conversion) 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 @@ -105,8 +105,6 @@ bool is_float_type (void) const { return true; } - bool valid_as_scalar_index (void) const; - double double_value (bool = false) const; double scalar_value (bool frc_str_conv = false) const diff --git a/src/ov-float.cc b/src/ov-float.cc --- a/src/ov-float.cc +++ b/src/ov-float.cc @@ -60,28 +60,19 @@ octave_value octave_float_scalar::do_index_op (const octave_value_list& idx, bool resize_ok) { - octave_value retval; + // FIXME -- this doesn't solve the problem of + // + // a = 1; a([1,1], [1,1], [1,1]) + // + // and similar constructions. Hmm... - if (idx.valid_scalar_indices ()) - retval = scalar; - else - { - // FIXME -- this doesn't solve the problem of - // - // a = 1; a([1,1], [1,1], [1,1]) - // - // and similar constructions. Hmm... + // FIXME -- using this constructor avoids narrowing the + // 1x1 matrix back to a scalar value. Need a better solution + // to this problem. - // FIXME -- using this constructor avoids narrowing the - // 1x1 matrix back to a scalar value. Need a better solution - // to this problem. + octave_value tmp (new octave_matrix (matrix_value ())); - octave_value tmp (new octave_matrix (matrix_value ())); - - retval = tmp.do_index_op (idx, resize_ok); - } - - return retval; + return tmp.do_index_op (idx, resize_ok); } octave_value diff --git a/src/ov-float.h b/src/ov-float.h --- a/src/ov-float.h +++ b/src/ov-float.h @@ -90,20 +90,6 @@ bool is_float_type (void) const { return true; } - bool valid_as_scalar_index (void) const - { - return (! xisnan (scalar) - && F_NINT (scalar) == scalar - && NINTbig (scalar) == 1); - } - - bool valid_as_zero_index (void) const - { - return (! xisnan (scalar) - && F_NINT (scalar) == scalar - && NINTbig (scalar) == 0); - } - int8NDArray int8_array_value (void) const { return int8NDArray (dim_vector (1, 1), scalar); } diff --git a/src/ov-flt-complex.cc b/src/ov-flt-complex.cc --- a/src/ov-flt-complex.cc +++ b/src/ov-flt-complex.cc @@ -71,28 +71,19 @@ octave_value octave_float_complex::do_index_op (const octave_value_list& idx, bool resize_ok) { - octave_value retval; + // FIXME -- this doesn't solve the problem of + // + // a = i; a([1,1], [1,1], [1,1]) + // + // and similar constructions. Hmm... - if (idx.valid_scalar_indices ()) - retval = scalar; - else - { - // FIXME -- this doesn't solve the problem of - // - // a = i; a([1,1], [1,1], [1,1]) - // - // and similar constructions. Hmm... + // FIXME -- using this constructor avoids narrowing the + // 1x1 matrix back to a scalar value. Need a better solution + // to this problem. - // FIXME -- using this constructor avoids narrowing the - // 1x1 matrix back to a scalar value. Need a better solution - // to this problem. + octave_value tmp (new octave_float_complex_matrix (float_complex_matrix_value ())); - octave_value tmp (new octave_float_complex_matrix (float_complex_matrix_value ())); - - retval = tmp.do_index_op (idx, resize_ok); - } - - return retval; + return tmp.do_index_op (idx, resize_ok); } double diff --git a/src/ov-flt-complex.h b/src/ov-flt-complex.h --- a/src/ov-flt-complex.h +++ b/src/ov-flt-complex.h @@ -93,10 +93,6 @@ 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; } - double double_value (bool = false) const; float float_value (bool = false) const; diff --git a/src/ov-flt-cx-mat.cc b/src/ov-flt-cx-mat.cc --- a/src/ov-flt-cx-mat.cc +++ b/src/ov-flt-cx-mat.cc @@ -121,13 +121,6 @@ matrix.assign (ra_idx, rhs); } -bool -octave_float_complex_matrix::valid_as_scalar_index (void) const -{ - // FIXME - return false; -} - double octave_float_complex_matrix::double_value (bool force_conversion) const { diff --git a/src/ov-flt-cx-mat.h b/src/ov-flt-cx-mat.h --- a/src/ov-flt-cx-mat.h +++ b/src/ov-flt-cx-mat.h @@ -100,8 +100,6 @@ bool is_float_type (void) const { return true; } - bool valid_as_scalar_index (void) const; - double double_value (bool = false) const; float float_value (bool = false) const; diff --git a/src/ov-flt-re-mat.cc b/src/ov-flt-re-mat.cc --- a/src/ov-flt-re-mat.cc +++ b/src/ov-flt-re-mat.cc @@ -90,13 +90,6 @@ return retval; } -bool -octave_float_matrix::valid_as_scalar_index (void) const -{ - // FIXME - return false; -} - double octave_float_matrix::double_value (bool) const { diff --git a/src/ov-flt-re-mat.h b/src/ov-flt-re-mat.h --- a/src/ov-flt-re-mat.h +++ b/src/ov-flt-re-mat.h @@ -98,8 +98,6 @@ bool is_float_type (void) const { return true; } - bool valid_as_scalar_index (void) const; - int8NDArray int8_array_value (void) const { return int8NDArray (matrix); } diff --git a/src/ov-intx.h b/src/ov-intx.h --- a/src/ov-intx.h +++ b/src/ov-intx.h @@ -407,30 +407,21 @@ octave_value do_index_op (const octave_value_list& idx, bool resize_ok = false) { - octave_value retval; - - if (idx.valid_scalar_indices ()) - retval = scalar; - else - { - // FIXME -- this doesn't solve the problem of - // - // a = 1; a([1,1], [1,1], [1,1]) - // - // and similar constructions. Hmm... + // FIXME -- this doesn't solve the problem of + // + // a = 1; a([1,1], [1,1], [1,1]) + // + // and similar constructions. Hmm... - // FIXME -- using this constructor avoids narrowing the - // 1x1 matrix back to a scalar value. Need a better solution - // to this problem. + // FIXME -- using this constructor avoids narrowing the + // 1x1 matrix back to a scalar value. Need a better solution + // to this problem. - octave_value tmp - (new OCTAVE_VALUE_INT_MATRIX_T - (OCTAVE_VALUE_INT_NDARRAY_EXTRACTOR_FUNCTION ())); + octave_value tmp + (new OCTAVE_VALUE_INT_MATRIX_T + (OCTAVE_VALUE_INT_NDARRAY_EXTRACTOR_FUNCTION ())); - retval = tmp.do_index_op (idx, resize_ok); - } - - return retval; + return tmp.do_index_op (idx, resize_ok); } bool OCTAVE_TYPE_PREDICATE_FUNCTION (void) const { return true; } diff --git a/src/ov-perm.cc b/src/ov-perm.cc --- a/src/ov-perm.cc +++ b/src/ov-perm.cc @@ -123,12 +123,6 @@ return to_dense ().is_true (); } -bool -octave_perm_matrix::valid_as_scalar_index (void) const -{ - return false; -} - double octave_perm_matrix::double_value (bool) const { diff --git a/src/ov-perm.h b/src/ov-perm.h --- a/src/ov-perm.h +++ b/src/ov-perm.h @@ -111,8 +111,6 @@ bool is_true (void) const; - bool valid_as_scalar_index (void) const; - double double_value (bool = false) const; float float_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 @@ -144,20 +144,6 @@ bool is_float_type (void) const { return true; } - bool valid_as_scalar_index (void) const - { - double b = range.base (); - return (range.nelem () == 1 - && ! xisnan (b) && D_NINT (b) == b && NINTbig (b) == 1); - } - - bool valid_as_zero_index (void) const - { - double b = range.base (); - return (range.nelem () == 1 - && ! xisnan (b) && D_NINT (b) == b && NINTbig (b) == 0); - } - bool is_numeric_type (void) const { return true; } bool is_true (void) const; diff --git a/src/ov-re-mat.cc b/src/ov-re-mat.cc --- a/src/ov-re-mat.cc +++ b/src/ov-re-mat.cc @@ -103,13 +103,6 @@ return retval; } -bool -octave_matrix::valid_as_scalar_index (void) const -{ - // FIXME - return false; -} - double octave_matrix::double_value (bool) const { 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 @@ -100,8 +100,6 @@ bool is_float_type (void) const { return true; } - bool valid_as_scalar_index (void) const; - int8NDArray int8_array_value (void) const { return int8NDArray (matrix); } diff --git a/src/ov-re-sparse.cc b/src/ov-re-sparse.cc --- a/src/ov-re-sparse.cc +++ b/src/ov-re-sparse.cc @@ -92,13 +92,6 @@ return retval; } -bool -octave_sparse_matrix::valid_as_scalar_index (void) const -{ - // FIXME - return false; -} - double octave_sparse_matrix::double_value (bool) const { 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 @@ -101,8 +101,6 @@ bool is_float_type (void) const { return true; } - bool valid_as_scalar_index (void) const; - double double_value (bool = false) const; double scalar_value (bool frc_str_conv = false) const diff --git a/src/ov-scalar.cc b/src/ov-scalar.cc --- a/src/ov-scalar.cc +++ b/src/ov-scalar.cc @@ -75,28 +75,19 @@ octave_value octave_scalar::do_index_op (const octave_value_list& idx, bool resize_ok) { - octave_value retval; + // FIXME -- this doesn't solve the problem of + // + // a = 1; a([1,1], [1,1], [1,1]) + // + // and similar constructions. Hmm... - if (idx.valid_scalar_indices ()) - retval = scalar; - else - { - // FIXME -- this doesn't solve the problem of - // - // a = 1; a([1,1], [1,1], [1,1]) - // - // and similar constructions. Hmm... + // FIXME -- using this constructor avoids narrowing the + // 1x1 matrix back to a scalar value. Need a better solution + // to this problem. - // FIXME -- using this constructor avoids narrowing the - // 1x1 matrix back to a scalar value. Need a better solution - // to this problem. + octave_value tmp (new octave_matrix (matrix_value ())); - octave_value tmp (new octave_matrix (matrix_value ())); - - retval = tmp.do_index_op (idx, resize_ok); - } - - return retval; + return tmp.do_index_op (idx, resize_ok); } octave_value diff --git a/src/ov-scalar.h b/src/ov-scalar.h --- a/src/ov-scalar.h +++ b/src/ov-scalar.h @@ -91,20 +91,6 @@ bool is_float_type (void) const { return true; } - bool valid_as_scalar_index (void) const - { - return (! xisnan (scalar) - && D_NINT (scalar) == scalar - && NINTbig (scalar) == 1); - } - - bool valid_as_zero_index (void) const - { - return (! xisnan (scalar) - && D_NINT (scalar) == scalar - && NINTbig (scalar) == 0); - } - int8NDArray int8_array_value (void) const { return int8NDArray (dim_vector (1, 1), scalar); } diff --git a/src/ov-str-mat.cc b/src/ov-str-mat.cc --- a/src/ov-str-mat.cc +++ b/src/ov-str-mat.cc @@ -142,14 +142,6 @@ return octave_value (retval, true); } -bool -octave_char_matrix_str::valid_as_scalar_index (void) const -{ - bool retval = false; - error ("octave_char_matrix_str::valid_as_scalar_index(): not implemented"); - return retval; -} - #define CHAR_MATRIX_CONV(T, INIT, TNAME, FCN) \ T retval INIT; \ \ diff --git a/src/ov-str-mat.h b/src/ov-str-mat.h --- a/src/ov-str-mat.h +++ b/src/ov-str-mat.h @@ -107,8 +107,6 @@ bool is_numeric_type (void) const { return false; } - bool valid_as_scalar_index (void) const; - double double_value (bool = false) const; Matrix matrix_value (bool = false) const; diff --git a/src/ov.h b/src/ov.h --- a/src/ov.h +++ b/src/ov.h @@ -570,12 +570,6 @@ bool is_sparse_type (void) const { return rep->is_sparse_type (); } - bool valid_as_scalar_index (void) const - { return rep->valid_as_scalar_index (); } - - bool valid_as_zero_index (void) const - { return rep->valid_as_zero_index (); } - // Does this constant correspond to a truth value? bool is_true (void) const