Thank you very much for your quick response.
To be more concrete:
#include "boost/multi_array.hpp"
//stl
#include <algorithm>
#include <iostream>
using namespace std;
int main(int argc, char **argv){
const int M = 3;
const int N = 4;
typedef boost::multi_array< int, 2> array_t;
typedef array_t::index index;
typedef array_t::index_range range_t;
typedef array_t::array_view<1>::type array_1d_view_t;
array_t A( boost::extents[M][N], boost::fortran_storage_order() );
//initialize:
int num = 0;
for ( index i = 0; i < M ; ++i ) {
for ( index j = 0; j < N ; ++j ) {
A[i][j] = ++num;
}
}
//show initialization
cout << "A: 3x4 array" << endl;
for ( index i = 0; i < M ; ++i ) {
for ( index j = 0; j < N ; ++j ) {
cout << A[i][j] << "\t";
}
cout << endl;
}
cout <
I, say, have a 3d array (fortran storage), and want to create a view to it so that I select say: grid[ indices[ [range(9,10)] [3], [range(9,10)] ];
I am not clear on exactly what this creates: from the documentation, I see this creating a 3d view.
I think this would be a 2d slice since you provided the single value 3 in the second position. The underling type would be accessible through either the templated array_view typedefs or else the array_view_gen mechanism.
Can I use stl-like iterators on this, to use stl type algorithms?
You can use stl-algorithms on the 2d view. Be aware that iterators retrieved from the 2D view (via begin(), end()) walk over 1D views in your example.
Is there any other repository of examples that would use high-level constructs like this so that I could look into a few examples?
Other than the tutorial, the reference, and an article [1], I'm not aware of any. - Rhys [1] http://www3.interscience.wiley.com/journal/109793810/abstract _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users