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 16:43:40 +0300
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20120614 Thunderbird/13.0.1

On 02/07/2012 16:26, Jordi Gutiérrez Hermoso wrote:
> 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.
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
> 

Yes I am aware of that. My point is that the error should be the default
behavior, and automatic broadcasting be optional.

That's my opinion anyway :)



reply via email to

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