Mercurial > hg > octave-terminal
changeset 8972:5fa53d1b6247
more indexing optimizations
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 13 Mar 2009 13:39:22 +0100 |
parents | 967a692ddfe2 |
children | ddea8b06ed7c |
files | liboctave/ChangeLog liboctave/idx-vector.cc liboctave/idx-vector.h src/ChangeLog src/data.cc |
diffstat | 5 files changed, 23 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -4,6 +4,9 @@ constructor body. * Range.cc: Move it here. Check for invalid range op results. (all operators): Validate cache for invalid range op results. + * idx-vector.h (idx_vector::index): Optimize zero-step range case. + * idx-vector.cc (idx_vector::maybe_reduce): Always reduce colon in + singleton dimension. 2009-03-10 Jason Riedy <jason@acm.org>
--- a/liboctave/idx-vector.cc +++ b/liboctave/idx-vector.cc @@ -416,6 +416,16 @@ return true; } + // Possibly skip singleton dims. + if (n == 1 && rep->is_colon_equiv (n)) + { + *this = j; + return true; + } + + if (nj == 1 && j.is_colon_equiv (nj)) + return true; + switch (j.idx_class ()) { case class_colon:
--- a/liboctave/idx-vector.h +++ b/liboctave/idx-vector.h @@ -517,6 +517,8 @@ std::copy (ssrc, ssrc + len, dest); else if (step == -1) std::reverse_copy (ssrc - len + 1, ssrc + 1, dest); + else if (step == 0) + std::fill_n (dest, len, *ssrc); else { for (octave_idx_type i = 0, j = 0; i < len; i++, j += step)
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -4,6 +4,8 @@ constructing from invalid range op result. * ov-range.cc (octave_range::try_narrowing_conversion): Validate invalid range op results. + * data.cc (fill_matrix): Return packed form (zero-step range) if + possible. 2009-03-10 Jason Riedy <jason@acm.org>
--- a/src/data.cc +++ b/src/data.cc @@ -3248,7 +3248,12 @@ break; case oct_data_conv::dt_double: - retval = NDArray (dims, val); + { + if (val == 1 && dims.length () == 2 && dims (0) == 1) + retval = Range (1.0, 0.0, dims (1)); // packed form + else + retval = NDArray (dims, val); + } break; case oct_data_conv::dt_logical: