The code giving me an error is like below. And when I remove the "const" from the parameter type, it worked.
#include<iostream>
#include<vector>
#include</usr/include/eigen3/Eigen/Core>
using namespace std;
void func(const vector<double>& x)
{
Eigen::VectorXd X=Eigen::Map<Eigen::VectorXd>(&x[0], x.size());
}
int main(){
vector<double> x(100);
func(x);
}
The error is like below. I can't understand it. Could anybody explain it to me? And is there a good way to do the same thing with "const" keyword?
error: invalid conversion from ‘const value_type* {aka const double*}’ to ‘Eigen::Map<Eigen::Matrix<double, -1, 1>, 0, Eigen::Stride<0, 0> >::PointerArgType {aka double*}’ [-fpermissive]
Eigen::VectorXd X=Eigen::Map<Eigen::VectorXd>(&x[0], x.size());