octave-maintainers
[Top][All Lists]
Advanced

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

Re: Multiplication of empty matrices?


From: Carnë Draug
Subject: Re: Multiplication of empty matrices?
Date: Tue, 9 Jun 2015 21:04:25 +0100

On 9 June 2015 at 20:49, Olaf Till <address@hidden> wrote:
> On Tue, Jun 09, 2015 at 10:59:18AM -0700, Rik wrote:
>> 6/9/15
>>
>> All,
>>
>> I came across this odd behavior for the multiplication of empty matrices:
>>
>> octave:1> x = zeros (0,1)
>> x = [](0x1)
>> octave:2> y = zeros (1,0)
>> y = [](1x0)
>> octave:3> x * y
>> ans = [](0x0)
>> octave:4> x .* y
>> error: product: nonconformant arguments (op1 is 0x1, op2 is 1x0)
>> octave:4> x * y'
>> error: operator *: nonconformant arguments (op1 is 0x1, op2 is 0x1)
>> magic(3) * x
>> error: operator *: nonconformant arguments (op1 is 3x3, op2 is 0x1)
>
> Imagine the dimensions which are zero in each of your examples
> actually vary between zero and some positive integer. Then I would not
> expect that the outcome (failure or allowed) changes only because the
> dimension gets zero. So the results of your examples seem reasonable
> to me (since the same rules are applied for zero or any other positive
> integer).
>
>> <snip>  I would think that an empty matrix multiplying
>> anything would return the empty matrix.
>
> I can see no reason for this ...
>

Since Octave performs automatic broadcasting, I would expect a 0x0 array,
as can be seen calling bsxfun directly:

    octave> bsxfun (@times, zeros (0, 1), zeros (1, 0))
    ans = [](0x0)

Carnë



reply via email to

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