The family's dist() function works like proxy::dist() but supports parallelization and
optimized symmetric calculations. If you like, you can use the function more or less directly,
but provide a control argument when creating the family (see examples). However, bear in mind
the following considerations.
The second argument is called centroids (inconsistent with proxy::dist()).
If control$distmat is not NULL, the function will try to subset it.
If control$symmetric is TRUE, centroids is NULL, and there is no argument
pairwise that is TRUE, only half the distance matrix will be computed.
The function always returns a crossdist matrix.
Note that all distances implemented as part of dtwclust have custom proxy loops that use
multi-threading independently of foreach, so see their respective documentation to see
what optimizations apply to each one.
For distances not included in dtwclust, the computation can be in parallel using
multi-processing with foreach::foreach(). If you install and load or attach (see
base::library() or base::loadNamespace()) the bigmemory package, the function will
take advantage of said package when all of the following conditions are met, reducing the
overhead of data copying across processes:
control$symmetric is TRUE
centroids is NULL
pairwise is FALSE or NULL
The distance was registered in proxy::pr_DB with loop = TRUE
A parallel backend with more than 1 worker has been registered with foreach
This symmetric, parallel case makes chunks for parallel workers, but they are not perfectly
balanced, so some workers might finish before the others.