|
Boost Users : |
Subject: Re: [Boost-users] multi_array iteration problem
From: Petros (pmamales_at_[hidden])
Date: 2012-06-19 11:44:42
Hi Ron,
Thank you very much.
All the best,
Petros
From: Ronald Garcia
Sent: Tuesday, June 19, 2012 10:52 AM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] multi_array iteration problem
Hi Petros,
On Jun 18, 2012, at 7:54 PM, Petros wrote:
Hi,
I would greatly appreciate your help with this, as I have spent considerable time and have run out of ideas:
In the following piece of code, I want to recursively visit the elements of a 4-dimensional array.
If all the dimensions are the same, there is no problem.
However, if there is a dimension of different length the program crashes !
TIA,
Petros
...
The program :
...
iterator3 begin3 = a.begin() + lowerBounds[3], end3 = a.begin() + upperBounds[3];
for ( iterator3 i3 = begin3; i3 != end3; ++i3 ){
iterator2 begin2 = i3->begin() + lowerBounds[2], end2 = i3->begin() + upperBounds[2];
for ( iterator2 i2 = begin2; i2 != end2; ++i2 ){
iterator1 begin1 = i2->begin() + lowerBounds[1], end1 = i2->begin() + upperBounds[1];
for ( iterator1 i1 = begin1; i1 != end1; ++i1 ){
iterator0 begin0 = i1->begin() + lowerBounds[0], end0 = i1->begin() + upperBounds[0];
for ( iterator0 i0 = begin0; i0 != end0; ++i0 ){
cout << *i0 << endl;
}
}
}
}
It looks like you are indexing lowerBounds and upperBounds in the wrong order (3,2,1,0 instead of 0,1,2,3).
HTH,
Ron
--------------------------------------------------------------------------------
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net