help-octave
[Top][All Lists]
Advanced

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

Re: senseless warning in octave-3.6.2


From: Mero
Subject: Re: senseless warning in octave-3.6.2
Date: Mon, 02 Jul 2012 07:14:20 +0300
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20120614 Thunderbird/13.0.1

On 01/07/2012 23:20, Sergei Steshenko wrote:
> A scaled down example:
> 
> "
> octave:1> foo = zeros(1, 1e3);
> octave:2> bar = ones(1e3, 1);
> octave:3> doo = foo + bar;
> warning: operator +: automatic broadcasting operation applied
> octave:4> size(doo)
> ans =
> 
>    1000   1000
> 
> octave:5> size(foo)
> ans =
> 
>       1   1000
> 
> octave:6> size(bar)
> ans =
> 
>    1000      1
> 
> octave:7>
> "
> 
> - why the result is a matrix despite the fact that both operands of the '+' 
> operator are vectors ?

Automatic broadcasting means that the above is now equivalent to:

    % one is a column vector, the other a row vector
    doo = bsxfun(@plus, foo, bar);

Do I like this feature, NO. I think it should just give an error of
"size mismatch" and let the user decide what to do...



reply via email to

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