提交 526defab 编写于 作者: V Vadim Pisarevsky

Merge pull request #4048 from vpisarev:hal_fixes

...@@ -492,11 +492,9 @@ _AccTp normL2Sqr(const _Tp* a, const _Tp* b, int n) ...@@ -492,11 +492,9 @@ _AccTp normL2Sqr(const _Tp* a, const _Tp* b, int n)
return s; 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 ) float s = 0.f;
return hal::normL2Sqr_(a, b, n);
float s = 0;
for( int i = 0; i < n; i++ ) for( int i = 0; i < n; i++ )
{ {
float v = a[i] - b[i]; float v = a[i] - b[i];
...@@ -527,20 +525,22 @@ _AccTp normL1(const _Tp* a, const _Tp* b, int n) ...@@ -527,20 +525,22 @@ _AccTp normL1(const _Tp* a, const _Tp* b, int n)
inline float normL1(const float* a, const float* b, int n) inline float normL1(const float* a, const float* b, int n)
{ {
if( n >= 8 ) float s = 0.f;
return hal::normL1_(a, b, n);
float s = 0;
for( int i = 0; i < n; i++ ) for( int i = 0; i < n; i++ )
{ {
float v = a[i] - b[i]; s += std::abs(a[i] - b[i]);
s += std::abs(v);
} }
return s; return s;
} }
inline int normL1(const uchar* a, const uchar* b, int n) inline int normL1(const uchar* a, const uchar* b, int n)
{ {
return hal::normL1_(a, b, n); int s = 0;
for( int i = 0; i < n; i++ )
{
s += std::abs(a[i] - b[i]);
}
return s;
} }
template<typename _Tp, typename _AccTp> static inline template<typename _Tp, typename _AccTp> static inline
...@@ -573,6 +573,15 @@ CV_EXPORTS_W float cubeRoot(float val); ...@@ -573,6 +573,15 @@ CV_EXPORTS_W float cubeRoot(float val);
*/ */
CV_EXPORTS_W float fastAtan2(float y, float x); 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 ////////////////// ////////////////// forward declarations for important OpenCV types //////////////////
//! @cond IGNORED //! @cond IGNORED
......
...@@ -427,7 +427,7 @@ template<typename _Tp, int m> struct Matx_DetOp ...@@ -427,7 +427,7 @@ template<typename _Tp, int m> struct Matx_DetOp
double operator ()(const Matx<_Tp, m, m>& a) const double operator ()(const Matx<_Tp, m, m>& a) const
{ {
Matx<_Tp, m, m> temp = a; 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 ) if( p == 0 )
return p; return p;
for( int i = 0; i < m; i++ ) for( int i = 0; i < m; i++ )
......
...@@ -72,9 +72,9 @@ template<typename _Tp, int m> struct Matx_FastInvOp ...@@ -72,9 +72,9 @@ template<typename _Tp, int m> struct Matx_FastInvOp
b(i, i) = (_Tp)1; b(i, i) = (_Tp)1;
if( method == DECOMP_CHOLESKY ) 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;
} }
}; };
......
...@@ -50,6 +50,26 @@ ...@@ -50,6 +50,26 @@
namespace cv 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<typename _Tp> static inline _Tp hypot(_Tp a, _Tp b) template<typename _Tp> static inline _Tp hypot(_Tp a, _Tp b)
{ {
a = std::abs(a); a = std::abs(a);
......
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
#include "precomp.hpp" #include "precomp.hpp"
#undef HAVE_IPP
namespace cv { namespace hal { namespace cv { namespace hal {
///////////////////////////////////// ATAN2 //////////////////////////////////// ///////////////////////////////////// ATAN2 ////////////////////////////////////
...@@ -160,6 +162,19 @@ void fastAtan2(const float *Y, const float *X, float *angle, int len, bool angle ...@@ -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) 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; int i = 0;
#if CV_SIMD128 #if CV_SIMD128
...@@ -183,6 +198,19 @@ void magnitude(const float* x, const float* y, float* mag, int len) ...@@ -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) 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; int i = 0;
#if CV_SIMD128_64F #if CV_SIMD128_64F
...@@ -207,6 +235,18 @@ void magnitude(const double* x, const double* y, double* mag, int len) ...@@ -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) 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; int i = 0;
#if CV_SIMD128 #if CV_SIMD128
...@@ -241,6 +281,18 @@ void invSqrt(const double* src, double* dst, int len) ...@@ -241,6 +281,18 @@ void invSqrt(const double* src, double* dst, int len)
void sqrt(const float* src, float* 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; int i = 0;
#if CV_SIMD128 #if CV_SIMD128
...@@ -260,6 +312,18 @@ void sqrt(const float* src, float* dst, int len) ...@@ -260,6 +312,18 @@ void sqrt(const float* src, float* dst, int len)
void sqrt(const double* src, double* 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; int i = 0;
#if CV_SIMD128_64F #if CV_SIMD128_64F
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册