changeset 20264:5dfaaaae784f

Deprecate Array::capacity() and Sparse::capacity() for numel() and nzmax(). * liboctave/array/Array.h (Array::capacity): deprecate for ::numel(). * liboctave/array/Sparse.h (Sparse::capacity): deprecate for ::nzmax(). Also move comments into doxygen docs. * libinterp/corefcn/daspk.cc, libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc, libinterp/corefcn/jit-typeinfo.h, libinterp/corefcn/quad.cc, libinterp/corefcn/variables.cc, libinterp/octave-value/ov-base-sparse.h, libinterp/octave-value/ov-base.h, libinterp/octave-value/ov.h, liboctave/array/Sparse.cc, liboctave/numeric/DASPK.cc, liboctave/numeric/DASRT.cc, liboctave/numeric/DASSL.cc, liboctave/numeric/LSODE.cc, liboctave/numeric/Quad.cc, liboctave/numeric/base-de.h, liboctave/numeric/base-min.h, liboctave/numeric/oct-rand.cc: replace use of capacity by numel() or nzmax() as appropriate.
author Carnë Draug <carandraug@octave.org>
date Sun, 24 May 2015 04:47:20 +0100
parents 00cf2847355d
children e914b5399c67
files libinterp/corefcn/daspk.cc libinterp/corefcn/dasrt.cc libinterp/corefcn/dassl.cc libinterp/corefcn/jit-typeinfo.h libinterp/corefcn/quad.cc libinterp/corefcn/variables.cc libinterp/octave-value/ov-base-sparse.h libinterp/octave-value/ov-base.h libinterp/octave-value/ov.h liboctave/array/Array.h liboctave/array/Sparse.cc liboctave/array/Sparse.h liboctave/numeric/DASPK.cc liboctave/numeric/DASRT.cc liboctave/numeric/DASSL.cc liboctave/numeric/LSODE.cc liboctave/numeric/Quad.cc liboctave/numeric/base-de.h liboctave/numeric/base-min.h liboctave/numeric/oct-rand.cc
diffstat 20 files changed, 53 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/daspk.cc	Sun May 24 02:41:37 2015 +0100
+++ b/libinterp/corefcn/daspk.cc	Sun May 24 04:47:20 2015 +0100
@@ -63,7 +63,7 @@
 {
   ColumnVector retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -111,7 +111,7 @@
 {
   Matrix retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -426,7 +426,7 @@
           crit_times_set = 1;
         }
 
-      if (state.capacity () != deriv.capacity ())
+      if (state.numel () != deriv.numel ())
         DASPK_ABORT1 ("x and xdot must have the same size");
 
       double tzero = out_times (0);
--- a/libinterp/corefcn/dasrt.cc	Sun May 24 02:41:37 2015 +0100
+++ b/libinterp/corefcn/dasrt.cc	Sun May 24 04:47:20 2015 +0100
@@ -63,7 +63,7 @@
 {
   ColumnVector retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -147,7 +147,7 @@
 {
   Matrix retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
--- a/libinterp/corefcn/dassl.cc	Sun May 24 02:41:37 2015 +0100
+++ b/libinterp/corefcn/dassl.cc	Sun May 24 04:47:20 2015 +0100
@@ -63,7 +63,7 @@
 {
   ColumnVector retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -111,7 +111,7 @@
 {
   Matrix retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -427,7 +427,7 @@
           crit_times_set = 1;
         }
 
-      if (state.capacity () != deriv.capacity ())
+      if (state.numel () != deriv.numel ())
         DASSL_ABORT1 ("x and xdot must have the same size");
 
       double tzero = out_times (0);
--- a/libinterp/corefcn/jit-typeinfo.h	Sun May 24 02:41:37 2015 +0100
+++ b/libinterp/corefcn/jit-typeinfo.h	Sun May 24 04:47:20 2015 +0100
@@ -79,7 +79,7 @@
   {
     ref_count = array->jit_ref_count ();
     slice_data = array->jit_slice_data () - 1;
-    slice_len = array->capacity ();
+    slice_len = array->numel ();
     dimensions = array->jit_dimensions ();
   }
 
--- a/libinterp/corefcn/quad.cc	Sun May 24 02:41:37 2015 +0100
+++ b/libinterp/corefcn/quad.cc	Sun May 24 04:47:20 2015 +0100
@@ -312,7 +312,7 @@
               if (error_state)
                 QUAD_ABORT1 ("expecting vector of tolerances as fifth argument");
 
-              switch (tol.capacity ())
+              switch (tol.numel ())
                 {
                 case 2:
                   quad_opts.set_single_precision_relative_tolerance (tol (1));
@@ -421,7 +421,7 @@
               if (error_state)
                 QUAD_ABORT1 ("expecting vector of tolerances as fifth argument");
 
-              switch (tol.capacity ())
+              switch (tol.numel ())
                 {
                 case 2:
                   quad_opts.set_relative_tolerance (tol (1));
--- a/libinterp/corefcn/variables.cc	Sun May 24 02:41:37 2015 +0100
+++ b/libinterp/corefcn/variables.cc	Sun May 24 04:47:20 2015 +0100
@@ -1256,7 +1256,7 @@
                   break;
 
                 case 'e':
-                  os << varval.capacity ();
+                  os << varval.numel ();
                   break;
 
                 case 'n':
@@ -1404,7 +1404,7 @@
 
             octave_value val = p->varval;
 
-            elements += val.capacity ();
+            elements += val.numel ();
             bytes += val.byte_size ();
           }
 
@@ -1476,7 +1476,7 @@
                                 > static_cast<size_t> (param_length(pos_t)))
                                ? str.length () : param_length(pos_t));
 
-        elements1 = val.capacity ();
+        elements1 = val.numel ();
         ss1 << elements1;
         str = ss1.str ();
         param_length(pos_e) = ((str.length ()
--- a/libinterp/octave-value/ov-base-sparse.h	Sun May 24 02:41:37 2015 +0100
+++ b/libinterp/octave-value/ov-base-sparse.h	Sun May 24 04:47:20 2015 +0100
@@ -143,7 +143,7 @@
 
   bool is_true (void) const;
 
-  octave_idx_type capacity (void) const { return matrix.capacity (); }
+  GCC_ATTR_DEPRECATED octave_idx_type capacity (void) const { return nzmax (); }
 
   bool print_as_scalar (void) const;
 
--- a/libinterp/octave-value/ov-base.h	Sun May 24 02:41:37 2015 +0100
+++ b/libinterp/octave-value/ov-base.h	Sun May 24 04:47:20 2015 +0100
@@ -310,7 +310,8 @@
 
   virtual octave_idx_type numel (void) const { return dims ().numel (); }
 
-  virtual octave_idx_type capacity (void) const { return numel (); }
+  GCC_ATTR_DEPRECATED virtual octave_idx_type capacity (void) const
+  { return numel (); }
 
   virtual size_t byte_size (void) const { return 0; }
 
--- a/libinterp/octave-value/ov.h	Sun May 24 02:41:37 2015 +0100
+++ b/libinterp/octave-value/ov.h	Sun May 24 04:47:20 2015 +0100
@@ -483,8 +483,8 @@
   octave_idx_type numel (void) const
   { return rep->numel (); }
 
-  octave_idx_type capacity (void) const
-  { return rep->capacity (); }
+  GCC_ATTR_DEPRECATED octave_idx_type capacity (void) const
+  { return rep->numel (); }
 
   size_t byte_size (void) const
   { return rep->byte_size (); }
--- a/liboctave/array/Array.h	Sun May 24 02:41:37 2015 +0100
+++ b/liboctave/array/Array.h	Sun May 24 04:47:20 2015 +0100
@@ -253,11 +253,11 @@
   //@{
   //! Number of elements in the array.
   //! Synonymous with numel().
-  octave_idx_type capacity (void) const { return numel (); }
+  //! @note This method is deprecated in favour of numel().
+  GCC_ATTR_DEPRECATED octave_idx_type capacity (void) const { return numel (); }
 
   //! Number of elements in the array.
-  /*! Synonymous with capacity() and numel().
-
+  /*! Synonymous with numel().
       @note This method is deprecated in favour of numel().
 
       @note
@@ -269,12 +269,11 @@
   octave_idx_type length (void) const { return numel (); }
 
   //! Number of elements in the array.
-  //! Synonymous with capacity() and numel().
+  //! Synonymous with numel().
   //! @note This method is deprecated in favour of numel().
   GCC_ATTR_DEPRECATED octave_idx_type nelem (void) const { return numel (); }
 
   //! Number of elements in the array.
-  //! Synonymous with capacity().
   octave_idx_type numel (void) const { return slice_len; }
   //@}
 
--- a/liboctave/array/Sparse.cc	Sun May 24 02:41:37 2015 +0100
+++ b/liboctave/array/Sparse.cc	Sun May 24 04:47:20 2015 +0100
@@ -1879,7 +1879,7 @@
               octave_idx_type rnz = rhs.nnz ();
               octave_idx_type new_nz = nz - (ui - li) + rnz;
 
-              if (new_nz >= nz && new_nz <= capacity ())
+              if (new_nz >= nz && new_nz <= nzmax ())
                 {
                   // Adding/overwriting elements, enough capacity allocated.
 
@@ -2062,7 +2062,7 @@
               octave_idx_type rnz = rhs.nnz ();
               octave_idx_type new_nz = nz - (ui - li) + rnz;
 
-              if (new_nz >= nz && new_nz <= capacity ())
+              if (new_nz >= nz && new_nz <= nzmax ())
                 {
                   // Adding/overwriting elements, enough capacity allocated.
 
--- a/liboctave/array/Sparse.h	Sun May 24 02:41:37 2015 +0100
+++ b/liboctave/array/Sparse.h	Sun May 24 04:47:20 2015 +0100
@@ -240,11 +240,13 @@
 
   Sparse<T>& operator = (const Sparse<T>& a);
 
-  // Note that nzmax and capacity are the amount of storage for
-  // nonzero elements, while nnz is the actual number of nonzero
-  // terms.
+  //! Amount of storage for nonzero elements.
+  //! This may differ from the actual number of elements, see nnz().
   octave_idx_type nzmax (void) const { return rep->length (); }
-  octave_idx_type capacity (void) const { return nzmax (); }
+  //! Amount of storage for nonzero elements.
+  //! Synonymous with nzmax().
+  GCC_ATTR_DEPRECATED octave_idx_type capacity (void) const { return nzmax (); }
+  //!Actual number of nonzero terms.
   octave_idx_type nnz (void) const { return rep->nnz (); }
 
   // Querying the number of elements (incl. zeros) may overflow the index type,
@@ -254,7 +256,7 @@
     return dimensions.safe_numel ();
   }
 
-  GCC_ATTR_DEPRECATED octave_idx_type nelem (void) const { return capacity (); }
+  GCC_ATTR_DEPRECATED octave_idx_type nelem (void) const { return nzmax (); }
   octave_idx_type length (void) const { return numel (); }
 
   octave_idx_type dim1 (void) const { return dimensions(0); }
@@ -276,7 +278,7 @@
   size_t byte_size (void) const
   {
     return (static_cast<size_t>(cols () + 1) * sizeof (octave_idx_type)
-            + static_cast<size_t> (capacity ())
+            + static_cast<size_t> (nzmax ())
             * (sizeof (T) + sizeof (octave_idx_type)));
   }
 
--- a/liboctave/numeric/DASPK.cc	Sun May 24 02:41:37 2015 +0100
+++ b/liboctave/numeric/DASPK.cc	Sun May 24 04:47:20 2015 +0100
@@ -538,7 +538,7 @@
 {
   Matrix retval;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -583,7 +583,7 @@
 {
   Matrix retval;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -597,7 +597,7 @@
           xdot_out.elem (0, i) = xdot.elem (i);
         }
 
-      octave_idx_type n_crit = tcrit.capacity ();
+      octave_idx_type n_crit = tcrit.numel ();
 
       if (n_crit > 0)
         {
--- a/liboctave/numeric/DASRT.cc	Sun May 24 02:41:37 2015 +0100
+++ b/liboctave/numeric/DASRT.cc	Sun May 24 04:47:20 2015 +0100
@@ -393,7 +393,7 @@
   Matrix xdot_out;
   ColumnVector t_out = tout;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -452,7 +452,7 @@
   Matrix xdot_out;
   ColumnVector t_outs = tout;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -460,7 +460,7 @@
       x_out.resize (n_out, n);
       xdot_out.resize (n_out, n);
 
-      octave_idx_type n_crit = tcrit.capacity ();
+      octave_idx_type n_crit = tcrit.numel ();
 
       if (n_crit > 0)
         {
--- a/liboctave/numeric/DASSL.cc	Sun May 24 02:41:37 2015 +0100
+++ b/liboctave/numeric/DASSL.cc	Sun May 24 04:47:20 2015 +0100
@@ -353,7 +353,7 @@
 {
   Matrix retval;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -398,7 +398,7 @@
 {
   Matrix retval;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -412,7 +412,7 @@
           xdot_out.elem (0, i) = xdot.elem (i);
         }
 
-      octave_idx_type n_crit = tcrit.capacity ();
+      octave_idx_type n_crit = tcrit.numel ();
 
       if (n_crit > 0)
         {
--- a/liboctave/numeric/LSODE.cc	Sun May 24 02:41:37 2015 +0100
+++ b/liboctave/numeric/LSODE.cc	Sun May 24 04:47:20 2015 +0100
@@ -383,7 +383,7 @@
 {
   Matrix retval;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -413,7 +413,7 @@
 {
   Matrix retval;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -423,7 +423,7 @@
       for (octave_idx_type i = 0; i < n; i++)
         retval.elem (0, i) = x.elem (i);
 
-      octave_idx_type n_crit = tcrit.capacity ();
+      octave_idx_type n_crit = tcrit.numel ();
 
       if (n_crit > 0)
         {
--- a/liboctave/numeric/Quad.cc	Sun May 24 02:41:37 2015 +0100
+++ b/liboctave/numeric/Quad.cc	Sun May 24 04:47:20 2015 +0100
@@ -126,7 +126,7 @@
 DefQuad::do_integrate (octave_idx_type& ier, octave_idx_type& neval,
                        double& abserr)
 {
-  octave_idx_type npts = singularities.capacity () + 2;
+  octave_idx_type npts = singularities.numel () + 2;
   double *points = singularities.fortran_vec ();
   double result = 0.0;
 
@@ -224,7 +224,7 @@
 FloatDefQuad::do_integrate (octave_idx_type& ier, octave_idx_type& neval,
                             float& abserr)
 {
-  octave_idx_type npts = singularities.capacity () + 2;
+  octave_idx_type npts = singularities.numel () + 2;
   float *points = singularities.fortran_vec ();
   float result = 0.0;
 
--- a/liboctave/numeric/base-de.h	Sun May 24 02:41:37 2015 +0100
+++ b/liboctave/numeric/base-de.h	Sun May 24 04:47:20 2015 +0100
@@ -72,7 +72,7 @@
     force_restart ();
   }
 
-  octave_idx_type size (void) const { return x.capacity (); }
+  octave_idx_type size (void) const { return x.numel (); }
 
   ColumnVector state (void) const { return x; }
 
--- a/liboctave/numeric/base-min.h	Sun May 24 02:41:37 2015 +0100
+++ b/liboctave/numeric/base-min.h	Sun May 24 04:47:20 2015 +0100
@@ -114,7 +114,7 @@
     return do_minimize (objf, inform, lambda);
   }
 
-  octave_idx_type size (void) const { return x.capacity (); }
+  octave_idx_type size (void) const { return x.numel (); }
 
 protected:
 
--- a/liboctave/numeric/oct-rand.cc	Sun May 24 02:41:37 2015 +0100
+++ b/liboctave/numeric/oct-rand.cc	Sun May 24 04:47:20 2015 +0100
@@ -513,7 +513,7 @@
     {
       retval.clear (n, 1);
 
-      fill (retval.capacity (), retval.fortran_vec (), a);
+      fill (retval.numel (), retval.fortran_vec (), a);
     }
   else if (n < 0)
     (*current_liboctave_error_handler) ("rand: invalid negative argument");
@@ -530,7 +530,7 @@
     {
       retval.clear (n, 1);
 
-      fill (retval.capacity (), retval.fortran_vec (), a);
+      fill (retval.numel (), retval.fortran_vec (), a);
     }
   else if (n < 0)
     (*current_liboctave_error_handler) ("rand: invalid negative argument");
@@ -547,7 +547,7 @@
     {
       retval.clear (dims);
 
-      fill (retval.capacity (), retval.fortran_vec (), a);
+      fill (retval.numel (), retval.fortran_vec (), a);
     }
 
   return retval;
@@ -562,7 +562,7 @@
     {
       retval.clear (dims);
 
-      fill (retval.capacity (), retval.fortran_vec (), a);
+      fill (retval.numel (), retval.fortran_vec (), a);
     }
 
   return retval;