comparison libinterp/octave-value/ov-range.cc @ 20438:00cf2847355d

Deprecate Array::nelem() and Range::nelem() in favour of ::numel(). * liboctave/array/Array.h (Array::nelem) deprecate in favour of numel(). (Array::capacity, Array:: length): change to call numel() directly. These methods will be deprecated soon. * liboctave/array/PermMatrix.h (PermMatrix::nelem): deprecate in favour of numel(). * liboctave/array/Range.h (Range::numel) new method to replace nelem(). (Range::nelem) deprecate in favour of the new method numel. * liboctave/array/Sparse.h (Sparse::nelem) deprecate in favour of nzmax(). This one is secially bad because unlike the other classes, it is different from numel(). * libinterp/corefcn/debug.cc, libinterp/corefcn/jit-typeinfo.cc, libinterp/corefcn/ls-mat4.cc, libinterp/corefcn/lu.cc, libinterp/corefcn/luinc.cc, libinterp/corefcn/max.cc, libinterp/corefcn/pr-output.cc, libinterp/corefcn/rand.cc, libinterp/corefcn/xpow.cc, libinterp/dldfcn/__magick_read__.cc, libinterp/dldfcn/audioread.cc, libinterp/octave-value/ov-base-int.cc, libinterp/octave-value/ov-bool-mat.cc, libinterp/octave-value/ov-flt-re-mat.cc, libinterp/octave-value/ov-perm.cc, libinterp/octave-value/ov-range.cc, libinterp/octave-value/ov-range.h, libinterp/octave-value/ov-re-mat.cc, libinterp/parse-tree/pt-eval.cc, liboctave/array/Array.cc, liboctave/array/CNDArray.cc, liboctave/array/Range.cc, liboctave/array/dNDArray.cc, liboctave/array/fCNDArray.cc, liboctave/array/fNDArray.cc, liboctave/array/idx-vector.cc, liboctave/array/intNDArray.cc, liboctave/numeric/SparseCmplxLU.cc, liboctave/numeric/SparsedbleLU.cc: replace use of nelem() with numel().
author Carnë Draug <carandraug@octave.org>
date Sun, 24 May 2015 02:41:37 +0100
parents 075a5e2e1ba5
children dd6345fd8a97
comparison
equal deleted inserted replaced
20437:9f484edd8767 20438:00cf2847355d
70 octave_base_value * 70 octave_base_value *
71 octave_range::try_narrowing_conversion (void) 71 octave_range::try_narrowing_conversion (void)
72 { 72 {
73 octave_base_value *retval = 0; 73 octave_base_value *retval = 0;
74 74
75 switch (range.nelem ()) 75 switch (range.numel ())
76 { 76 {
77 case 1: 77 case 1:
78 retval = new octave_scalar (range.base ()); 78 retval = new octave_scalar (range.base ());
79 break; 79 break;
80 80
129 129
130 // The range can handle a single subscript. 130 // The range can handle a single subscript.
131 idx_vector i = idx(0).index_vector (); 131 idx_vector i = idx(0).index_vector ();
132 if (! error_state) 132 if (! error_state)
133 { 133 {
134 if (i.is_scalar () && i(0) < range.nelem ()) 134 if (i.is_scalar () && i(0) < range.numel ())
135 retval = range.elem (i(0)); 135 retval = range.elem (i(0));
136 else 136 else
137 retval = range.index (i); 137 retval = range.index (i);
138 } 138 }
139 139
171 double 171 double
172 octave_range::double_value (bool) const 172 octave_range::double_value (bool) const
173 { 173 {
174 double retval = lo_ieee_nan_value (); 174 double retval = lo_ieee_nan_value ();
175 175
176 octave_idx_type nel = range.nelem (); 176 octave_idx_type nel = range.numel ();
177 177
178 if (nel > 0) 178 if (nel > 0)
179 { 179 {
180 gripe_implicit_conversion ("Octave:array-to-scalar", 180 gripe_implicit_conversion ("Octave:array-to-scalar",
181 "range", "real scalar"); 181 "range", "real scalar");
191 float 191 float
192 octave_range::float_value (bool) const 192 octave_range::float_value (bool) const
193 { 193 {
194 float retval = lo_ieee_float_nan_value (); 194 float retval = lo_ieee_float_nan_value ();
195 195
196 octave_idx_type nel = range.nelem (); 196 octave_idx_type nel = range.numel ();
197 197
198 if (nel > 0) 198 if (nel > 0)
199 { 199 {
200 gripe_implicit_conversion ("Octave:array-to-scalar", 200 gripe_implicit_conversion ("Octave:array-to-scalar",
201 "range", "real scalar"); 201 "range", "real scalar");
262 bool 262 bool
263 octave_range::is_true (void) const 263 octave_range::is_true (void) const
264 { 264 {
265 bool retval = false; 265 bool retval = false;
266 266
267 if (range.nelem () != 0) 267 if (range.numel () != 0)
268 { 268 {
269 // FIXME: this is a potential waste of memory. 269 // FIXME: this is a potential waste of memory.
270 270
271 Matrix m ((range.matrix_value () . all ()) . all ()); 271 Matrix m ((range.matrix_value () . all ()) . all ());
272 272
281 { 281 {
282 double tmp = lo_ieee_nan_value (); 282 double tmp = lo_ieee_nan_value ();
283 283
284 Complex retval (tmp, tmp); 284 Complex retval (tmp, tmp);
285 285
286 octave_idx_type nel = range.nelem (); 286 octave_idx_type nel = range.numel ();
287 287
288 if (nel > 0) 288 if (nel > 0)
289 { 289 {
290 gripe_implicit_conversion ("Octave:array-to-scalar", 290 gripe_implicit_conversion ("Octave:array-to-scalar",
291 "range", "complex scalar"); 291 "range", "complex scalar");
303 { 303 {
304 float tmp = lo_ieee_float_nan_value (); 304 float tmp = lo_ieee_float_nan_value ();
305 305
306 FloatComplex retval (tmp, tmp); 306 FloatComplex retval (tmp, tmp);
307 307
308 octave_idx_type nel = range.nelem (); 308 octave_idx_type nel = range.numel ();
309 309
310 if (nel > 0) 310 if (nel > 0)
311 { 311 {
312 gripe_implicit_conversion ("Octave:array-to-scalar", 312 gripe_implicit_conversion ("Octave:array-to-scalar",
313 "range", "complex scalar"); 313 "range", "complex scalar");
368 bool 368 bool
369 octave_range::print_name_tag (std::ostream& os, const std::string& name) const 369 octave_range::print_name_tag (std::ostream& os, const std::string& name) const
370 { 370 {
371 bool retval = false; 371 bool retval = false;
372 372
373 octave_idx_type n = range.nelem (); 373 octave_idx_type n = range.numel ();
374 374
375 indent (os); 375 indent (os);
376 376
377 if (n == 0 || n == 1) 377 if (n == 0 || n == 1)
378 os << name << " = "; 378 os << name << " = ";
390 } 390 }
391 391
392 void 392 void
393 octave_range::short_disp (std::ostream& os) const 393 octave_range::short_disp (std::ostream& os) const
394 { 394 {
395 octave_idx_type len = range.nelem (); 395 octave_idx_type len = range.numel ();
396 396
397 if (len == 0) 397 if (len == 0)
398 os << "[]"; 398 os << "[]";
399 else 399 else
400 { 400 {
432 { 432 {
433 Range r = range_value (); 433 Range r = range_value ();
434 double base = r.base (); 434 double base = r.base ();
435 double limit = r.limit (); 435 double limit = r.limit ();
436 double inc = r.inc (); 436 double inc = r.inc ();
437 octave_idx_type len = r.nelem (); 437 octave_idx_type len = r.numel ();
438 438
439 if (inc != 0) 439 if (inc != 0)
440 os << "# base, limit, increment\n"; 440 os << "# base, limit, increment\n";
441 else 441 else
442 os << "# base, length, increment\n"; 442 os << "# base, length, increment\n";
485 Range r = range_value (); 485 Range r = range_value ();
486 double bas = r.base (); 486 double bas = r.base ();
487 double lim = r.limit (); 487 double lim = r.limit ();
488 double inc = r.inc (); 488 double inc = r.inc ();
489 if (inc == 0) 489 if (inc == 0)
490 lim = r.nelem (); 490 lim = r.numel ();
491 491
492 os.write (reinterpret_cast<char *> (&bas), 8); 492 os.write (reinterpret_cast<char *> (&bas), 8);
493 os.write (reinterpret_cast<char *> (&lim), 8); 493 os.write (reinterpret_cast<char *> (&lim), 8);
494 os.write (reinterpret_cast<char *> (&inc), 8); 494 os.write (reinterpret_cast<char *> (&inc), 8);
495 495
581 } 581 }
582 582
583 Range r = range_value (); 583 Range r = range_value ();
584 double range_vals[3]; 584 double range_vals[3];
585 range_vals[0] = r.base (); 585 range_vals[0] = r.base ();
586 range_vals[1] = r.inc () != 0 ? r.limit () : r.nelem (); 586 range_vals[1] = r.inc () != 0 ? r.limit () : r.numel ();
587 range_vals[2] = r.inc (); 587 range_vals[2] = r.inc ();
588 588
589 if (H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL, H5P_DEFAULT, 589 if (H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL, H5P_DEFAULT,
590 range_vals) >= 0) 590 range_vals) >= 0)
591 { 591 {
592 octave_idx_type nel = r.nelem (); 592 octave_idx_type nel = r.numel ();
593 retval = hdf5_add_scalar_attr (data_hid, H5T_NATIVE_IDX, 593 retval = hdf5_add_scalar_attr (data_hid, H5T_NATIVE_IDX,
594 "OCTAVE_RANGE_NELEM", &nel) >= 0; 594 "OCTAVE_RANGE_NELEM", &nel) >= 0;
595 } 595 }
596 else 596 else
597 retval = false; 597 retval = false;
691 } 691 }
692 692
693 octave_value 693 octave_value
694 octave_range::fast_elem_extract (octave_idx_type n) const 694 octave_range::fast_elem_extract (octave_idx_type n) const
695 { 695 {
696 return (n < range.nelem ()) ? octave_value (range.elem (n)) 696 return (n < range.numel ()) ? octave_value (range.elem (n))
697 : octave_value (); 697 : octave_value ();
698 } 698 }
699 699
700 DEFUN (allow_noninteger_range_as_index, args, nargout, 700 DEFUN (allow_noninteger_range_as_index, args, nargout,
701 "-*- texinfo -*-\n\ 701 "-*- texinfo -*-\n\