Search code examples
matrixrcpparmadillor-bigmemory

Save several large Matrix from Rcpp to R environment


I used Rcpp (especially Rcpp Armadillo) to perform a method that returns as result several large matrix, for example of size 10000*10000. How can I save these matrix to use them in R environment. Assume that my code in Rcpp looks like:

  list Output (20000);
  for( int i(0);i<20000;++1 ){
    ...
    ...
    // Suppose that the previous lines allow me to compute a matrix Gi  of size 10000*10000
    Output(i)=Gi;
  }
  return Output;

The way I programmed is very costly and need enough memory. But I need the 20000 matrix to compute an estimator in R environment. How can I save the matrix ? I do not know if bigmatrix package can help me.

Best,


Solution

  • I finally found a solution. I noticed that I will need 15TB to save the matrices. That is impossible. What I finally did is to save only some features of the matrices, as eigenvalues for example and others. See more details here