diff --git a/modules/core/include/opencv2/core/base.hpp b/modules/core/include/opencv2/core/base.hpp index e4efe0fb9b64feaaca590c2b21bedd54157eb1db..742e0d2ca8ada53822652b1fcafdddd4cb0f072a 100644 --- a/modules/core/include/opencv2/core/base.hpp +++ b/modules/core/include/opencv2/core/base.hpp @@ -492,17 +492,9 @@ _AccTp normL2Sqr(const _Tp* a, const _Tp* b, int n) return s; } -inline float normL2Sqr(const float* a, const float* b, int n) +static inline float normL2Sqr(const float* a, const float* b, int n) { - if( n >= 8 ) - return hal::normL2Sqr_(a, b, n); - float s = 0; - for( int i = 0; i < n; i++ ) - { - float v = a[i] - b[i]; - s += v*v; - } - return s; + return normL2Sqr(a, b, n); } template static inline @@ -527,20 +519,12 @@ _AccTp normL1(const _Tp* a, const _Tp* b, int n) inline float normL1(const float* a, const float* b, int n) { - if( n >= 8 ) - return hal::normL1_(a, b, n); - float s = 0; - for( int i = 0; i < n; i++ ) - { - float v = a[i] - b[i]; - s += std::abs(v); - } - return s; + return normL1(a, b, n); } inline int normL1(const uchar* a, const uchar* b, int n) { - return hal::normL1_(a, b, n); + return normL1(a, b, n); } template static inline @@ -573,6 +557,15 @@ CV_EXPORTS_W float cubeRoot(float val); */ CV_EXPORTS_W float fastAtan2(float y, float x); +/** proxy for hal::LU */ +CV_EXPORTS int LU(float* A, size_t astep, int m, float* b, size_t bstep, int n); +/** proxy for hal::LU */ +CV_EXPORTS int LU(double* A, size_t astep, int m, double* b, size_t bstep, int n); +/** proxy for hal::Cholesky */ +CV_EXPORTS bool Cholesky(float* A, size_t astep, int m, float* b, size_t bstep, int n); +/** proxy for hal::Cholesky */ +CV_EXPORTS bool Cholesky(double* A, size_t astep, int m, double* b, size_t bstep, int n); + ////////////////// forward declarations for important OpenCV types ////////////////// //! @cond IGNORED diff --git a/modules/core/include/opencv2/core/matx.hpp b/modules/core/include/opencv2/core/matx.hpp index e9023243e836491df04ce42335cc2d6b3e1e0cdd..6cc5d06251318494f9706ccf3a3ca75985ee0718 100644 --- a/modules/core/include/opencv2/core/matx.hpp +++ b/modules/core/include/opencv2/core/matx.hpp @@ -427,7 +427,7 @@ template struct Matx_DetOp double operator ()(const Matx<_Tp, m, m>& a) const { Matx<_Tp, m, m> temp = a; - double p = hal::LU(temp.val, m*sizeof(_Tp), m, 0, 0, 0); + double p = LU(temp.val, m*sizeof(_Tp), m, 0, 0, 0); if( p == 0 ) return p; for( int i = 0; i < m; i++ ) diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 2c42e1f3a3977f2049b58865cd102bfeebc3cf0f..bced1a755912ab498c79fe4cc55312b87af954f6 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -72,9 +72,9 @@ template struct Matx_FastInvOp b(i, i) = (_Tp)1; if( method == DECOMP_CHOLESKY ) - return hal::Cholesky(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m); + return Cholesky(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m); - return hal::LU(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m) != 0; + return LU(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m) != 0; } }; diff --git a/modules/core/src/lapack.cpp b/modules/core/src/lapack.cpp index e246a7c4000e436fd1fafaebe93c7922ffb843ae..b3e1b52941b8b97b56336f5f40c3e7d9a4501461 100644 --- a/modules/core/src/lapack.cpp +++ b/modules/core/src/lapack.cpp @@ -50,6 +50,26 @@ namespace cv { +int LU(float* A, size_t astep, int m, float* b, size_t bstep, int n) +{ + return hal::LU(A, astep, m, b, bstep, n); +} + +int LU(double* A, size_t astep, int m, double* b, size_t bstep, int n) +{ + return hal::LU(A, astep, m, b, bstep, n); +} + +bool Cholesky(float* A, size_t astep, int m, float* b, size_t bstep, int n) +{ + return hal::Cholesky(A, astep, m, b, bstep, n); +} + +bool Cholesky(double* A, size_t astep, int m, double* b, size_t bstep, int n) +{ + return hal::Cholesky(A, astep, m, b, bstep, n); +} + template static inline _Tp hypot(_Tp a, _Tp b) { a = std::abs(a); diff --git a/modules/hal/src/mathfuncs.cpp b/modules/hal/src/mathfuncs.cpp index 7d0199f00c4f2610a4cc844bd0998a45c2b74df7..66a03e1a582957ce38b1fe15e69fe85b482ae36a 100644 --- a/modules/hal/src/mathfuncs.cpp +++ b/modules/hal/src/mathfuncs.cpp @@ -42,6 +42,8 @@ #include "precomp.hpp" +#undef HAVE_IPP + namespace cv { namespace hal { ///////////////////////////////////// ATAN2 //////////////////////////////////// @@ -160,6 +162,19 @@ void fastAtan2(const float *Y, const float *X, float *angle, int len, bool angle void magnitude(const float* x, const float* y, float* mag, int len) { +#if defined HAVE_IPP + CV_IPP_CHECK() + { + IppStatus status = ippsMagnitude_32f(x, y, mag, len); + if (status >= 0) + { + CV_IMPL_ADD(CV_IMPL_IPP); + return; + } + setIppErrorStatus(); + } +#endif + int i = 0; #if CV_SIMD128 @@ -183,6 +198,19 @@ void magnitude(const float* x, const float* y, float* mag, int len) void magnitude(const double* x, const double* y, double* mag, int len) { +#if defined(HAVE_IPP) + CV_IPP_CHECK() + { + IppStatus status = ippsMagnitude_64f(x, y, mag, len); + if (status >= 0) + { + CV_IMPL_ADD(CV_IMPL_IPP); + return; + } + setIppErrorStatus(); + } +#endif + int i = 0; #if CV_SIMD128_64F @@ -207,6 +235,18 @@ void magnitude(const double* x, const double* y, double* mag, int len) void invSqrt(const float* src, float* dst, int len) { +#if defined(HAVE_IPP) + CV_IPP_CHECK() + { + if (ippsInvSqrt_32f_A21(src, dst, len) >= 0) + { + CV_IMPL_ADD(CV_IMPL_IPP); + return; + } + setIppErrorStatus(); + } +#endif + int i = 0; #if CV_SIMD128 @@ -241,6 +281,18 @@ void invSqrt(const double* src, double* dst, int len) void sqrt(const float* src, float* dst, int len) { +#if defined(HAVE_IPP) + CV_IPP_CHECK() + { + if (ippsSqrt_32f_A21(src, dst, len) >= 0) + { + CV_IMPL_ADD(CV_IMPL_IPP); + return; + } + setIppErrorStatus(); + } +#endif + int i = 0; #if CV_SIMD128 @@ -260,6 +312,18 @@ void sqrt(const float* src, float* dst, int len) void sqrt(const double* src, double* dst, int len) { +#if defined(HAVE_IPP) + CV_IPP_CHECK() + { + if (ippsSqrt_64f_A50(src, dst, len) >= 0) + { + CV_IMPL_ADD(CV_IMPL_IPP); + return; + } + setIppErrorStatus(); + } +#endif + int i = 0; #if CV_SIMD128_64F