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: Jordi Gutiérrez Hermoso
Subject: Re: senseless warning in octave-3.6.2
Date: Mon, 2 Jul 2012 09:26:07 -0400

On 2 July 2012 00:14, Mero <address@hidden> wrote:
> 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...

If you want that to be an error, turn it into one:

    warning error Octave:broadcast

- Jordi G. H.


reply via email to

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