Why do you do this: On 12 December 2016 at 14:35, Ron Wehrens wrote: | double RcppDist(NumericMatrix sData1, | NumericMatrix sData2, | int numObjects, | int numVars, | int numCodes) { | int i, j, k; | double dist, tmp, mindist, | *data = REAL(sData1), | *codes = REAL(sData2); | mindist = 10000.0; | | for (i = 0; i < numObjects; i++) { | for (j = 0; j < numCodes; j++) { | dist = 0; | for (k = 0; k < numVars; k++) { | if (!ISNAN(data[i * numVars + k])) { | tmp = data[i * numVars + k] - codes[j * numVars + k];
Why not drop data and codes and use sData1(i,k) - sData2(j,k) ? That still doesn't explain the slowdowns though. Could you prepare a _complete_ yet minimal example along with mock data? Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org _______________________________________________ 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