#include // [[Rcpp::depends(BH, bigmemory)]] #include #include #include using namespace Rcpp; //' computeMedoidsIndices //' //' For each column of the 'series' matrix input, search for the closest medoid //' (euclidian distance) and store its index //' //' @param pMedoids External pointer (a big.matrix 'address' slot in R) //' @param series (reference) series, a matrix of size Lxn //' //' @return An integer vector of the closest medoids indices, for each (column) serie // [[Rcpp::export]] IntegerVector computeMedoidsIndices(SEXP pMedoids, NumericMatrix series) { // Turn SEXP external pointer into BigMatrix (description) object XPtr pMed(pMedoids); // medoids: access to the content of the BigMatrix object MatrixAccessor medoids = MatrixAccessor(*pMed); int nb_series = series.ncol(), K = pMed->ncol(), L = pMed->nrow(); IntegerVector mi(nb_series); for (int i=0; i