Parallel Distances

TanayLabUtilities.ParallelDistances.parallel_pairwise Function
parallel_pairwise(
    distance, X[, Y];
    dims::Integer,
    policy::Symbol = :greedy,
    progress::Maybe{Progress} = nothing
)::AbstractMatrix

A parallel version of pairwise . This will use parallel_loop_wo_rng over the columns of Y , with the specified policy and progress . If policy is :serial , then the standard version of pairwise is called and progress is ignored.

using Test
using Distances
using Random

Random.seed!(123456)

m1 = rand(10, 20)
m2 = rand(10, 30)

d = pairwise(Euclidean(), m1; dims = 2)
@test maximum(abs.(d .- parallel_pairwise(Euclidean(), m1; dims = 2, policy = :serial))) < 1e-6
@test maximum(abs.(d .- parallel_pairwise(Euclidean(), m1; dims = 2, policy = :greedy))) < 1e-6
@test maximum(abs.(d .- parallel_pairwise(Euclidean(), m1; dims = 2, policy = :dynamic))) < 1e-6
@test maximum(abs.(d .- parallel_pairwise(Euclidean(), m1; dims = 2, policy = :static))) < 1e-6

d = pairwise(Euclidean(), m1, m2; dims = 2)
@test maximum(abs.(d .- parallel_pairwise(Euclidean(), m1, m2; dims = 2, policy = :serial))) < 1e-6
@test maximum(abs.(d .- parallel_pairwise(Euclidean(), m1, m2; dims = 2, policy = :greedy))) < 1e-6
@test maximum(abs.(d .- parallel_pairwise(Euclidean(), m1, m2; dims = 2, policy = :dynamic))) < 1e-6
@test maximum(abs.(d .- parallel_pairwise(Euclidean(), m1, m2; dims = 2, policy = :static))) < 1e-6

println("OK")

# output

OK

TanayLabUtilities.ParallelDistances.parallel_colwise Function
parallel_colwise(
    distance, X, Y;
    policy::Symbol = :greedy,
    progress::Maybe{Progress} = nothing,
)::AbstractVector

A parallel version of colwise . This will use parallel_loop_wo_rng over the columns of X and Y , using the specified policy and progress . If policy is :serial , then the standard version of pairwise is called and progress is ignored.

```jldoctest using Test using Distances using Random

Random.seed!(123456)

m1 = rand(10, 20) m2 = rand(10, 20)

d = colwise(Euclidean(), m1, m2) @test maximum(abs.(d .- parallel colwise(Euclidean(), m1, m2; policy = :serial))) < 1e-6 @test maximum(abs.(d .- parallel colwise(Euclidean(), m1, m2; policy = :greedy))) < 1e-6 @test maximum(abs.(d .- parallel colwise(Euclidean(), m1, m2; policy = :dynamic))) < 1e-6 @test maximum(abs.(d .- parallel colwise(Euclidean(), m1, m2; policy = :static))) < 1e-6

println("OK")

output

OK

Index