It's possible to convert an Eigen::Map
to a Matrix
by assignment:
vector<float> v = { 1, 2, 3, 4 };
auto m_map = Eigen::Map<Eigen::Matrix<float, 2, 2, Eigen::RowMajor>>(&v[0]);
Eigen::MatrixXf m = m_map;
cout << m << endl;
This produces:
1 2
3 4
If I try to do something similar with a Tensor
:
vector<float> v = { 1, 2, 3, 4 };
auto mapped_t = Eigen::TensorMap<Eigen::Tensor<float, 2, Eigen::RowMajor>>(&v[0], 2, 2);
Eigen::Tensor<float, 2> t = mapped_t;
I simply get the compiler error YOU_MADE_A_PROGRAMMING_MISTAKE
. Is there any way to convert a TensorMap to a Tensor?