The bug is probably fixed by this commit:
https://github.com/RcppCore/Rcpp/commit/eb069bf5c20aaa4d38e0ca2897bf04e956cb8c4c

Le 31/10/2015 20:08, Alessandro Mammana a écrit :
Dear All,
When creating a large matrix with the follwing code:

#include <Rcpp.h>
// [[Rcpp::export]]
Rcpp::IntegerMatrix makeMat(int nrow, int ncol){
         Rcpp::IntegerMatrix mat(nrow, ncol);
         return mat;
}

I get the error:

Error in .Primitive(".Call")(<pointer: 0x7f86936d3ea0>, nrow, ncol) :
   negative length vectors are not allowed

Where nrow*ncol is a very large number (about 3*10^9). I understand
that such a number cannot be represented by an int type, but this does
not seem to be a problem when in R I do:

mat <- matrix(0, nrow=nrow, ncol=ncol)

Questions:
1. why is the behaviour different between R and Rcpp in the allocation
of a matrix?
2. In a 64 bits machine, what is actually the maximum allowed length
of a vector/matrix? does the length of a vector/matrix need to be
represented by an int?

Thanks a lot and best regards,
Alessandro

_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to