# HG changeset patch
# User David Bateman
# Date 1371308306 -7200
# Node ID d5c61e2aefa428e9b51d5671ff1e72e7de90a500
# Parent 1c8b6ab2c8ae71f1fdef51016472396a6665f483
Specialize is_empty method for sparse matrices
* ov-base.h (virtual bool is_empty (void) const) : Make method virtual
* ov-base-sparse.h (bool is_empty (void) const)) : Declare new method
* ov-base-sparse.cc (template bool octave_base_sparse:is_empty
(void) const)) : Define new method
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
@@ -137,6 +137,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; }