@@ -362,14 +362,16 @@ template <> struct select_npy_type<uint64_t> {
362
362
363
363
// TODO change to Vector template so useable for Eigen vectors,
364
364
// 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) {
366
366
detail::_interpreter::get (); // interpreter needs to be initialized for the
367
367
// numpy commands to work
368
368
NPY_TYPES type = select_npy_type<Numeric>::type;
369
369
if (type == NPY_NOTYPE) {
370
370
std::vector<double > vd (v.size ());
371
371
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 ());
373
375
PyObject *varray =
374
376
PyArray_SimpleNewFromData (1 , &vsize, NPY_DOUBLE, (void *)(vd.data ()));
375
377
return varray;
@@ -389,7 +391,9 @@ template <typename Vector> PyObject *get_array(const Vector &v) {
389
391
if (type == NPY_NOTYPE) {
390
392
std::vector<double > vd (v.size ());
391
393
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 ());
393
397
PyObject *varray =
394
398
PyArray_SimpleNewFromData (1 , &vsize, NPY_DOUBLE, (void *)(vd.data ()));
395
399
return varray;
0 commit comments