Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi-array] Extracting dimension information from a multi-array
From: Hicham Mouline (hicham_at_[hidden])
Date: 2010-09-12 04:51:30


 

From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Ryan McConnehey
Sent: 12 September 2010 07:37
To: Boost-users
Subject: [Boost-users] [multi-array] Extracting dimension information from a
multi-array

 

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

  _____

 

I believe the shape() member function is what you're looking for,



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