[multi-array] Extracting dimension information from a multi-array

From: boost-users-bounces@lists.boost.org
[mailto:boost-users-bounces@lists.boost.org] 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

Ryan McConnehey
Do you have an example of how shape() works? The shape method isn't used in any of the multi-array tutorials. Also, the reference material says the shape method returns a list of "NumDims" but the return signature specifies a "const size_type *" is returned. How is "const size_type *" a list of dimension?
Since it is not a container, you will need to use the ::dimensionality to see
how far to iterate this bare pointer.
e.g. to put it into a bounded ublas vector vector:
const static std::size_t rank = ublas::multi_array

Ryan McConnehey
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.

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
participants (4)
-
Brian Davis
-
Hicham Mouline
-
Jesse Perla
-
Ryan McConnehey