How to vectorize a distance calculation using SSE2
问题 A and B are vectors or length N, where N could be in the range 20 to 200 say. I want to calculate the square of the distance between these vectors, i.e. d^2 = ||A-B||^2. So far I have: float* a = ...; float* b = ...; float d2 = 0; for(int k = 0; k < N; ++k) { float d = a[k] - b[k]; d2 += d * d; } That seems to work fine, except that I have profiled my code and this is the bottleneck (more than 50% of time is spent just doing this). I am using Visual Studio 2012, on Win 7, with these