使用EIGEN从同一个SparseMatrix中删除行或列

时间:2017-02-16 14:14:27

标签: eigen eigen3

我有点麻烦,可能很简单。

我正在寻找一种删除SAME SparseMatrix上的行或列的方法。

我在RowMajor“模式”中使用SparseMatrix,删除我正在做的行:

void removeRow(unsigned int rowID, SparseMatrix<short int, RowMajor> & toDealWith)
{
    for (unsigned int i = rowID; i < toDealWith.rows() - 1; i++){
        toDealWith.row(i) = toDealWith.row(i + 1);
    }
    toDealWith.conservativeResize(toDealWith.rows() - 1, toDealWith.cols());
}

无辜地,我期待这个工作:

void removeCol(unsigned int colID, SparseMatrix<short int, RowMajor> & toDealWith)
{
    for (unsigned int i = colID; i < toDealWith.cols() - 1; i++){
        toDealWith.col(i) = toDealWith.col(i + 1);
    }
    toDealWith.conservativeResize(toDealWith.rows(), toDealWith.cols() - 1);
}

但这不是VS2013的编译,原因是:

error C2666: 'Eigen::BlockImpl<XprType,-1,1,false,Eigen::internal::traits<Derived>::StorageKind>::operator =' : 2 overloads have similar conversions    ...

经过一番调查后,我发现了this,我想这就是问题所在。

我尝试了不同的方法来实现这一目标,但它们都没有奏效。

我的问题是,由于linked post是1岁,我是否错过了一些更新,使得同一个SparseMatrix上的行删除和列删除操作可用?

提前致谢。

0 个答案:

没有答案
相关问题