comparison libinterp/octave-value/ov-fcn-inline.cc @ 20232:a9574e3c6e9e

Deprecate Array::length() and Sparse::length() in favour of ::numel(). * liboctave/array/Array.h (Array::length): deprecate for ::numel. * liboctave/array/Sparse.h (Sparse::length): deprecate for ::numel. * libgui/graphics/QtHandlesUtils.cc, libgui/src/octave-qt-link.cc, libinterp/corefcn/Cell.cc, libinterp/corefcn/__contourc__.cc, libinterp/corefcn/__pchip_deriv__.cc, libinterp/corefcn/__qp__.cc, libinterp/corefcn/cellfun.cc, libinterp/corefcn/daspk.cc, libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc, libinterp/corefcn/data.cc, libinterp/corefcn/filter.cc, libinterp/corefcn/find.cc, libinterp/corefcn/gl-render.cc, libinterp/corefcn/gl-render.h, libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h, libinterp/corefcn/help.cc, libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc, libinterp/corefcn/load-path.cc, libinterp/corefcn/load-save.cc, libinterp/corefcn/ls-oct-ascii.h, libinterp/corefcn/lsode.cc, libinterp/corefcn/matrix_type.cc, libinterp/corefcn/oct-hist.cc, libinterp/corefcn/oct-map.cc, libinterp/corefcn/oct-map.h, libinterp/corefcn/oct-obj.h, libinterp/corefcn/oct-stream.cc, libinterp/corefcn/oct-stream.h, libinterp/corefcn/pr-output.cc, libinterp/corefcn/quadcc.cc, libinterp/corefcn/rand.cc, libinterp/corefcn/regexp.cc, libinterp/corefcn/strfns.cc, libinterp/corefcn/sub2ind.cc, libinterp/corefcn/symtab.h, libinterp/corefcn/syscalls.cc, libinterp/corefcn/tsearch.cc, libinterp/corefcn/urlwrite.cc, libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc, libinterp/corefcn/xdiv.cc, libinterp/corefcn/xpow.cc, libinterp/dldfcn/__glpk__.cc, libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/__magick_read__.cc, libinterp/dldfcn/audiodevinfo.cc, libinterp/dldfcn/ccolamd.cc, libinterp/dldfcn/colamd.cc, libinterp/octave-value/ov-cell.cc, libinterp/octave-value/ov-class.cc, libinterp/octave-value/ov-class.h, libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-perm.cc, libinterp/octave-value/ov-struct.cc, libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov.cc, libinterp/operators/op-int.h, libinterp/parse-tree/pt-pr-code.cc, liboctave/array/Array-util.cc, liboctave/array/Array.cc, liboctave/array/CColVector.cc, liboctave/array/CDiagMatrix.cc, liboctave/array/CMatrix.cc, liboctave/array/CRowVector.cc, liboctave/array/DiagArray2.cc, liboctave/array/DiagArray2.h, liboctave/array/MArray.cc, liboctave/array/PermMatrix.cc, liboctave/array/PermMatrix.h, liboctave/array/Sparse.cc, liboctave/array/boolMatrix.cc, liboctave/array/chMatrix.cc, liboctave/array/chNDArray.cc, liboctave/array/dColVector.cc, liboctave/array/dDiagMatrix.cc, liboctave/array/dMatrix.cc, liboctave/array/dRowVector.cc, liboctave/array/fCColVector.cc, liboctave/array/fCDiagMatrix.cc, liboctave/array/fCMatrix.cc, liboctave/array/fCRowVector.cc, liboctave/array/fColVector.cc, liboctave/array/fDiagMatrix.cc, liboctave/array/fMatrix.cc, liboctave/array/fRowVector.cc, liboctave/array/idx-vector.cc, liboctave/array/intNDArray.cc, liboctave/numeric/CmplxCHOL.cc, liboctave/numeric/CmplxLU.cc, liboctave/numeric/CmplxQR.cc, liboctave/numeric/DASPK.cc, liboctave/numeric/DASRT.cc, liboctave/numeric/DASSL.cc, liboctave/numeric/LSODE.cc, liboctave/numeric/ODES.cc, liboctave/numeric/ODES.h, liboctave/numeric/base-dae.h, liboctave/numeric/base-lu.cc, liboctave/numeric/dbleCHOL.cc, liboctave/numeric/dbleLU.cc, liboctave/numeric/dbleQR.cc, liboctave/numeric/eigs-base.cc, liboctave/numeric/fCmplxCHOL.cc, liboctave/numeric/fCmplxLU.cc, liboctave/numeric/fCmplxQR.cc, liboctave/numeric/floatCHOL.cc, liboctave/numeric/floatLU.cc, liboctave/numeric/floatQR.cc, liboctave/numeric/lo-specfun.cc, liboctave/numeric/oct-rand.cc, liboctave/numeric/oct-spparms.cc, liboctave/numeric/sparse-base-chol.cc, liboctave/operators/mx-inlines.cc, liboctave/system/file-ops.cc, liboctave/util/glob-match.h, liboctave/util/kpse.cc, liboctave/util/lo-regexp.cc, liboctave/util/oct-glob.cc, liboctave/util/pathsearch.cc, liboctave/util/str-vec.cc, liboctave/util/str-vec.h, liboctave/util/url-transfer.cc: replace all usage of Array::length() and Sparse::length() with ::numel().
author Carnë Draug <carandraug@octave.org>
date Sat, 30 May 2015 03:14:07 +0100
parents 075a5e2e1ba5
children c6224b4e7774
comparison
equal deleted inserted replaced
20231:83792dd9bcc1 20232:a9574e3c6e9e
68 68
69 std::ostringstream buf; 69 std::ostringstream buf;
70 70
71 buf << "@("; 71 buf << "@(";
72 72
73 for (int i = 0; i < ifargs.length (); i++) 73 for (int i = 0; i < ifargs.numel (); i++)
74 { 74 {
75 if (i > 0) 75 if (i > 0)
76 buf << ", "; 76 buf << ", ";
77 77
78 buf << ifargs(i); 78 buf << ifargs(i);
126 m.assign ("isEmpty", 0.0); 126 m.assign ("isEmpty", 0.0);
127 m.assign ("expr", fcn_text ()); 127 m.assign ("expr", fcn_text ());
128 128
129 string_vector args = fcn_arg_names (); 129 string_vector args = fcn_arg_names ();
130 130
131 m.assign ("numArgs", args.length ()); 131 m.assign ("numArgs", args.numel ());
132 m.assign ("args", args); 132 m.assign ("args", args);
133 133
134 std::ostringstream buf; 134 std::ostringstream buf;
135 135
136 for (int i = 0; i < args.length (); i++) 136 for (int i = 0; i < args.numel (); i++)
137 buf << args(i) << " = INLINE_INPUTS_{" << i + 1 << "}; "; 137 buf << args(i) << " = INLINE_INPUTS_{" << i + 1 << "}; ";
138 138
139 m.assign ("inputExpr", buf.str ()); 139 m.assign ("inputExpr", buf.str ());
140 140
141 return m; 141 return m;
142 } 142 }
143 143
144 bool 144 bool
145 octave_fcn_inline::save_ascii (std::ostream& os) 145 octave_fcn_inline::save_ascii (std::ostream& os)
146 { 146 {
147 os << "# nargs: " << ifargs.length () << "\n"; 147 os << "# nargs: " << ifargs.numel () << "\n";
148 for (int i = 0; i < ifargs.length (); i++) 148 for (int i = 0; i < ifargs.numel (); i++)
149 os << ifargs(i) << "\n"; 149 os << ifargs(i) << "\n";
150 if (nm.length () < 1) 150 if (nm.length () < 1)
151 // Write an invalid value to flag empty fcn handle name. 151 // Write an invalid value to flag empty fcn handle name.
152 os << "0\n"; 152 os << "0\n";
153 else 153 else
193 } 193 }
194 194
195 bool 195 bool
196 octave_fcn_inline::save_binary (std::ostream& os, bool&) 196 octave_fcn_inline::save_binary (std::ostream& os, bool&)
197 { 197 {
198 int32_t tmp = ifargs.length (); 198 int32_t tmp = ifargs.numel ();
199 os.write (reinterpret_cast<char *> (&tmp), 4); 199 os.write (reinterpret_cast<char *> (&tmp), 4);
200 for (int i = 0; i < ifargs.length (); i++) 200 for (int i = 0; i < ifargs.numel (); i++)
201 { 201 {
202 tmp = ifargs(i).length (); 202 tmp = ifargs(i).length ();
203 os.write (reinterpret_cast<char *> (&tmp), 4); 203 os.write (reinterpret_cast<char *> (&tmp), 4);
204 os.write (ifargs(i).c_str (), ifargs(i).length ()); 204 os.write (ifargs(i).c_str (), ifargs(i).length ());
205 } 205 }
289 group_hid = H5Gcreate (loc_id, name, 0); 289 group_hid = H5Gcreate (loc_id, name, 0);
290 #endif 290 #endif
291 if (group_hid < 0) return false; 291 if (group_hid < 0) return false;
292 292
293 size_t len = 0; 293 size_t len = 0;
294 for (int i = 0; i < ifargs.length (); i++) 294 for (int i = 0; i < ifargs.numel (); i++)
295 if (len < ifargs(i).length ()) 295 if (len < ifargs(i).length ())
296 len = ifargs(i).length (); 296 len = ifargs(i).length ();
297 297
298 hid_t space_hid, data_hid, type_hid; 298 hid_t space_hid, data_hid, type_hid;
299 space_hid = data_hid = type_hid = -1; 299 space_hid = data_hid = type_hid = -1;
302 // than a null padded matrix? 302 // than a null padded matrix?
303 303
304 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, 2); 304 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, 2);
305 305
306 // Octave uses column-major, while HDF5 uses row-major ordering 306 // Octave uses column-major, while HDF5 uses row-major ordering
307 hdims[1] = ifargs.length (); 307 hdims[1] = ifargs.numel ();
308 hdims[0] = len + 1; 308 hdims[0] = len + 1;
309 309
310 space_hid = H5Screate_simple (2, hdims, 0); 310 space_hid = H5Screate_simple (2, hdims, 0);
311 if (space_hid < 0) 311 if (space_hid < 0)
312 { 312 {
325 H5Sclose (space_hid); 325 H5Sclose (space_hid);
326 H5Gclose (group_hid); 326 H5Gclose (group_hid);
327 return false; 327 return false;
328 } 328 }
329 329
330 OCTAVE_LOCAL_BUFFER (char, s, ifargs.length () * (len + 1)); 330 OCTAVE_LOCAL_BUFFER (char, s, ifargs.numel () * (len + 1));
331 331
332 // Save the args as a null teminated list 332 // Save the args as a null teminated list
333 for (int i = 0; i < ifargs.length (); i++) 333 for (int i = 0; i < ifargs.numel (); i++)
334 { 334 {
335 const char * cptr = ifargs(i).c_str (); 335 const char * cptr = ifargs(i).c_str ();
336 for (size_t j = 0; j < ifargs(i).length (); j++) 336 for (size_t j = 0; j < ifargs(i).length (); j++)
337 s[i*(len+1)+j] = *cptr++; 337 s[i*(len+1)+j] = *cptr++;
338 s[ifargs(i).length ()] = '\0'; 338 s[ifargs(i).length ()] = '\0';
625 if (nm.empty ()) 625 if (nm.empty ())
626 buf << "f("; 626 buf << "f(";
627 else 627 else
628 buf << nm << "("; 628 buf << nm << "(";
629 629
630 for (int i = 0; i < ifargs.length (); i++) 630 for (int i = 0; i < ifargs.numel (); i++)
631 { 631 {
632 if (i) 632 if (i)
633 buf << ", "; 633 buf << ", ";
634 634
635 buf << ifargs(i); 635 buf << ifargs(i);
749 749
750 if (terminate_arg || (i == fun_length && is_arg)) 750 if (terminate_arg || (i == fun_length && is_arg))
751 { 751 {
752 bool have_arg = false; 752 bool have_arg = false;
753 753
754 for (int j = 0; j < fargs.length (); j++) 754 for (int j = 0; j < fargs.numel (); j++)
755 if (tmp_arg == fargs (j)) 755 if (tmp_arg == fargs (j))
756 { 756 {
757 have_arg = true; 757 have_arg = true;
758 break; 758 break;
759 } 759 }
771 } 771 }
772 772
773 // Sort the arguments into ascii order. 773 // Sort the arguments into ascii order.
774 fargs.sort (); 774 fargs.sort ();
775 775
776 if (fargs.length () == 0) 776 if (fargs.numel () == 0)
777 fargs.append (std::string ("x")); 777 fargs.append (std::string ("x"));
778 778
779 } 779 }
780 else if (nargin == 2 && args(1).is_numeric_type ()) 780 else if (nargin == 2 && args(1).is_numeric_type ())
781 { 781 {
918 918
919 if (fn) 919 if (fn)
920 { 920 {
921 string_vector t1 = fn->fcn_arg_names (); 921 string_vector t1 = fn->fcn_arg_names ();
922 922
923 Cell t2 (dim_vector (t1.length (), 1)); 923 Cell t2 (dim_vector (t1.numel (), 1));
924 924
925 for (int i = 0; i < t1.length (); i++) 925 for (int i = 0; i < t1.numel (); i++)
926 t2(i) = t1(i); 926 t2(i) = t1(i);
927 927
928 retval = t2; 928 retval = t2;
929 } 929 }
930 else 930 else