指向eigen matrixxd的子行,表现得像vectorxd
pointer to sub-row of Eigen MatrixXd that behaves like a VectorXd
我有一个eigen matrixxd,需要一个指针,以便某些行的某些后续条目。我希望能够使用这个指针。我有这样的东西:
Eigen::MatrixXd* matrix = new MatrixXd(3, 3);
(*matrix) << 1, 2, 3,
4, 5, 6,
7, 8, 9;
Block<MatrixXd, 1, Dynamic, false, true> full_row = (*matrix).row(1);
// this gives me the full row. I am interested only in the row containing 5 6.
Block<MatrixXd> part_row = (*matrix).block(1, 1, 1, 2);
// this gives me the partial row that I want, but now i need two indices to
// access an element.
part_row(0, 1) = 3; // works
part_row(1) = 3; // gives compiler error
我希望能够直接访问部分行,而无需复制值。这确实很重要,因为它必须经常完成,而且我负担不起来回复制向量。(我相信我不能指望编译器优化复制,因为矩阵的大小通常未知)。任何帮助是极大的赞赏。欢呼!
您需要指定您的subbatrix是向量:
Block<MatrixXd,1,Dynamic> part_row(*matrix, 1, 1, 1, 2);
相关文章:
- Eigen如何在容器循环中干净地附加矩阵
- 当在带有Eigen的C++中使用GDB时,我如何才能看到更多的大矩阵
- 如何在没有数据拷贝的情况下从指针创建一个Eigen VectorXd对象
- Eigen::VectorXd 和 Boost::Odeint,不起作用
- EIGEN地图类:将C阵列映射到VectorXD指针以有效的方式
- 内存效率-EIGEN :: vectorxd在循环中
- 从一个内存的一个块创建许多eigen :: vectorxd
- 将“Eigen::VectorXd”的集合合并为一个大的“Eigen::VectorXd”
- Un-flatten Eigen::VectorXd to Eigen::MatrixXd
- 两个Eigen::VectorXd的有效(非标准)连接
- 如何使用另一个"Eigen::VectorXd"向量中的值初始化"Eigen::VectorXd",基于索引的"向量<int>"
- 为什么 std::less<Eigen::VectorXd> 编译失败?
- c++ lambda 函数,用于将 Eigen::VectorXd 转换为 Eigen::MatrixXd
- 从eigen :: vectorxd获取矩阵视图/块而无需复制(共享内存)
- 指向eigen matrixxd的子行,表现得像vectorxd
- 如何从双指针数组创建 Eigen::VectorXd
- 将Eigen::VectorXd类型转换为std::vector
- 在访问Eigen::VectorXd时使用0作为第二个索引是否安全?
- 将Rcpp::NumericVector转换为Eigen::VectorXd
- 如何在Eigen中定义VectorXd数组