X-Git-Url: https://git.auder.net/?p=epclust.git;a=blobdiff_plain;f=epclust%2Fsrc%2FcomputeMedoidsIndices.cpp;h=895031a90f71376f10be93d4efc16a3a1faab94e;hp=f24758411ce9d30b0670c3fb5f26811b41cb5708;hb=d9bb53c5e1392018bf67f92140edb10137f3423c;hpb=9f05a4a0b703deffd7bdb9cd99b0aaa2246a5c83 diff --git a/epclust/src/computeMedoidsIndices.cpp b/epclust/src/computeMedoidsIndices.cpp index f247584..895031a 100644 --- a/epclust/src/computeMedoidsIndices.cpp +++ b/epclust/src/computeMedoidsIndices.cpp @@ -10,33 +10,39 @@ using namespace Rcpp; //' computeMedoidsIndices //' -//' Compute medoids indices +//' For each column of the 'series' matrix input, search for the closest medoid +//' (euclidian distance) and store its index //' -//' @param pMedoids External pointer -//' @param ref_series reference series +//' @param pMedoids External pointer (a big.matrix 'address' slot in R) +//' @param series (reference) series, a matrix of size Lxn //' -//' @return A map serie number -> medoid index +//' @return An integer vector of the closest medoids indices, for each (column) serie // [[Rcpp::export]] -IntegerVector computeMedoidsIndices(SEXP pMedoids, NumericMatrix ref_series) +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 = ref_series.ncol(), + + int nb_series = series.ncol(), K = pMed->ncol(), L = pMed->nrow(); IntegerVector mi(nb_series); - for (int i=0; i