### Error when creating row vector using map in Eigen

I am trying to map my ` std:vector ` into an Eigen row vector so I can perform element-wise multiplication. I have the error:
 ``123`` `````` no matching function for call to ‘Eigen::Map, 1, -1>, 0, Eigen::Stride<0, 0> >::Map(Eigen::PlainObjectBase >::Scalar*, Eigen::EigenBase >::Index)’ 179 | Eigen::RowVectorXcd eeKX = Eigen::Map(eKX.data(), eKX.size()); ``````

And the code is:
 ``123456789`` ``````Matrix eKX; eKX.setZero(); for(int i = 0; i < nx; i++){ eKX[i] = //some expression } Eigen::RowVectorXcd eeKX = Eigen::Map(eKX.data(), eKX.size()); //error here std::cout << eeKX << endl;``````

There's no std::vector in the code snippet above?
 ``12345678910111213141516171819202122232425`` ``````#include #include #include #include #include using namespace std::literals; int main() { std::vector> my_vector { 1.0 + 1.0i, 3.0 + 2i, 4.0 - 5.0i }; Eigen::Map map_of_vector(my_vector.data(), my_vector.size()); // map_of_vector does not contain a copy of my_vector's elements map_of_vector *= 0.5; std::cout << map_of_vector << '\n'; for (auto elt: my_vector) std::cout << elt << " "; std::cout << '\n'; // copy_of_vector contains a copy of my_vector's elements Eigen::RowVectorXcd copy_of_vector = map_of_vector; copy_of_vector *= 2; std::cout << copy_of_vector << '\n'; for (auto elt: my_vector) std::cout << elt << " "; std::cout << '\n'; }``````
Last edited on
Thanks!
Topic archived. No new replies allowed.