octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #47287] accumarray unable to handle empty list


From: Carnë Draug
Subject: [Octave-bug-tracker] [bug #47287] accumarray unable to handle empty list of subscripts
Date: Sun, 28 Feb 2016 18:39:25 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0 Iceweasel/38.6.1

Follow-up Comment #1, bug #47287 (project octave):

I have attached a file that fixes this issue. It has two csets, fixing two
different bug related bugs.

I found that this was not an issue for the special cases of sum, max, and min
because they use a special code path. I still added test cases for them to
avoid regressions in the future.

I don't really like the fix. I couldn't find an elegant way to do it, and had
to resort to a "n != 0". If anyone has a better plan that would be great.

The second cset fixes a related issue which is being able to automatically
find the output size when list of subscript is empty.

This whole thing introduce a Matlab incompatibility though (I guess it could
be considered a Matlab bug). It was not on purpose but came out as a side
effect of fixing the support for empty SUBS.

When FUNC returns a cell element, and SUBS is empty, we are now returning a
cell array (previously we would error).  This makes sense to me, FUNC is meant
to create a cell array. Matlab seems to always return an array of doubles. 
However, we still only do this for the general case of '@(x) {x}'.


>> accumarray (zeros (0, 1), zeros (0, 1), [0 1] , @(x) {x})
ans = {}(0x1)
>> accumarray (zeros (0, 1), zeros (0, 1), [0 1] , @(x) {x+1})
ans = [](0x1)


(file #36499)
    _______________________________________________________

Additional Item Attachment:

File name: accumarray-zero-length-dims.cset Size:3 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?47287>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]