Say I have a Eigen::MatrixXd m, I can get its row i by m.row(i). I can also get pointer to this slice by auto p = m.row(i).data(). This should return a pointer to the first element of the row. At this point, however, because MatrixXd saves array in col major, this pointer would not point to the contiguous block to the matrix row which I would want to use later to pass in a Eigen::Map function.
For example, it I want to do
auto m2 = Eigen::Map<MatrixXd>(p, rows, cols);
I will not be able to get what I wanted because the contiguous block is not corresponding to the view of the row.
Is this intended behavior? I guess the only way is to transpose it first and then get the col instead? Will it be inefficient?
Edit: Transpose will not work, it also returns pointer to the same array, which is in same order.
A broader question. Working with Eigen, I often needed to convert back and forth from matrix to tensor, I did this via TensorMap and Map. However, when I work with slice of data, say convert a row of matrix, to a tensor type, what is the best way of achieving this? Using the above Map method would not work, so I guess I need to do some copying?