+ indices[((i-1)*nb_series_per_task+1):upper_bound]
+ })
+ cl = parallel::makeCluster(ncores_tasks)
+ #1000*K1 (or K2) indices (or NOTHING--> series on file)
+ indices = unlist( parallel::parLapply(cl, indices_tasks, function(inds) {
+ clusteringTask(inds, getSeries, getSeries, getCoefs, K1, K2*(WER=="mix"),
+ nb_series_per_chunk,ncores_clust,to_file=TRUE, ftype)
+ }) )
+ parallel::stopCluster(cl)
+
+ getSeriesForSynchrones = getSeries
+ synchrones_file = paste(bin_dir,"synchrones",sep="")
+ if (WER=="mix")
+ {
+ indices = seq_len(ntasks*K2)
+ #Now series must be retrieved from synchrones_file
+ getSeries = function(inds) getDataInFile(inds, synchrones_file)
+ #Coefs must be re-computed
+ unlink(coefs_file)
+ index = 1
+ repeat
+ {
+ series = getSeries((index-1)+seq_len(nb_series_per_chunk))
+ if (is.null(series))
+ break
+ coeffs_chunk = curvesToCoeffs(series, wf)
+ serialize(coeffs_chunk, coefs_file, ftype, nb_series_per_chunk)
+ index = index + nb_series_per_chunk
+ }