Python, Pairwise 'distance', need a fast way to do it
问题 For a side project in my PhD, I engaged in the task of modelling some system in Python. Efficiency wise, my program hits a bottleneck in the following problem, which I'll expose in a Minimal Working Example. I deal with a large number of segments encoded by their 3D beginning and endpoints, so each segment is represented by 6 scalars. I need to calculate a pairwise minimal intersegment distance. The analytical expression of the minimal distance between two segments is found in this source. To