# HG changeset patch # User Jaroslav Hajek # Date 1265451103 -3600 # Node ID 217d36560dfafb0e60be64794c129ecb3972cae2 # Parent 9a16a61ed43d6e1064ef698f6d8c73ba6eef17eb small fixes to accumarray diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2010-02-06 Jaroslav Hajek + + * general/accumarray.m: Small fixes. + 2010-02-05 Jaroslav Hajek * general/accumarray.m: Rewrite. Split sparse and dense case. Treat diff --git a/scripts/general/accumarray.m b/scripts/general/accumarray.m --- 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 diff --git a/src/data.cc b/src/data.cc --- 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);