X-Git-Url: https://git.auder.net/?a=blobdiff_plain;ds=sidebyside;f=epclust%2FR%2FcomputeWerDists.R;h=568a8262adbf2989c6472f5b271a7b299a0262c3;hb=3fb6e823601002c44ffbf913e83c8d24cfa1e819;hp=061c3609a54bc10928c5cd36702ad326f34b0eb6;hpb=282342bafdc9ff65c5df98c6e2304d63b33b9fb2;p=epclust.git diff --git a/epclust/R/computeWerDists.R b/epclust/R/computeWerDists.R index 061c360..568a826 100644 --- a/epclust/R/computeWerDists.R +++ b/epclust/R/computeWerDists.R @@ -1,7 +1,7 @@ #' computeWerDists #' -#' Compute the WER distances between the synchrones curves (in columns), which are -#' returned (e.g.) by \code{computeSynchrones()} +#' Compute the WER distances between the series at specified indices, which are +#' obtaind by \code{getSeries(indices)} #' #' @param indices Range of series indices to cluster #' @inheritParams claws @@ -11,7 +11,7 @@ #' #' @export computeWerDists <- function(indices, getSeries, nb_series_per_chunk, smooth_lvl, nvoice, - nbytes, endian, ncores_clust=1, verbose=FALSE, parll=TRUE) + nbytes, endian, ncores_clust=3, verbose=FALSE, parll=TRUE) { n <- length(indices) L <- length(getSeries(1)) #TODO: not very neat way to get L @@ -29,8 +29,7 @@ computeWerDists <- function(indices, getSeries, nb_series_per_chunk, smooth_lvl, { if (parll) { - require("bigmemory", quietly=TRUE) - require("Rwave", quietly=TRUE) + # parallel workers start with an empty environment require("epclust", quietly=TRUE) } @@ -61,7 +60,6 @@ computeWerDists <- function(indices, getSeries, nb_series_per_chunk, smooth_lvl, if (parll) { # parallel workers start with an empty environment - require("bigmemory", quietly=TRUE) require("epclust", quietly=TRUE) Xwer_dist <- bigmemory::attach.big.matrix(Xwer_dist_desc) } @@ -78,7 +76,7 @@ computeWerDists <- function(indices, getSeries, nb_series_per_chunk, smooth_lvl, cwt_j <- getCWT(j, L) # Compute the ratio of integrals formula 5.6 for WER^2 - # in https://arxiv.org/abs/1101.4744v2 §5.3 + # in https://arxiv.org/abs/1101.4744v2 paragraph 5.3 num <- filterMA(Mod(cwt_i * Conj(cwt_j)), smooth_lvl) WY <- filterMA(Mod(cwt_j * Conj(cwt_j)), smooth_lvl) wer2 <- sum(colSums(num)^2) / sum(colSums(WX) * colSums(WY)) @@ -92,7 +90,11 @@ computeWerDists <- function(indices, getSeries, nb_series_per_chunk, smooth_lvl, if (parll) { # outfile=="" to see stderr/stdout on terminal - cl <- parallel::makeCluster(ncores_clust, outfile="") + cl <- + if (verbose) + parallel::makeCluster(ncores_clust, outfile="") + else + parallel::makeCluster(ncores_clust) Xwer_dist_desc <- bigmemory::describe(Xwer_dist) parallel::clusterExport(cl, varlist=c("parll","nb_cwt_per_chunk","n","L", "Xwer_dist_desc","noctave","nvoice","getCWT"), envir=environment())