Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi-array] Extracting dimension information from a multi-array
From: Brian Davis (bitminer_at_[hidden])
Date: 2011-07-15 17:38:06

I just viewed this while trying to figure out how to access the
dimensionality of MultiArray

 Since the above code works we can access a specific dimension like so.
> var.shape()[1] //as long as the operator values exists within the
> dimension
> Yes.Since the type returned from var.shape() is a raw pointer, you should be able
> to access it under all circumstances like this.
Is raw pointers seriously how we should be accessing Boost.MultiArray in the
age of std::vector? I was expecting something like (which is what I use in
my code that does not use MultiArray which I have here adapted to use

typedef std::vector<size_t> dimensions_t;
typedef boost::multi_array<double, 2> TForm_t;

dimensions_t dimensions( TForm_t t )
    dimensions_t dims;
    TForm_t::size_type dim;
    for( int i = 0; i < t.num_dimensions(); i++ )
    return dims;

dimensions_t dims = dimensions(t);

At least with above I get a std::vector access exception when accessing
dims[2] or greater. Using raw pointers I just get random memory values...
awesome. I'll add these to my pool of lottery numbers.

It seems as though Boost.MultiArray is designed to hide pointers and
bookeeping only to leave the programmer "hanging" when trying to get
something simple such as get the dimensions. Clearly this is was well
thought out. Am I missing something here?

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at