Mercurial > hg > octave-max
changeset 10042:b7915ebe8acf
implement index reduction rule for multiple constant ranges
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 30 Dec 2009 05:30:54 +0100 |
parents | 0240c7b34f54 |
children | 7fbdeaa9b0e0 |
files | liboctave/ChangeLog liboctave/idx-vector.cc |
diffstat | 2 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2009-12-30 Jaroslav Hajek <highegg@gmail.com> + + * idx-vector.cc (idx_vector::maybe_reduce): Implement reduction rule + for subsequent ones () indices. + 2009-12-28 John W. Eaton <jwe@octave.org> * file-ops.cc (fle_ops::mkdir_internal,
--- a/liboctave/idx-vector.cc +++ b/liboctave/idx-vector.cc @@ -618,13 +618,14 @@ case class_range: { // (i:k:end,p:q) reduces to a range if i <= k and k divides n. + // (ones (1, m), ones (1, n)) reduces to (ones (1, m*n)) idx_range_rep * r = dynamic_cast<idx_range_rep *> (rep); octave_idx_type s = r->get_start (), l = r->length (n); octave_idx_type t = r->get_step (); idx_range_rep * rj = dynamic_cast<idx_range_rep *> (j.rep); octave_idx_type sj = rj->get_start (), lj = rj->length (nj); octave_idx_type tj = rj->get_step (); - if (l*t == n && tj == 1) + if ((l*t == n && tj == 1) || (t == 0 && tj == 0)) { *this = new idx_range_rep (s + n * sj, l * lj, t, DIRECT); reduced = true;