Traversing through a multi_array and accessing the data set...
How do you access the data in the example below?
Thanks much,
Graham
boost::multi_array
On Tue, 4 Sep 2007, Graham Reitz wrote:
How do you access the data in the example below?
Thanks much,
Graham
boost::multi_array
multi_test; boost::multi_array ::iterator multi_test_iter; boost::multi_array ::extent_gen extents; multi_test.resize(extents[2][3]);
for (multi_test_iter = multi_test.begin(); multi_test_iter != multi_test.end(); ++multi_test_iter) { // How do you get(set) at the current data set pointed to by multi_test_iter? }
multi_test_iter in this example is an iterator on rows. You need to add an extra loop to iterate on those elements, something like for ( multi_test_iter = multi_test.begin() ; multi_test_iter != multi_test.end() ; ++ multi_test_iter ) { for ( boost::multi_array< double , 2 >::value_type::iterator inner_multi_test_iter = multi_test_iter->begin() , end_inner = multi_test_iter->end() ; inner_multi_test_iter != end_inner ; ++ inner_multi_test_iter ) { // here, *inner_mult_test_iter returns a reference to a double } } -- François Duranleau
Ahh...thanks much!
On 9/4/07, François Duranleau
On Tue, 4 Sep 2007, Graham Reitz wrote:
How do you access the data in the example below?
Thanks much,
Graham
boost::multi_array
multi_test; boost::multi_array ::iterator multi_test_iter; boost::multi_array ::extent_gen extents; multi_test.resize(extents[2][3]);
for (multi_test_iter = multi_test.begin(); multi_test_iter != multi_test.end(); ++multi_test_iter) { // How do you get(set) at the current data set pointed to by multi_test_iter? }
multi_test_iter in this example is an iterator on rows. You need to add an extra loop to iterate on those elements, something like
for ( multi_test_iter = multi_test.begin() ; multi_test_iter != multi_test.end() ; ++ multi_test_iter ) { for ( boost::multi_array< double , 2 >::value_type::iterator inner_multi_test_iter = multi_test_iter->begin() , end_inner = multi_test_iter->end() ; inner_multi_test_iter != end_inner ; ++ inner_multi_test_iter ) { // here, *inner_mult_test_iter returns a reference to a double } }
-- François Duranleau _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
François Duranleau
-
Graham Reitz