X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=epclust%2FR%2FcomputeWerDists.R;h=c6fa6338384cbbd7eb87e48753af5e90cbe4fa33;hb=c25d83a0ea7435d3c72ed74738be86ddcccd7e66;hp=8eb755c9920d86f2934d15eb90ec560ba4f596e7;hpb=dc86eb0c992e6e4ab119d48398d040c4cf3a75fd;p=epclust.git diff --git a/epclust/R/computeWerDists.R b/epclust/R/computeWerDists.R index 8eb755c..c6fa633 100644 --- a/epclust/R/computeWerDists.R +++ b/epclust/R/computeWerDists.R @@ -12,8 +12,8 @@ #' @return A distances matrix of size K x K where K == length(indices) #' #' @export -computeWerDists <- function(indices, getSeries, nb_series_per_chunk, smooth_lvl, nvoice, - nbytes, endian, ncores=3, verbose=FALSE, parll=TRUE) +computeWerDists <- function(indices, getSeries, nb_series_per_chunk, smooth_lvl=3, nvoice=4, + nbytes=4, endian=.Platform$endian, ncores=3, verbose=FALSE, parll=TRUE) { n <- length(indices) L <- length(getSeries(1)) #TODO: not very neat way to get L @@ -27,10 +27,13 @@ computeWerDists <- function(indices, getSeries, nb_series_per_chunk, smooth_lvl, cwt_file <- tempfile(pattern="epclust_cwt.bin_") # Compute the getSeries(indices) CWT, and store the results in the binary file - computeSaveCWT <- function(indices) + computeSaveCWT <- function(inds) { + if (verbose) + cat(" Compute save CWT on ",length(inds)," indices\n", sep="") + # Obtain CWT as big vectors of real part + imaginary part (concatenate) - ts_cwt <- sapply(indices, function(i) { + ts_cwt <- sapply(inds, function(i) { ts <- scale(ts(getSeries(i)), center=TRUE, scale=FALSE) ts_cwt <- Rwave::cwt(ts, noctave, nvoice, w0=2*pi, twoD=TRUE, plot=FALSE) c( as.double(Re(ts_cwt)),as.double(Im(ts_cwt)) ) @@ -60,7 +63,7 @@ computeWerDists <- function(indices, getSeries, nb_series_per_chunk, smooth_lvl, Xwer_dist <- bigmemory::attach.big.matrix(Xwer_dist_desc) } - if (verbose && !parll) + if (verbose) cat(paste(" Distances from ",i," to ",i+1,"...",n,"\n", sep="")) # Get CWT of column i, and run computations for columns j>i @@ -87,10 +90,10 @@ computeWerDists <- function(indices, getSeries, nb_series_per_chunk, smooth_lvl, cat(paste("--- Precompute and serialize synchrones CWT\n", sep="")) # Split indices by packets of length at most nb_cwt_per_chunk - indices_cwt <- .splitIndices(seq_len(n), nb_cwt_per_chunk) + indices_cwt <- .splitIndices(indices, nb_cwt_per_chunk) # NOTE: next loop could potentially be run in //. Indices would be permuted (by # serialization order), and synchronicity would be required because of concurrent - # writes. Probably not worth the effort - but possible to gain some bits of speed. + # writes. Probably not worth the effort - but possible. for (inds in indices_cwt) computeSaveCWT(inds)