boost::multi_array SWIG binding

Hi all,
I'm fairly new to C++ and learning as I go, but there is very little info
out there on my particular problem.
I am trying to turn a model I've written in C++ into a python module
using SWIG.
The main problems I'm having are initializing Boost multiarray containers then
getting data into and out of them.
Here is some sample code:
#include <iostream>
#include <vector>
#include <algorithm>
#include "boost/multi_array.hpp"
typedef boost::multi_array

AMDG NJ Duncan wrote:
I'm fairly new to C++ and learning as I go, but there is very little info out there on my particular problem.
I am trying to turn a model I've written in C++ into a python module using SWIG. The main problems I'm having are initializing Boost multiarray containers then getting data into and out of them.
Here is some sample code:
<snip>
Unfortunately I get the following error message:
python: /usr/include/boost/multi_array/multi_array_ref.hpp:481: boost::multi_array_ref
& boost::multi_array_ref ::operator=(const ConstMultiArray&) [with ConstMultiArray = boost::multi_array , T = double, long unsigned int NumDims = 2ul]: Assertion `std::equal(other.shape(), other.shape()+this->num_dimensions(), this->shape())' failed. I think I have assigned the array extents incorrectly, but I'm not sure of the proper way to do this as part of a C++ class.
I don't think that's the problem. Something is assuming that boost::multi_array has a normal assignment operator--it doesn't. You can only assign multi-arrays that have the same dimensions. Since there are no assignments in the code you posted, it's hard to tell where the problem is. If you can get a stack trace from the assertion, the error will probably be easy to spot.
Any ideas, I'm starting to pull my hair out, I hope there is a simple answer.
In Christ, Steven Watanabe
participants (2)
-
NJ Duncan
-
Steven Watanabe