$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] [multi-array] Extracting dimension information from a multi-array
From: Jesse Perla (jesseperla_at_[hidden])
Date: 2010-09-12 11:21:48
Ryan McConnehey <mccorywork <at> gmail.com> writes:
> 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<double, 3>::dimensionality;
//Or just 3 in this case... Showing you this could work in generic code
ublas::bounded_vector<std::size_t, rank> dims;
std::copy(var.shape(), var.shape() + rank, dims.begin());