If the Map's parameter is a non-const type (e.Eigen::VectorXd) then it assumes that it can modify the raw buffer (in your case *data). As the function expects a const qualified buffer, you have to tell the map that it's const. Define your typedef as