新的 Mapped SparseMatrix 类型 RcppEigen 编译错误

New Mapped SparseMatrix type RcppEigen compilation errors

自 RcppEigen 版本 3.3.3.0 以来,MappedSpareMatrixTdeprecated。出于某种原因,在使用这种新类型编译函数时出现错误。

例如(基于this question);

编辑: 根据 coatless 的建议 - 仍然出现相同的错误。

#include <RcppEigen.h>

typedef Eigen::Map<Eigen::SparseMatrix<double> > mappedSparseMatrix;
typedef Eigen::Map<Eigen::VectorXd> mappedVector;

// [[Rcpp::depends(RcppEigen)]]
// [[Rcpp::export]]
Eigen::VectorXd cgSparse(const mappedSparseMatrix A, const mappedVector b) {
  Eigen::ConjugateGradient< mappedSparseMatrix, Eigen::Lower > cg(A);
  return cg.solve(b);
}

我尝试了不同的东西,甚至从 Rcppeigen 复制了类型 unitTests;

typedef Eigen::Map<Eigen::SparseMatrix<double, Eigen::ColMajor> > MapMat;

在这两种情况下,我都会收到以下错误;

SessionInfo() 此处:

R version 3.4.0 (2017-04-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RcppEigen_0.3.3.3.0  RevoUtilsMath_10.0.0

loaded via a namespace (and not attached):
[1] compiler_3.4.0   Matrix_1.2-9     RevoUtils_10.0.4 tools_3.4.0      Rcpp_0.12.10     grid_3.4.0      
[7] lattice_0.20-35 

进行了上述更改 - 如何映射我的稀疏矩阵?比如上面的函数中sparseCG? (注意:我是 C++ 新手)

文件 RcppEigenForward.hRcppEigenWrap.h 中有一条注释,从 Eigen 3.3.0 开始,上游不推荐使用 mappedSparseMatrix

如果我把它改成

typedef Eigen::SparseMatrix< double > mappedSparseMatrix;

即使用完全稀疏矩阵(而不是映射到它)然后编译。