Mercurial > hg > octave-avbm
changeset 10269:217d36560dfa
small fixes to accumarray
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 06 Feb 2010 11:11:43 +0100 |
parents | 9a16a61ed43d |
children | 6ffed9bb5598 |
files | scripts/ChangeLog scripts/general/accumarray.m src/data.cc |
diffstat | 3 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2010-02-06 Jaroslav Hajek <highegg@gmail.com> + + * general/accumarray.m: Small fixes. + 2010-02-05 Jaroslav Hajek <highegg@gmail.com> * general/accumarray.m: Rewrite. Split sparse and dense case. Treat
--- a/scripts/general/accumarray.m +++ b/scripts/general/accumarray.m @@ -148,6 +148,8 @@ subs = num2cell (subs, 1); endif subs = sub2ind (sz, subs{:}); + elseif (length (sz) < 2) + error ("accumarray: needs at least 2 dimensions"); endif @@ -174,6 +176,8 @@ if (isinteger (val)) zero = intmin (class (val)); + elseif (islogical (val)) + zero = false; elseif (fillval == 0 && all (val(:) >= 0)) ## This is a common case - fillval is zero, all numbers nonegative. zero = 0; @@ -198,6 +202,8 @@ if (isinteger (val)) zero = intmax (class (val)); + elseif (islogical (val)) + zero = true; else zero = NaN; # Neutral value. endif
--- a/src/data.cc +++ b/src/data.cc @@ -6347,7 +6347,7 @@ else retval = do_accumarray_sum (idx, vals.float_array_value (), n); } - else if (vals.is_numeric_type () || vals.is_bool_type () || vals.is_string ()) + else if (vals.is_numeric_type () || vals.is_bool_type ()) { if (vals.is_complex_type ()) retval = do_accumarray_sum (idx, vals.complex_array_value (), n);