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
MultiArray)
typedef std::vector dimensions_t;
typedef boost::multi_array 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++ )
dims.push_back(t.shape()[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?