[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Possible bug in the assignment operator when handling arrays of structs
From: |
Brendan Drew |
Subject: |
Possible bug in the assignment operator when handling arrays of structs which hold arrays of structs (or I just don't know how to correctly phrase the search on the bugs list) |
Date: |
Thu, 08 Sep 2005 14:00:56 -0600 |
User-agent: |
Mozilla Thunderbird 1.0 (X11/20041206) |
I'm afraid this is a bit involved, but I figured it's better to ask and
see if this has already been addressed before reporting it as a bug.
I have a structure, called a feature. Features hold several different
histograms (plain old matrices).
I have a structure called a state, which is described by a feature and
some book keeping data.
I have a structure called a SSM which holds a vector of states and some
book keeping data.
I have a matrix of SSM structures.
What I would /really/ like to do is something like this:
for i=1:r
for j=1:c
ssm(i,j) = UpdateSSM(ssm(i,j), newImageChunk(i,j));
end;
end;
I can't do that (octave complains about a mismatch of struct field names
when I do the assignment). So I do this instead:
for i=1:r
for j=1:c
temp = UpdateSSM(ssm(i,j), newImageChunk(i,j));
ssm(i,j).states = temp.states; % <--- This is the assignment that
doesn't do what I expect it to
end;
end;
ssm(i,j).states is an array of states as described above.
Any thoughts on what is going wrong? I've checked the return value, and
it is definitely correct. I've tried a couple things to get the code to
work:
for i=1:r
for j=1:c
temp = UpdateSSM(ssm(i,j), newImageChunk(i,j));
n = length(temp.states);
for k=1:n
ssm(i,j).states(k) = temp.states(k); % <--- also doesn't work
end;
end;
end;
I also tried:
for i=1:r
for j=1:c
temp = UpdateSSM(ssm(i,j), newImageChunk(i,j));
n = length(temp.states);
for k=1:n
ssm(i,j).states(k).descriptor.gray = temp.states(k).descriptor.gray;
% gray is a gray scale histogram, descriptor is a feature as
described
% above
% Copy the remaining histograms stored in descriptor
end;
end;
end;
I even went so far as to attempt to copy each histogram element by
element. This (also) didn't work. Any thoughts?
Thanks much,
Brendan.
--
Brendan Drew
Research Scientist
PercepTek, Inc.
12395 North Mead Way
Littleton, CO 80125
Tel: 720-344-1037 x 126
Fax: 720-344-2360
-------------------------------------------------------------
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
-------------------------------------------------------------
- Possible bug in the assignment operator when handling arrays of structs which hold arrays of structs (or I just don't know how to correctly phrase the search on the bugs list),
Brendan Drew <=