diff scripts/general/accumarray.m @ 10269:217d36560dfa

small fixes to accumarray
author Jaroslav Hajek <highegg@gmail.com>
date Sat, 06 Feb 2010 11:11:43 +0100
parents 9a16a61ed43d
children 297996005012
line wrap: on
line diff
--- 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