(Looking for the most idiomatic way to solve this problem. It’s inside several nested loops.)
I have a situation where I have two lists of 3-vectors. Often these two lists are identical except for displacement. (One set of points is merely a shifted copy of the other.) To check for identity, I just subtract them and then check to see that the component-wise difference is the same for all vectors. So the difference between two sets of vectors might be something like this (just a MWE, not realistic)
julia> t
4-element Vector{Vector{Float64}}:
[0.1, 0.2, 3.3]
[0.2, -0.2, 1.0]
[0.3, 0.25, -1.0]
[-0.1, -0.2, 0.3]
julia> s
4-element Vector{Vector{Float64}}:
[-0.1, 0.5, 4.6]
[0.0, 0.1, 2.3]
[0.1, 0.55, 0.3]
[-0.3, 0.1, 1.6]
julia> diffs=t-s
4-element Vector{Vector{Float64}}:
[0.2, -0.3, -1.2999999999999998]
[0.2, -0.30000000000000004, -1.2999999999999998]
[0.19999999999999998, -0.30000000000000004, -1.3]
[0.19999999999999998, -0.30000000000000004, -1.3]
So then I check to see that each difference vector matches the others by:
julia> all([diffs[1]≈i for i in diffs[2:end]])
Not sure if this is the best way to do this. Is there a more idiomatic way? It seems verbose with the list comprehension…
(I could perhaps store the points as columns in a matrix instead of as a vector of vectors…)