问题描述
我想通过Eigen中的块来更改类型为Eigen :: MatrixXd的矩阵A的内容,在编译时已知块的尺寸。我想利用编译时已知块的大小这一事实来获得最佳性能。最好的方法是什么?
在下面的最小示例中,我假设该块的大小为2x2,但是在我的实际实现中,我将使用已知大小为n1xn2的块。我还需要将矩阵的恒定块作为参数传递给另一个也具有已知大小的函数,我该如何使用Eigen来获得最佳性能呢?
#include <Eigen/Dense>
#include <iostream>
template <typename derived>
void change_block(Eigen::MatrixBase<derived> &M){
M=Eigen::MatrixXd::Identity(2,2);
}
int main()
{
Eigen::MatrixXd A(10,10);
std::cout << "Here is the initial matrix:" << std::endl << A << std::endl << std::endl;
auto A_block = A.block<2,2>(0,0);
change_block(A_block);
std::cout << "Here is the matrix after the change:" << std::endl << A << std::endl << std::endl;
}
我只使用了Eigen的基本功能。因此,将对允许深入理解建议方法的解释性意见表示赞赏。我将考虑尺寸在1x1到15x15之间的矩形块。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)