Some of my Eigen C++ methods need to be callable from plain C++, therefore I want to provide overloaded functions that accept c arrays and map them to ArrayXd using Eigen::Map.
The code I currently have looks like this:
bool Dmp::executeStep(double* position, double* velocity,
double* acceleration, const int len)
{
Map<ArrayXd> posMap(position, len);
Map<ArrayXd> velMap(velocity, len);
Map<ArrayXd> accMap(acceleration, len);
return executeStep(posMap, velMap, accMap);
}
bool Dmp::executeStep(ArrayXd& position, ArrayXd& velocity, ArrayXd& acceleration)
{
//Code that modifies position, velocity and acceleration
}
This does not work because there is no known conversation from Map<ArrayXd>
to ArrayXd&
.
What is the correct way of doing this?
edit: The answer that luk32 pointed out below would work, however it involves moving my code to the header file which is something I would like to avoid if at all possible.
Eigen
andc
tag? Really ... what the heck. – Subrogate