so I'm really confused about the recommended way to pass sparse Matrices from R to c++. I was under the impression that sp_mat was the correct argument type to do it as in the code below
testCode = '
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::export]]
void testFun(arma::sp_mat F){
Rcpp::Rcout << "F has " << F.n_rows << " rows" << std::endl;
}'
Rcpp::sourceCpp(code = testCode)
n = 70000
M = Matrix::sparseMatrix(i=c(n), j=c(n), x=c(1))
testFun(M)
However, running this code generates the following error:
error: SpMat::init(): requested size is too large
Error in testFun(M) : SpMat::init(): requested size is too large
Calls: testFun -> .Call
Execution halted
I saw the example in https://gallery.rcpp.org/articles/armadillo-sparse-matrix/ but I'm not sure if it is saying that every time we pass a sparse Matrix to c++ we should use the function provided there? Thanks for a clarification!