octave-maintainers
[Top][All Lists]
Advanced

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

Re: Multiplication of empty matrices?


From: John W. Eaton
Subject: Re: Multiplication of empty matrices?
Date: Tue, 09 Jun 2015 16:01:34 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0

On 06/09/2015 01:59 PM, 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)

Is this what Matlab does?  I would think that an empty matrix multiplying
anything would return the empty matrix.

I think Octave is doing the right thing here. Matlab should be doing the same now. Originally, Matlab did not have dimensions for empty matrices (all empty matrices were just "empty") and operations on empty matrices usually returned empty matrices. Octave originally behaved the same as Matlab. Then I read Carl de Boor, An Empty Exercise, SIGNUM, Volume 25, pages 2-6, 1990 and C. N. Nett and W. M. Haddad, A System Theoretic Appropriate Realization of the Empty Matrix Concept, IEEE Transactions on Automatic Control, Volume 38, Number 5, May 1993 and realized that it's better to define operations that preserve the non-zero dimensions and always require dimensions to conform whether empty or not. So I fixed Octave and eventually TMW did the same for Matlab.

jwe




reply via email to

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