octave-maintainers
[Top][All Lists]
Advanced

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

Re: [major] struct array indexing in tip


From: Thorsten Meyer
Subject: Re: [major] struct array indexing in tip
Date: Sun, 25 Jan 2009 11:48:00 +0100
User-agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103)

Hi,

Jaroslav Hajek wrote:
While generating some tests for structure indexing, I came across this behaviour
 in octave (revision 83b8c739d626):

octave:165> clear
octave:166> b=struct ("name", {"a", "b", "c"; "d", "e", "f"}, "value", 0);
octave:167> b(1, [1,3]).name
ans = a
ans = c
octave:168> [b(1, [1,3]).name] = deal("aa", "cc");
octave:169> b(1, [1,3]).name
ans = aa
ans = cc

this works as I would have expected. However:

octave:173> [b(1:2, [1,3]).name] = deal("aaa", "ddd", "ccc", "fff");
error: A(I,J,...) = X: dimensions mismatch

Is that intended behaviour?

    

This stuff never worked correctly, so it's hard to judge by older
versions, but I think that given that cs-lists aren't allowed to have
shape, they should automatically reshape when assigned to lvalues like
a{1:2,3:4}. This following patch should guarantee this.
http://hg.savannah.gnu.org/hgweb/octave/rev/35656d6ad061
  
With my freshly built octave, the above bug is gone. Thanks.
  
Now trying to nest struct arrays:

octave:173> b(3,1).value = b;
octave:174> b(3,1).value(1, [1,3]).name
ans = aa
ans = cc
octave:175> [b(3,1).value(1, [1,3]).name] = deal("aaa", "ccc")
error: invalid cs-list length in assignment
error: assignment to structure element failed
error: assignment failed, or no method for `struct = cs-list'

Should that work or have I misunderstood something?

    

It should work. I don't see this behaviour; can you upgrade to the tip?

  
During the last couple of days I found it really difficult to upgrade to the tip: more patches kept coming in while I was building octave. :-)
Anyway. With octave freshly built this morning I no longer see the above behaviour.

regards

Thorsten

reply via email to

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