# HG changeset patch # User Jaroslav Hajek # Date 1264018492 -3600 # Node ID b6b65e71049b0f158f78d174172bb1e0a7e07f46 # Parent c2f1cdb59821b6a7e71b6a89c992d20dd316bcb0 optimize cumsum with logicals diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2010-01-20 Jaroslav Hajek + + * boolNDArray.cc (boolNDArray::cumsum): Sum directly in double to + avoid a copy. + 2010-01-20 John W. Eaton * dim-vector.h: Style fixes. Remove Emacs local variables block. diff --git a/liboctave/boolNDArray.cc b/liboctave/boolNDArray.cc --- a/liboctave/boolNDArray.cc +++ b/liboctave/boolNDArray.cc @@ -72,15 +72,16 @@ NDArray boolNDArray::sum (int dim) const { - // NOTE: going via octave_idx_type is faster even though it requires a conversion. + // NOTE: going via octave_idx_type is typically faster even though it + // requires a conversion. return do_mx_red_op , bool> (*this, dim, mx_inline_count); } NDArray boolNDArray::cumsum (int dim) const { - // NOTE: going via octave_idx_type is faster even though it requires a conversion. - return do_mx_cum_op , bool> (*this, dim, mx_inline_cumcount); + // In this case, it's better to sum directly to doubles. + return do_mx_cum_op (*this, dim, mx_inline_cumcount); } boolNDArray