Reduce the number of cache misses with in minimum pair search
Profiling revealed a number of cache misses due to the indices in the search for a minimum value being separated by large distances. To reduce this issue the current minimum distance is stored in local variable along with the index.