[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: empty ranges are matrices ?
From: |
John W. Eaton |
Subject: |
Re: empty ranges are matrices ? |
Date: |
Tue, 29 Mar 2005 14:13:38 -0500 |
On 29-Mar-2005, Jean-Francois Cardoso <address@hidden> wrote:
| It is not a problem that I cannot work around, of course. But it may
| appear counterintuitive: I was disturbed at first that an empty object
| cannot be "stacked" freely, in the sense that:
|
| octave> r = 1:-1 ; s = [ r 1 ]
| s = 1
| octave> r = 1:-1 ; s = [ r ; 1 ]
| error: number of columns must match (1 != 0)
|
| while I can do
|
| octave> vide = zeros(0) ;
| octave> [ vide 1 ] ;
| octave> [ vide ; 1 ] ;
| octave>
|
| but I now understand that an empty range should be more naturally
| represented as [](1x0) than as [](0x0). Hence the above error.
Yes, I think the behavior is consistent, but it does not seem to be
compatible. Matlab seems to allow
r = 1:-1 ; s = [ r ; 1 ]
to succeed without any warning, but it will warn for other mismatches,
for example
[zeros(10,1), 1]
| But we may have a more serious problem here:
|
| octave> zeros(0)
| ans = [](0x0)
| octave> zeros([])
| warning: zeros (A): use zeros (size (A)) instead
| ans = 0
| octave>
|
| Octave does produce a warning, but nothing more.
|
| Do we really want zeros([]) to return a SCALAR rather than an empty
| object?
Probably it should just produce an error now.
jwe
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------