octave-maintainers
[Top][All Lists]
Advanced

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

Re: Correct behavior of common_size()?


From: Jordi Gutiérrez Hermoso
Subject: Re: Correct behavior of common_size()?
Date: Wed, 14 Mar 2012 13:20:15 -0400

On 14 March 2012 12:59, Robert T. Short <address@hidden> wrote:
> When I include an empty vector in common_size() I get, for example,
>
> octave> [ec,x,y,z]=common_size([],1,[1 2 3])
> ec =  1
> x = [](0x0)
> y =  1
> z =
>
>   1   2   3
>
> In other words, I get an error because the empty matrix can't be sized to
> match the other elements.  I wonder if this is the correct behavior, though.

It seems to me that common_size should be a special case of
broadcasting arrays to a common shape. Accordingly, the broadcasting
rules do not apply to dimensions of size zero, only size one.

Ben was asking a while ago for a function like common_size that
applied all of the broadcasting rules. I was hesitant to encourage
that development, because one of the objectives of broadcasting is to
not actually fill your RAM with useless copies of the same data (not
to mention the time it takes to do so). Perhaps it's nevertheless
useful to extend common_size to do all of the broadcasting.

- Jordi G. H.


reply via email to

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