# HG changeset patch # User Jaroslav Hajek # Date 1230393712 -3600 # Node ID f00578b495e9512e5c829b0097f9b08efe9667be # Parent 342f72c1df1aef5ff2e5f4b1fd9342d8271263f7 remove valid_as_scalar_index diff -r 342f72c1df1a -r f00578b495e9 src/ChangeLog --- a/src/ChangeLog Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ChangeLog Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/oct-obj.cc --- a/src/oct-obj.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/oct-obj.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/oct-obj.h --- a/src/oct-obj.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/oct-obj.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-base-diag.cc --- a/src/ov-base-diag.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-base-diag.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-base-diag.h --- a/src/ov-base-diag.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-base-diag.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-base-scalar.cc --- a/src/ov-base-scalar.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-base-scalar.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-base.h --- a/src/ov-base.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-base.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-bool-mat.cc --- a/src/ov-bool-mat.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-bool-mat.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-bool-mat.h --- a/src/ov-bool-mat.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-bool-mat.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-bool-sparse.cc --- a/src/ov-bool-sparse.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-bool-sparse.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-bool-sparse.h --- a/src/ov-bool-sparse.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-bool-sparse.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-bool.cc --- a/src/ov-bool.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-bool.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-bool.h --- a/src/ov-bool.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-bool.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-ch-mat.cc --- a/src/ov-ch-mat.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-ch-mat.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-ch-mat.h --- a/src/ov-ch-mat.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-ch-mat.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-colon.h --- a/src/ov-colon.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-colon.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-complex.cc --- a/src/ov-complex.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-complex.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-complex.h --- a/src/ov-complex.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-complex.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-cx-mat.cc --- a/src/ov-cx-mat.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-cx-mat.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-cx-mat.h --- a/src/ov-cx-mat.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-cx-mat.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-cx-sparse.cc --- a/src/ov-cx-sparse.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-cx-sparse.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-cx-sparse.h --- a/src/ov-cx-sparse.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-cx-sparse.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-float.cc --- a/src/ov-float.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-float.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-float.h --- a/src/ov-float.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-float.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-flt-complex.cc --- a/src/ov-flt-complex.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-flt-complex.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-flt-complex.h --- a/src/ov-flt-complex.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-flt-complex.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-flt-cx-mat.cc --- a/src/ov-flt-cx-mat.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-flt-cx-mat.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-flt-cx-mat.h --- a/src/ov-flt-cx-mat.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-flt-cx-mat.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-flt-re-mat.cc --- a/src/ov-flt-re-mat.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-flt-re-mat.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-flt-re-mat.h --- a/src/ov-flt-re-mat.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-flt-re-mat.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-intx.h --- a/src/ov-intx.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-intx.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-perm.cc --- a/src/ov-perm.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-perm.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-perm.h --- a/src/ov-perm.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-perm.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-range.h --- a/src/ov-range.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-range.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-re-mat.cc --- a/src/ov-re-mat.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-re-mat.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-re-mat.h --- a/src/ov-re-mat.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-re-mat.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-re-sparse.cc --- a/src/ov-re-sparse.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-re-sparse.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-re-sparse.h --- a/src/ov-re-sparse.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-re-sparse.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-scalar.cc --- a/src/ov-scalar.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-scalar.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-scalar.h --- a/src/ov-scalar.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-scalar.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-str-mat.cc --- a/src/ov-str-mat.cc Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-str-mat.cc Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov-str-mat.h --- a/src/ov-str-mat.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov-str-mat.h Sat Dec 27 17:01:52 2008 +0100 @@ -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 -r 342f72c1df1a -r f00578b495e9 src/ov.h --- a/src/ov.h Fri Dec 26 22:54:38 2008 +0100 +++ b/src/ov.h Sat Dec 27 17:01:52 2008 +0100 @@ -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