From 8704c4e5cdb5a72de5dc22b55147718dfb50defa Mon Sep 17 00:00:00 2001 From: "Jared P. Lander" Date: Mon, 31 Aug 2020 17:15:11 -0400 Subject: [PATCH] Using R_xlen_t instead of int so that larger matrices can be computed on using vector mode. The standard int has a size limit of 2^31 which can be exceeded when computing distance on a matrix with more than 46,342 rows. I didn't change the matrix return formats because that shouldn't be as much of a problem since you can have a 32-bit integer in either direction. --- src/dists_vec.cpp | 59 ++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/dists_vec.cpp b/src/dists_vec.cpp index 1791ec4..9a2b3c9 100644 --- a/src/dists_vec.cpp +++ b/src/dists_vec.cpp @@ -11,14 +11,14 @@ using namespace arma; using std::string; -static int proper_size(int nrw,int ncl){ +static R_xlen_t proper_size(R_xlen_t nrw,R_xlen_t ncl){ return ncl*(ncl-1)*0.5; } //[[Rcpp::export]] -IntegerVector index_dist_vec(const int nrw,const int ncl){ +IntegerVector index_dist_vec(const R_xlen_t nrw,const R_xlen_t ncl){ IntegerVector f(proper_size(nrw,ncl)); - int i,j,k=0; + R_xlen_t i,j,k=0; for(i=0;i(x.begin(),x.end(),log_xx.begin()); for(i=0;i(x.begin(),x.end(),log_xx.begin()); for(i=0;i