In eigen c++, how do you
map a vectorXf to a matrixXf
(of appropriate dimensions)
(there is good docs on
how to do it for external objects
so i know we can do:
MatrixXf x_cen=Map<MatrixXf>(*x,*n,*p);
but what if xis a VectorXf?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the .data() member function followed by Map:
Then you can use vec_view_as_a_matrix just like any Eigen objects, modifications to vec_view_as_a_matrix will be reported to vec as well since they are sharing the memory. If you want to copy to a new MatrixXf object, then use the construction you wrote: