octave-maintainers
[Top][All Lists]
Advanced

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

Re: fix null assignment


From: Jaroslav Hajek
Subject: Re: fix null assignment
Date: Thu, 18 Sep 2008 14:47:03 +0200

On Thu, Sep 18, 2008 at 2:23 PM, Levente Torok <address@hidden> wrote:
> On Thursday 18 September 2008, Jaroslav Hajek wrote:
>
> Hi all,
>
> However, I think matlab compatibility is the top priority
> I believe octave was much more consistent in terms of mat
>
>> hello,
>>
>> the attached patch fixes the following problems / Matlab
>> incompatibilities with null assignment in Octave.
>>
>> 2. a = 1:5; a(1:5) = []
>> --> a is 0-by-0 in Octave, 1-by-0 in Matlab
>
>> 3. a = 1:5; a = a'; a(1:5) = []
>> --> a is 0-by-0 in Octave, 0-by-1 in Matlab
>
>
>> 4. a = ones (3); a(:,:) = []
>> --> a is 0-by-0 in Octave, 0-by-3 in Matlab
>
>> 5. a = ones (3); a(1:3,1:3) = []
>> --> a is 0-by-0 in Octave, error in Matlab
>
>> 6. a = ones (3); a(1:2,1:2) = []
>> --> a is unaffected in Octave (! BUG), error in Matlab
>
> I don't believe it makes much sense to follow Matlab in these aspects
> with the exception of the bug.
>
> To make myself clear why I think so:
>
> a = 1:5; a(1:5) = []; a * a'
> is 0 in matlab and ans = [](0x0)
>
> While the matlab version is handy when dealing with real data but faulty in 
> terms of math.
> I mean how can a scalar product equal to 0 when there are no items in the 
> product.
>

An empty sum is *defined* to be zero, and a matrix product with the
*inner* dimension empty is nothing else than an empty sum.
Therefore, this behaviour is completely OK. I'm glad that it also
works with the patch I've posted.
Similarly, an empty product is defined as unity.

-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

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