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

后端 未结 1 1205
没有蜡笔的小新
没有蜡笔的小新 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<Matrix2d> A(W.data());          // using the first 4 elements
    Map<Matrix2d> B(W.tail(4).data());  // using the last 4 elements
    Map<MatrixXd> C(W.data()+6, 2,2);   // using the 6th to 10th elements
                                        // with sizes defined at runtime.
    
    0 讨论(0)
提交回复
热议问题