Here is a boost example:
typedef boost::multi_array<double, 1> array_type;
typedef array_type::index index;
array_type A(boost::extents[100]);
for(index i = 0; i != A.size(); ++i) {
A[i] = (double)i;
}
// creating view
array_type::index_gen indices;
typedef boost::multi_array_types::index_range range;
array_type::array_view<1>::type myview = A[ indices[range(0,50)] ];
What this code does is creating a subarray or view mapping onto the original array. This view is continuous and covers from 0th to 50th elements of an original array.
What if I need to explicitly define elements I'd like to see in the view? How can I create a view with indices like [1, 5, 35, 23] ? Any ideas?