Boost logo

Boost Users :

Subject: [Boost-users] [multi-array] Extracting dimension information from a multi-array
From: Ryan McConnehey (mccorywork_at_[hidden])
Date: 2010-09-12 02:37:14


I'm trying to extract dimension information from a boost multi-array. The documentation gives the following short example.

typedef boost::multi_array<double, 3> array_type;
typedef array_type::index index;
array_type A(boost::extents[3][4][2]);

// Assign values to the elements
int values = 0;
for(index i = 0; i != 3; ++i) 
  for(index j = 0; j != 4; ++j)
    for(index k = 0; k != 2; ++k)
      A[i][j][k] = values++;

This is okay if you know the dimension information. Most of the time, though, you don't want to hard code the dimensions into your loop.  The multi_array::dimensionality specifies the dimensions of the array.  How do I find the max elements of each dimension?

Ryan

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