Get matrix views/blocks from a Eigen::VectorXd without copying (shared memory)

后端 未结 1 1193
没有蜡笔的小新
没有蜡笔的小新 2021-01-03 10:06

Does anyone know a good way how i can extract blocks from an Eigen::VectorXf that can be interpreted as a specific Eigen::MatrixXf without copying data? (the vector should c

1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-03 10:07

    If you want to reinterpret a subvector as a matrix then yes, you have to use Map:

    Map A(W.data());          // using the first 4 elements
    Map B(W.tail(4).data());  // using the last 4 elements
    Map C(W.data()+6, 2,2);   // using the 6th to 10th elements
                                        // with sizes defined at runtime.
    

    0 讨论(0)
提交回复
热议问题