我试图用非常最近RcppArmadillo包的能力(版本0.3.910.0有R 3.0.1和evrerything最新)从矩阵封装(类"dgCMatrix")的稀疏矩阵转换到sp_mat类型犰狳.我正在使用文件"RcppArmadilloExtensions/spmat.h"中的"as"和"wrap"函数.不幸的是,在尝试创建共享库时遇到编译错误.so在调用"R CMD INSTALL myRpackage"时.
这是重现错误的最小示例:
文件"arma_sp_sum.h"
#ifndef _anRpackage_ARMA_SP_SUM_H
#define _anRpackage_ARMA_SP_SUM_H
#include <RcppArmadilloExtensions/spmat.h>
RcppExport SEXP arma_sp_prod(SEXP SPMAT) ;
#endif
Run Code Online (Sandbox Code Playgroud)
文件"arma_sp_sum.cpp"
#include "arma_sp_sum.h"
using namespace Rcpp ;
SEXP arma_sp_sum(SEXP SPMAT){
arma::sp_mat m1 = Rcpp::as<arma::sp_mat>(SPMAT) ;
arma::sp_mat m2 = Rcpp::as<arma::sp_mat>(SPMAT) ;
arma::sp_mat res = m1 + m2;
return Rcpp::wrap(res) ;
}
Run Code Online (Sandbox Code Playgroud)
文件"arma_sp_prod.h"
#ifndef _anRpackage_ARMA_SP_PROD_H
#define _anRpackage_ARMA_SP_PROD_H
#include <RcppArmadilloExtensions/spmat.h>
RcppExport SEXP arma_sp_prod(SEXP SPMAT) ;
#endif
Run Code Online (Sandbox Code Playgroud)
档案"arma_sp_prod.cpp"
#include "arma_sp_prod.h"
using namespace Rcpp ;
SEXP arma_sp_prod(SEXP SPMAT){
arma::sp_mat m1 = Rcpp::as<arma::sp_mat>(SPMAT) ;
arma::sp_mat …Run Code Online (Sandbox Code Playgroud)