# HG changeset patch
# User David Bateman
# Date 1371664645 -7200
# Node ID 95d4850cddd551c2747855aea8be357ab6f84bac
# Parent 3542e106c496f04c339946ff6b9d67c3c5305e7f
Specialize is_empty and numel methods for sparse matrices (debian bug #706376)
* ov-base.h (virtual bool is_empty (void) const) : Make method virtual
* ov-base-sparse.h (bool is_empty (void) const)) : Declare new method
(octave_idx_type numel (void) const): New method.
* ov-base-sparse.cc (template bool octave_base_sparse:is_empty
(void) const)) : Define new method
* lo-array-gripes.cc (vois gripe_index_value (void)): Clarify error message
diff --git a/libinterp/octave-value/ov-base-sparse.cc b/libinterp/octave-value/ov-base-sparse.cc
--- a/libinterp/octave-value/ov-base-sparse.cc
+++ b/libinterp/octave-value/ov-base-sparse.cc
@@ -278,6 +278,15 @@
template
bool
+octave_base_sparse::is_empty (void) const
+{
+ dim_vector dv = dims ();
+
+ return (dv.any_zero ());
+}
+
+template
+bool
octave_base_sparse::print_as_scalar (void) const
{
dim_vector dv = dims ();
diff --git a/libinterp/octave-value/ov-base-sparse.h b/libinterp/octave-value/ov-base-sparse.h
--- a/libinterp/octave-value/ov-base-sparse.h
+++ b/libinterp/octave-value/ov-base-sparse.h
@@ -72,6 +72,8 @@
~octave_base_sparse (void) { }
+ octave_idx_type numel (void) const { return dims ().safe_numel (); }
+
octave_idx_type nnz (void) const { return matrix.nnz (); }
octave_idx_type nzmax (void) const { return matrix.nzmax (); }
@@ -137,6 +139,8 @@
bool is_defined (void) const { return true; }
+ bool is_empty (void) const;
+
bool is_constant (void) const { return true; }
bool is_true (void) const;
diff --git a/libinterp/octave-value/ov-base.h b/libinterp/octave-value/ov-base.h
--- a/libinterp/octave-value/ov-base.h
+++ b/libinterp/octave-value/ov-base.h
@@ -331,7 +331,7 @@
virtual bool is_defined (void) const { return false; }
- bool is_empty (void) const { return numel () == 0; }
+ virtual bool is_empty (void) const { return numel () == 0; }
virtual bool is_cell (void) const { return false; }
diff --git a/liboctave/util/lo-array-gripes.cc b/liboctave/util/lo-array-gripes.cc
--- a/liboctave/util/lo-array-gripes.cc
+++ b/liboctave/util/lo-array-gripes.cc
@@ -130,7 +130,11 @@
const char *err_id = error_id_invalid_index;
(*current_liboctave_error_with_id_handler)
- (err_id, "subscript indices must be either positive integers or logicals");
+#ifdef USE_64_BIT_IDX_T
+ (err_id, "subscript indices must be either positive integers less than 2^63 or logicals");
+#else
+ (err_id, "subscript indices must be either positive integers less than 2^31 or logicals");
+#endif
}
// FIXME -- the following is a common error message to resize,