octave-maintainers
[Top][All Lists]
Advanced

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

Empty matrices don't have trailing ones?


From: Jordi Gutiérrez Hermoso
Subject: Empty matrices don't have trailing ones?
Date: Thu, 10 May 2012 00:46:37 -0400

I'm trying to figure out the rationale for having dim_vector::redim
padding all-zero dim_vectors with zeros instead of ones. This results
in surprising behaviour like some empty matrices getting their
trailing dimensions being zero instead of one, so this errors out:

    x = zeros (0, 0);
    x(:,:,1)

I don't think it should (and neither does Matlab, I'm told). Note that
this is a peculiarity of trailing dimensions being zero instead of the
usual singletons.These two are fine, because dim_vector::redim doesn't
pad them with zeros:

    x = zeros (1, 0, 0);
    x(1,:,:)
    x(1,:,:,1)

This dim_vector::redim special-cased zero padding is the reason for bug #33216:

    https://savannah.gnu.org/bugs/?33216

But it looks like someone deliberately special-cased the zero-padding
case, so I don't want to just trample over the intentions of whoever
wrote that. Can someone explain? If not, I'm thinking of just getting
rid of this special-casing.

TIA,
- Jordi G. H.


reply via email to

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