Mercurial > octave-nkf
diff liboctave/array/Range.cc @ 20263: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 | 4197fc428c7d |
children | 642ce72cf1ab |
line wrap: on
line diff
--- a/liboctave/array/Range.cc Mon May 25 16:48:47 2015 -0700 +++ b/liboctave/array/Range.cc Sun May 24 02:41:37 2015 +0100 @@ -44,24 +44,24 @@ // or fewer elements only the base needs to be an integer return (! (xisnan (rng_base) || xisnan (rng_inc)) - && (NINTbig (rng_base) == rng_base || rng_nelem < 1) - && (NINTbig (rng_inc) == rng_inc || rng_nelem <= 1)); + && (NINTbig (rng_base) == rng_base || rng_numel < 1) + && (NINTbig (rng_inc) == rng_inc || rng_numel <= 1)); } Matrix Range::matrix_value (void) const { - if (rng_nelem > 0 && cache.nelem () == 0) + if (rng_numel > 0 && cache.numel () == 0) { - cache.resize (1, rng_nelem); + cache.resize (1, rng_numel); double b = rng_base; double increment = rng_inc; - if (rng_nelem > 0) + if (rng_numel > 0) { // The first element must always be *exactly* the base. // E.g, -0 would otherwise become +0 in the loop (-0 + 0*increment). cache(0) = b; - for (octave_idx_type i = 1; i < rng_nelem; i++) + for (octave_idx_type i = 1; i < rng_numel; i++) cache(i) = b + i * increment; } @@ -72,9 +72,9 @@ // elements. The tests need equality (>= rng_limit or <= rng_limit) // to have expressions like -5:1:-0 result in a -0 endpoint. - if ((rng_inc > 0 && cache(rng_nelem-1) >= rng_limit) - || (rng_inc < 0 && cache(rng_nelem-1) <= rng_limit)) - cache(rng_nelem-1) = rng_limit; + if ((rng_inc > 0 && cache(rng_numel-1) >= rng_limit) + || (rng_inc < 0 && cache(rng_numel-1) <= rng_limit)) + cache(rng_numel-1) = rng_limit; } return cache; @@ -83,12 +83,12 @@ double Range::checkelem (octave_idx_type i) const { - if (i < 0 || i >= rng_nelem) - gripe_index_out_of_range (1, 1, i+1, rng_nelem); + if (i < 0 || i >= rng_numel) + gripe_index_out_of_range (1, 1, i+1, rng_numel); if (i == 0) return rng_base; - else if (i < rng_nelem - 1) + else if (i < rng_numel - 1) return rng_base + i * rng_inc; else { @@ -109,7 +109,7 @@ #else if (i == 0) return rng_base; - else if (i < rng_nelem - 1) + else if (i < rng_numel - 1) return rng_base + i * rng_inc; else { @@ -158,11 +158,11 @@ { Array<double> retval; - octave_idx_type n = rng_nelem; + octave_idx_type n = rng_numel; if (i.is_colon ()) { - retval = matrix_value ().reshape (dim_vector (rng_nelem, 1)); + retval = matrix_value ().reshape (dim_vector (rng_numel, 1)); } else { @@ -181,26 +181,26 @@ // idx_vector loop across all values in i, // executing __rangeidx_helper (i) for each i i.loop (n, __rangeidx_helper (retval.fortran_vec (), - rng_base, rng_inc, rng_limit, rng_nelem)); + rng_base, rng_inc, rng_limit, rng_numel)); } return retval; } -// NOTE: max and min only return useful values if nelem > 0. -// do_minmax_body() in max.cc avoids calling Range::min/max if nelem == 0. +// NOTE: max and min only return useful values if numel > 0. +// do_minmax_body() in max.cc avoids calling Range::min/max if numel == 0. double Range::min (void) const { double retval = 0.0; - if (rng_nelem > 0) + if (rng_numel > 0) { if (rng_inc > 0) retval = rng_base; else { - retval = rng_base + (rng_nelem - 1) * rng_inc; + retval = rng_base + (rng_numel - 1) * rng_inc; // See the note in the matrix_value method above. if (retval <= rng_limit) @@ -215,11 +215,11 @@ Range::max (void) const { double retval = 0.0; - if (rng_nelem > 0) + if (rng_numel > 0) { if (rng_inc > 0) { - retval = rng_base + (rng_nelem - 1) * rng_inc; + retval = rng_base + (rng_numel - 1) * rng_inc; // See the note in the matrix_value method above. if (retval >= rng_limit) @@ -255,7 +255,7 @@ void Range::sort_internal (Array<octave_idx_type>& sidx, bool ascending) { - octave_idx_type nel = nelem (); + octave_idx_type nel = numel (); sidx.resize (dim_vector (1, nel)); @@ -336,9 +336,9 @@ sortmode Range::is_sorted (sortmode mode) const { - if (rng_nelem > 1 && rng_inc > 0) + if (rng_numel > 1 && rng_inc > 0) mode = (mode == DESCENDING) ? UNSORTED : ASCENDING; - else if (rng_nelem > 1 && rng_inc < 0) + else if (rng_numel > 1 && rng_inc < 0) mode = (mode == ASCENDING) ? UNSORTED : DESCENDING; else mode = mode ? mode : ASCENDING; @@ -351,7 +351,7 @@ { double b = a.base (); double increment = a.inc (); - octave_idx_type num_elem = a.nelem (); + octave_idx_type num_elem = a.numel (); if (num_elem > 1) { @@ -377,7 +377,7 @@ if (is) { is >> a.rng_inc; - a.rng_nelem = a.nelem_internal (); + a.rng_numel = a.numel_internal (); } } @@ -387,13 +387,13 @@ Range operator - (const Range& r) { - return Range (-r.base (), -r.limit (), -r.inc (), r.nelem ()); + return Range (-r.base (), -r.limit (), -r.inc (), r.numel ()); } Range operator + (double x, const Range& r) { - Range result (x + r.base (), x + r.limit (), r.inc (), r.nelem ()); - if (result.rng_nelem < 0) + Range result (x + r.base (), x + r.limit (), r.inc (), r.numel ()); + if (result.rng_numel < 0) result.cache = x + r.matrix_value (); return result; @@ -401,8 +401,8 @@ Range operator + (const Range& r, double x) { - Range result (r.base () + x, r.limit () + x, r.inc (), r.nelem ()); - if (result.rng_nelem < 0) + Range result (r.base () + x, r.limit () + x, r.inc (), r.numel ()); + if (result.rng_numel < 0) result.cache = r.matrix_value () + x; return result; @@ -410,8 +410,8 @@ Range operator - (double x, const Range& r) { - Range result (x - r.base (), x - r.limit (), -r.inc (), r.nelem ()); - if (result.rng_nelem < 0) + Range result (x - r.base (), x - r.limit (), -r.inc (), r.numel ()); + if (result.rng_numel < 0) result.cache = x - r.matrix_value (); return result; @@ -419,8 +419,8 @@ Range operator - (const Range& r, double x) { - Range result (r.base () - x, r.limit () - x, r.inc (), r.nelem ()); - if (result.rng_nelem < 0) + Range result (r.base () - x, r.limit () - x, r.inc (), r.numel ()); + if (result.rng_numel < 0) result.cache = r.matrix_value () - x; return result; @@ -428,8 +428,8 @@ Range operator * (double x, const Range& r) { - Range result (x * r.base (), x * r.limit (), x * r.inc (), r.nelem ()); - if (result.rng_nelem < 0) + Range result (x * r.base (), x * r.limit (), x * r.inc (), r.numel ()); + if (result.rng_numel < 0) result.cache = x * r.matrix_value (); return result; @@ -437,8 +437,8 @@ Range operator * (const Range& r, double x) { - Range result (r.base () * x, r.limit () * x, r.inc () * x, r.nelem ()); - if (result.rng_nelem < 0) + Range result (r.base () * x, r.limit () * x, r.inc () * x, r.numel ()); + if (result.rng_numel < 0) result.cache = r.matrix_value () * x; return result; @@ -524,7 +524,7 @@ } octave_idx_type -Range::nelem_internal (void) const +Range::numel_internal (void) const { octave_idx_type retval = -1;