@@ -362,14 +362,16 @@ template <> struct select_npy_type<uint64_t> {
362362
363363// TODO change to Vector template so useable for Eigen vectors,
364364// should be enough since it also provides the end and begin methods
365- template <typename Numeric > PyObject *get_array (const std::vector<Numeric> &v) {
365+ template <typename Vector > PyObject *get_array (const Vector &v) {
366366 detail::_interpreter::get (); // interpreter needs to be initialized for the
367367 // numpy commands to work
368368 NPY_TYPES type = select_npy_type<Numeric>::type;
369369 if (type == NPY_NOTYPE) {
370370 std::vector<double > vd (v.size ());
371371 npy_intp vsize = v.size ();
372- std::copy (v.begin (), v.end (), vd.begin ());
372+ // Eigen Vectors do not support begin/end() in the currently stable version
373+ // this can be changed once Eigen 3.4. is released
374+ std::copy (v.data (), v.data () + v.size (), vd.begin ());
373375 PyObject *varray =
374376 PyArray_SimpleNewFromData (1 , &vsize, NPY_DOUBLE, (void *)(vd.data ()));
375377 return varray;
@@ -389,7 +391,9 @@ template <typename Vector> PyObject *get_array(const Vector &v) {
389391 if (type == NPY_NOTYPE) {
390392 std::vector<double > vd (v.size ());
391393 npy_intp vsize = v.size ();
392- std::copy (v.begin (), v.end (), vd.begin ());
394+ // Eigen Vectors do not support begin/end() in the currently stable version
395+ // this can be changed once Eigen 3.4. is released
396+ std::copy (v.data (), v.data () + v.size (), vd.begin ());
393397 PyObject *varray =
394398 PyArray_SimpleNewFromData (1 , &vsize, NPY_DOUBLE, (void *)(vd.data ()));
395399 return varray;
0 commit comments