Skip to content

Commit 5b04eda

Browse files
committed
add heuristic for parallel
1 parent fd04d7b commit 5b04eda

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/matrices.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ use [`recurrenceplot`](@ref) to turn the result of these functions into a plotta
171171
recurrence quantifications", in: Webber, C.L. & N. Marwan (eds.), *Recurrence
172172
Quantification Analysis. Theory and Best Practices*, Springer, pp. 3-43 (2015).
173173
"""
174-
function RecurrenceMatrix(x, ε; metric = DEFAULT_METRIC, parallel::Bool = false, kwargs...)
174+
function RecurrenceMatrix(x, ε; metric = DEFAULT_METRIC,
175+
parallel::Bool = length(x) > 500 && Threads.nthreads() > 1, kwargs...)
175176
m = getmetric(metric)
176177
s = resolve_scale(x, m, ε; kwargs...)
177178
m = recurrence_matrix(x, m, s, Val(parallel))
@@ -191,7 +192,8 @@ then the cell `(i, j)` of the matrix will have a `true` value.
191192
See [`RecurrenceMatrix`](@ref) for details, references and keywords.
192193
See also: [`JointRecurrenceMatrix`](@ref).
193194
"""
194-
function CrossRecurrenceMatrix(x, y, ε; metric = DEFAULT_METRIC, parallel::Bool = false, kwargs...)
195+
function CrossRecurrenceMatrix(x, y, ε; metric = DEFAULT_METRIC,
196+
parallel::Bool = length(x) > 500 && Threads.nthreads() > 1, kwargs...)
195197
m = getmetric(metric)
196198
s = resolve_scale(x, y, m, ε; kwargs...)
197199
m = recurrence_matrix(x, y, m, s, Val(parallel))
@@ -302,7 +304,7 @@ end
302304
"""
303305
recurrence_matrix(x, y, metric::Metric, ε::Real, parallel::Val)
304306
305-
Returns a sparse matrix which encodes recurrence points.
307+
Return a sparse matrix which encodes recurrence points.
306308
307309
Note that `parallel` may be either `Val(true)` or `Val(false)`.
308310
"""

0 commit comments

Comments
 (0)