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

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

[Octave-bug-tracker] [bug #63453] output dimension of cell2mat with empt


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #63453] output dimension of cell2mat with empty inputs
Date: Tue, 7 Feb 2023 22:34:26 -0500 (EST)

Follow-up Comment #3, bug #63453 (project octave):

after looking at how matlab handles sized empties for a number of functions,
I'm guessing this is an unintentional side effect.  it seems for a lot of
functions matlab has a rule for first setting output size, then fills the
data. e.g., functions like sum all collapse the operating dimension to size 1:



sum(ones(0,0,2), 1) 
ans =  [](1x0x2)

sum(ones(0,0,2), 2) 
ans =  [](0x1x2)

sum(ones(0,0,2), 3) 
ans = [](0x0)  


except of course for inconsistencies with []: 

sum (ones(0,0))
ans = [](0x0)

sum (ones(0,0),1)
ans = [](1x0)

sum (ones(0,0),2)
ans = [](0x1)


in this case I'd guess cell2mat has some content-blind rule to set output
size. Looking at the help, it seems it would set the output dim1 and dim2
according to number of rows and columns across the cells. empty cells give odd
results, but depending on how it steps through cells to add this up with size
or numel or whatever, it gets zero elements in both directions. output size
for dim>2 is always = input size, so it makes no change there. 

so, I'm sure there's some logic to it. It makes no more sense than the other
functions like I mentioned above. But it does at least seem somewhat
consistent. 


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63453>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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