Pairwise distances from a single column or vector

In Distances, a collection of points (even if the points are one dimensional) is given as a matrix, not a vector. So either create it as a matrix or use the adjoint operator ' to give it an extra dimension.

julia> pairwise(Euclidean(), cc'; dims=2)
4×4 Array{Float64,2}:
 0.0  2.0  4.0  6.0
 2.0  0.0  2.0  4.0
 4.0  2.0  0.0  2.0
 6.0  4.0  2.0  0.0
1 Like