问题描述
我有一个Eigen::Matrix<double,M,N> matrix;
,我有一个只需要3x3切片并对其进行修改的函数
void ModifyBlock(Eigen::Matrix<double,3,3> & block){
// A stupid example
block += Eigen::Matrix<double,3>::Identity();
}
无法传递原始矩阵的一部分,因为以下代码无法编译:
int main(int argc,char *argv[]){
const int M = 10;
const int N = 20;
Eigen::Matrix<double,N> matrix;
// Initialize matrix
ModifyBlock(matrix(vector<int>{1,7},vector<int>{0,2,4});
return 0;
}
cannot bind non-const lvalue reference of type ‘Eigen::Matrix<double,3>&’ to an rvalue of type ‘Eigen::Matrix<double,3>
我想知道是否有办法做到这一点。
在documentation中,我找不到提到切片必须是常量引用的情况。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)