| 194 | } |
| 195 | |
| 196 | static void Magnitude_32f(const float* x, const float* y, float* mag, int len) |
| 197 | { |
| 198 | int i = 0; |
| 199 | |
| 200 | #if CV_SSE |
| 201 | if( USE_SSE2 ) |
| 202 | { |
| 203 | for( ; i <= len - 8; i += 8 ) |
| 204 | { |
| 205 | __m128 x0 = _mm_loadu_ps(x + i), x1 = _mm_loadu_ps(x + i + 4); |
| 206 | __m128 y0 = _mm_loadu_ps(y + i), y1 = _mm_loadu_ps(y + i + 4); |
| 207 | x0 = _mm_add_ps(_mm_mul_ps(x0, x0), _mm_mul_ps(y0, y0)); |
| 208 | x1 = _mm_add_ps(_mm_mul_ps(x1, x1), _mm_mul_ps(y1, y1)); |
| 209 | x0 = _mm_sqrt_ps(x0); x1 = _mm_sqrt_ps(x1); |
| 210 | _mm_storeu_ps(mag + i, x0); _mm_storeu_ps(mag + i + 4, x1); |
| 211 | } |
| 212 | } |
| 213 | #endif |
| 214 | |
| 215 | for( ; i < len; i++ ) |
| 216 | { |
| 217 | float x0 = x[i], y0 = y[i]; |
| 218 | mag[i] = std::sqrt(x0*x0 + y0*y0); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | static void Magnitude_64f(const double* x, const double* y, double* mag, int len) |
| 223 | { |
no test coverage detected