changeset 20974:1edf15793cac

maint: Use is_empty rather than "numel () == 0" for clarity. * daspk.cc, dasrt.cc, dassl.cc, gl-render.cc, lsode.cc, tril.cc, txt-eng-ft.cc, ov-fcn-inline.cc, ov-java.cc, ov-range.cc, ov-struct.cc, Array.cc, Range.cc, chNDArray.cc, dNDArray.cc, fNDArray.cc, DASPK.cc, DASRT.cc, DASSL.cc, LSODE.cc, eigs-base.cc: Use is_empty rather than "numel () == 0" for clarity.
author Rik <rik@octave.org>
date Wed, 23 Dec 2015 21:46:39 -0800
parents 7af34656efed
children b4019ebd45c4
files libinterp/corefcn/daspk.cc libinterp/corefcn/dasrt.cc libinterp/corefcn/dassl.cc libinterp/corefcn/gl-render.cc libinterp/corefcn/lsode.cc libinterp/corefcn/tril.cc libinterp/corefcn/txt-eng-ft.cc libinterp/octave-value/ov-fcn-inline.cc libinterp/octave-value/ov-java.cc libinterp/octave-value/ov-range.cc libinterp/octave-value/ov-struct.cc liboctave/array/Array.cc liboctave/array/Range.cc liboctave/array/chNDArray.cc liboctave/array/dNDArray.cc liboctave/array/fNDArray.cc liboctave/numeric/DASPK.cc liboctave/numeric/DASRT.cc liboctave/numeric/DASSL.cc liboctave/numeric/LSODE.cc liboctave/numeric/eigs-base.cc
diffstat 21 files changed, 50 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/daspk.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/libinterp/corefcn/daspk.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -98,7 +98,7 @@
           if (tlen > 1)
             ires = tmp(1).int_value ();
 
-          if (retval.numel () == 0)
+          if (retval.is_empty ())
             gripe_user_supplied_eval ("daspk");
         }
       else
@@ -147,7 +147,7 @@
 
           retval = tmp(0).matrix_value ();
 
-          if (retval.numel () == 0)
+          if (retval.is_empty ())
             gripe_user_supplied_eval ("daspk");
         }
       else
--- a/libinterp/corefcn/dasrt.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/libinterp/corefcn/dasrt.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -94,7 +94,7 @@
 
           retval = tmp(0).vector_value ();
 
-          if (retval.numel () == 0)
+          if (retval.is_empty ())
             gripe_user_supplied_eval ("dasrt");
         }
       else
@@ -137,7 +137,7 @@
 
           retval = tmp(0).vector_value ();
 
-          if (retval.numel () == 0)
+          if (retval.is_empty ())
             gripe_user_supplied_eval ("dasrt");
         }
       else
@@ -186,7 +186,7 @@
 
           retval = tmp(0).matrix_value ();
 
-          if (retval.numel () == 0)
+          if (retval.is_empty ())
             gripe_user_supplied_eval ("dasrt");
         }
       else
--- a/libinterp/corefcn/dassl.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/libinterp/corefcn/dassl.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -98,7 +98,7 @@
           if (tlen > 1)
             ires = tmp(1).int_value ();
 
-          if (retval.numel () == 0)
+          if (retval.is_empty ())
             gripe_user_supplied_eval ("dassl");
         }
       else
@@ -147,7 +147,7 @@
 
           retval = tmp(0).matrix_value ();
 
-          if (retval.numel () == 0)
+          if (retval.is_empty ())
             gripe_user_supplied_eval ("dassl");
         }
       else
--- a/libinterp/corefcn/gl-render.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/libinterp/corefcn/gl-render.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -861,7 +861,7 @@
 opengl_renderer::draw_axes_planes (const axes::properties& props)
 {
   Matrix axe_color = props.get_color_rgb ();
-  if (axe_color.numel () == 0 || ! props.is_visible ())
+  if (axe_color.is_empty () || ! props.is_visible ())
     return;
 
   double xPlane = props.get_xPlane ();
@@ -2159,20 +2159,19 @@
       Matrix mfcolor = props.get_markerfacecolor_rgb ();
       Matrix cc (1, 3, 0.0);
 
-      if (mecolor.numel () == 0 && props.markeredgecolor_is ("auto"))
+      if (mecolor.is_empty () && props.markeredgecolor_is ("auto"))
         {
           mecolor = props.get_edgecolor_rgb ();
           do_edge = ! props.edgecolor_is ("none");
         }
 
-      if (mfcolor.numel () == 0 && props.markerfacecolor_is ("auto"))
+      if (mfcolor.is_empty () && props.markerfacecolor_is ("auto"))
         {
           mfcolor = props.get_facecolor_rgb ();
           do_face = ! props.facecolor_is ("none");
         }
 
-      if ((mecolor.numel () == 0 || mfcolor.numel () == 0)
-          && c.numel () == 0)
+      if ((mecolor.is_empty () || mfcolor.is_empty ()) && c.is_empty ())
         c = props.get_color_data ().array_value ();
 
       init_marker (props.get_marker (), props.get_markersize (),
@@ -2191,8 +2190,8 @@
               if (x_mat)
                 j1 = j;
 
-              if ((do_edge && mecolor.numel () == 0)
-                  || (do_face && mfcolor.numel () == 0))
+              if ((do_edge && mecolor.is_empty ())
+                  || (do_face && mfcolor.is_empty ()))
                 {
                   if (! xfinite (c(j,i)))
                     continue;  // Skip NaNs in color data
@@ -2201,9 +2200,9 @@
                     cc(k) = c(j,i,k);
                 }
 
-              Matrix lc = (do_edge ? (mecolor.numel () == 0 ? cc : mecolor)
+              Matrix lc = (do_edge ? (mecolor.is_empty () ? cc : mecolor)
                                    : Matrix ());
-              Matrix fc = (do_face ? (mfcolor.numel () == 0 ? cc : mfcolor)
+              Matrix fc = (do_face ? (mfcolor.is_empty () ? cc : mfcolor)
                                    : Matrix ());
 
               draw_marker (x(j1,i), y(j,i1), z(j,i), lc, fc);
@@ -2591,26 +2590,23 @@
 
       bool has_markerfacecolor = false;
 
-      if ((mecolor.numel () == 0 && ! props.markeredgecolor_is ("none"))
-          || (mfcolor.numel () == 0 && ! props.markerfacecolor_is ("none")))
+      if ((mecolor.is_empty () && ! props.markeredgecolor_is ("none"))
+          || (mfcolor.is_empty () && ! props.markerfacecolor_is ("none")))
         {
           Matrix mc = props.get_color_data ().matrix_value ();
 
           if (mc.rows () == 1)
             {
               // Single color specifications, we can simplify a little bit
-
-              if (mfcolor.numel () == 0
-                  && ! props.markerfacecolor_is ("none"))
+              if (mfcolor.is_empty () && ! props.markerfacecolor_is ("none"))
                 mfcolor = mc;
 
-              if (mecolor.numel () == 0
-                  && ! props.markeredgecolor_is ("none"))
+              if (mecolor.is_empty () && ! props.markeredgecolor_is ("none"))
                 mecolor = mc;
             }
           else
             {
-              if (c.numel () == 0)
+              if (c.is_empty ())
                 c = props.get_color_data ().matrix_value ();
               has_markerfacecolor = ((c.numel () > 0)
                                      && (c.rows () == f.rows ()));
@@ -2639,9 +2635,9 @@
                   cc(0) = c(idx,0), cc(1) = c(idx,1), cc(2) = c(idx,2);
               }
 
-            Matrix lc = (do_edge ? (mecolor.numel () == 0 ? cc : mecolor)
+            Matrix lc = (do_edge ? (mecolor.is_empty () ? cc : mecolor)
                                  : Matrix ());
-            Matrix fc = (do_face ? (mfcolor.numel () == 0 ? cc : mfcolor)
+            Matrix fc = (do_face ? (mfcolor.is_empty () ? cc : mfcolor)
                                  : Matrix ());
 
             draw_marker (v(idx,0), v(idx,1), (has_z ? v(idx,2) : 0), lc, fc);
--- a/libinterp/corefcn/lsode.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/libinterp/corefcn/lsode.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -91,7 +91,7 @@
 
           retval = tmp(0).xvector_value ("lsode: expecting user supplied function to return numeric vector");
 
-          if (retval.numel () == 0)
+          if (retval.is_empty ())
             gripe_user_supplied_eval ("lsode");
         }
       else
@@ -133,7 +133,7 @@
 
           retval = tmp(0).xmatrix_value ("lsode: expecting user supplied jacobian function to return numeric array");
 
-          if (retval.numel () == 0)
+          if (retval.is_empty ())
             gripe_user_supplied_eval ("lsode");
         }
       else
--- a/libinterp/corefcn/tril.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/libinterp/corefcn/tril.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -265,7 +265,7 @@
                  name.c_str (), arg.class_name ().c_str ());
 
         octave_value tmp = arg;
-        if (arg.numel () == 0)
+        if (arg.is_empty ())
           return arg;
 
         octave_idx_type nr = dims(0);
--- a/libinterp/corefcn/txt-eng-ft.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/libinterp/corefcn/txt-eng-ft.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -1031,11 +1031,8 @@
   pixels_ = render (elt, box, rot_mode);
   delete elt;
 
-  if (pixels_.numel () == 0)
-    {
-      // nothing to render
-      return;
-    }
+  if (pixels_.is_empty ())
+    return;  // nothing to render
 
   switch (halign)
     {
--- a/libinterp/octave-value/ov-fcn-inline.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/libinterp/octave-value/ov-fcn-inline.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -770,7 +770,7 @@
       // Sort the arguments into ascii order.
       fargs.sort ();
 
-      if (fargs.numel () == 0)
+      if (fargs.is_empty ())
         fargs.append (std::string ("x"));
 
     }
--- a/libinterp/octave-value/ov-java.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/libinterp/octave-value/ov-java.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -1216,7 +1216,7 @@
                       jdoubleArray_ref row (jni_env,
                                             reinterpret_cast<jdoubleArray> (jni_env->GetObjectArrayElement (jarr, r)));
 
-                      if (m.numel () == 0)
+                      if (m.is_empty ())
                         {
                           cols = jni_env->GetArrayLength (row);
                           m.resize (cols, rows);
--- a/libinterp/octave-value/ov-range.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/libinterp/octave-value/ov-range.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -273,7 +273,7 @@
 {
   bool retval = false;
 
-  if (range.numel () != 0)
+  if (! range.numel () != 0)
     {
       // FIXME: this is a potential waste of memory.
 
--- a/libinterp/octave-value/ov-struct.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/libinterp/octave-value/ov-struct.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -83,7 +83,7 @@
   if (p != map.end ())
     retval = map.contents (p);
   else if (auto_add)
-    retval = (numel () == 0) ? Cell (dim_vector (1, 1)) : Cell (dims ());
+    retval = (is_empty ()) ? Cell (dim_vector (1, 1)) : Cell (dims ());
   else
     error_with_id ("Octave:invalid-indexing",
                    "structure has no member '%s'", nm.c_str ());
@@ -1847,7 +1847,7 @@
 
   string_vector keys = m.fieldnames ();
 
-  if (keys.numel () == 0)
+  if (keys.is_empty ())
     retval = Cell (0, 1);
   else
     retval = Cell (keys);
--- a/liboctave/array/Array.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/liboctave/array/Array.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -2370,7 +2370,7 @@
 
   Array<T> m (dv);
 
-  if (m.numel () == 0)
+  if (m.is_empty ())
     return m;
 
   sortmode mode = UNSORTED;
--- a/liboctave/array/Range.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/liboctave/array/Range.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -51,7 +51,7 @@
 Matrix
 Range::matrix_value (void) const
 {
-  if (rng_numel > 0 && cache.numel () == 0)
+  if (rng_numel > 0 && cache.is_empty ())
     {
       cache.resize (1, rng_numel);
 
--- a/liboctave/array/chNDArray.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/liboctave/array/chNDArray.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -112,7 +112,7 @@
   charNDArray tmp (rb.dims ());
   octave_idx_type nel = rb.numel ();
 
-  if (rb.numel () == 0)
+  if (rb.is_empty ())
     return *this;
 
   for (octave_idx_type i = 0; i < nel; i++)
--- a/liboctave/array/dNDArray.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/liboctave/array/dNDArray.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -784,7 +784,7 @@
         }
     }
 
-  if (rb.numel () == 0)
+  if (rb.is_empty ())
     return retval;
 
   retval.insert (rb, ra_idx);
--- a/liboctave/array/fNDArray.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/liboctave/array/fNDArray.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -753,7 +753,7 @@
         }
     }
 
-  if (rb.numel () == 0)
+  if (rb.is_empty ())
     return retval;
 
   retval.insert (rb, ra_idx);
--- a/liboctave/numeric/DASPK.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/liboctave/numeric/DASPK.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -91,7 +91,7 @@
 
   if (ires >= 0)
     {
-      if (tmp_delta.numel () == 0)
+      if (tmp_delta.is_empty ())
         ires = -2;
       else
         {
--- a/liboctave/numeric/DASRT.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/liboctave/numeric/DASRT.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -87,7 +87,7 @@
 
   ColumnVector tmp_fval = (*user_fsub) (tmp_state, tmp_deriv, t, ires);
 
-  if (tmp_fval.numel () == 0)
+  if (tmp_fval.is_empty ())
     ires = -2;
   else
     {
--- a/liboctave/numeric/DASSL.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/liboctave/numeric/DASSL.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -84,7 +84,7 @@
 
   if (ires >= 0)
     {
-      if (tmp_delta.numel () == 0)
+      if (tmp_delta.is_empty ())
         ires = -2;
       else
         {
--- a/liboctave/numeric/LSODE.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/liboctave/numeric/LSODE.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -74,7 +74,7 @@
 
   tmp_deriv = (*user_fun) (*tmp_x, time);
 
-  if (tmp_deriv.numel () == 0)
+  if (tmp_deriv.is_empty ())
     ierr = -1;
   else
     {
--- a/liboctave/numeric/eigs-base.cc	Wed Dec 23 20:45:02 2015 -0800
+++ b/liboctave/numeric/eigs-base.cc	Wed Dec 23 21:46:39 2015 -0800
@@ -829,7 +829,7 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.numel () != 0)
+  if (have_b && cholB && ! permB.is_empty ())
     {
       // Check the we really have a permutation vector
       if (permB.numel () != n)
@@ -880,7 +880,7 @@
         {
           bt = b;
           b = b.transpose ();
-          if (permB.numel () == 0)
+          if (permB.is_empty ())
             {
               permB = ColumnVector (n);
               for (octave_idx_type i = 0; i < n; i++)
@@ -1153,7 +1153,7 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.numel () != 0)
+  if (have_b && cholB && ! permB.is_empty ())
     {
       // Check the we really have a permutation vector
       if (permB.numel () != n)
@@ -1743,7 +1743,7 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.numel () != 0)
+  if (have_b && cholB && ! permB.is_empty ())
     {
       // Check the we really have a permutation vector
       if (permB.numel () != n)
@@ -1794,7 +1794,7 @@
         {
           bt = b;
           b = b.transpose ();
-          if (permB.numel () == 0)
+          if (permB.is_empty ())
             {
               permB = ColumnVector (n);
               for (octave_idx_type i = 0; i < n; i++)
@@ -2116,7 +2116,7 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.numel () != 0)
+  if (have_b && cholB && ! permB.is_empty ())
     {
       // Check that we really have a permutation vector
       if (permB.numel () != n)
@@ -2811,7 +2811,7 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.numel () != 0)
+  if (have_b && cholB && ! permB.is_empty ())
     {
       // Check the we really have a permutation vector
       if (permB.numel () != n)
@@ -2862,7 +2862,7 @@
         {
           bt = b;
           b = b.hermitian ();
-          if (permB.numel () == 0)
+          if (permB.is_empty ())
             {
               permB = ColumnVector (n);
               for (octave_idx_type i = 0; i < n; i++)
@@ -3136,7 +3136,7 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.numel () != 0)
+  if (have_b && cholB && ! permB.is_empty ())
     {
       // Check that we really have a permutation vector
       if (permB.numel () != n)