Hi I have a few boost::multi_array defined as below:
typedef boost::multi_array<double, 3> region_prior_integral_image
I am trying to create an array of region_prior_integral_image
like the following:
unordered_map<string, int> filename_to_hash_key_map = get_filename_to_hash_key_map();
unordered_map<string, region_prior_integral_image> filename_to_region_prior_map = get_region_prior_integral_images();
region_prior_integral_image* image_cache = new region_prior_integral_image[5];
for(unordered_map<string, int>::iterator it = filename_to_hash_key_map.begin(); it != filename_to_hash_key_map.end(); it++){
image_cache[it->second] = filename_to_region_prior_map[it->first];
}
However the program is terminating with the following: SemanticTextonForest: /home/aly/libs/boost_1_51_0/stage/include/boost/multi_array/multi_array_ref.hpp:488: boost::multi_array_ref<T, NumDims>& boost::multi_array_ref<T, NumDims>::operator=(const ConstMultiArray&) [with ConstMultiArray = boost::multi_array<double, 3ul>, T = double, long unsigned int NumDims = 3ul, boost::multi_array_ref<T, NumDims> = boost::multi_array_ref<double, 3ul>]: Assertion
std::equal(other.shape(),other.shape()+this->num_dimensions(), this->shape())' failed.`
And I have no idea why?
I know I could just use a vector, but for arguments sake lets say I wanted to have an array of region_prior_integral_images
Thanks
Let's say we have two region_prior_integral_image
instances: A and B. If you want to assign B to A, like A = B;
, the shapes of A
and B
must be equal. The error message is saying that, in your code image_cache[it->second] = filename_to_region_prior_map[it->first];
, the two arrays are of different shapes.
How do you created the arrays in filename_to_region_prior_map
? I guess you used this constructor to specify the shapes: multi_array<double,3> B(boost::extents[i][j][k])
. Hence their shape is [i][j][k]
. But when you create the image_cache
, the default constructor is invoked. So the two shapes mismatch.
My opinion is to store pointers of region_prior_integral_image
in your code, which will save a lot of copy as well.