commit x64 compilation from lulu cause the other branch dont seems to compile properly at home
This commit is contained in:
@ -42,8 +42,8 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_OPERATIONS_HPP__
|
||||
#define __OPENCV_CORE_OPERATIONS_HPP__
|
||||
#ifndef OPENCV_CORE_OPERATIONS_HPP
|
||||
#define OPENCV_CORE_OPERATIONS_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error operations.hpp header must be compiled as C++
|
||||
@ -61,29 +61,44 @@ namespace cv
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template<typename _Tp, int m> struct Matx_FastInvOp
|
||||
template<typename _Tp, int m, int n> struct Matx_FastInvOp
|
||||
{
|
||||
bool operator()(const Matx<_Tp, m, m>& a, Matx<_Tp, m, m>& b, int method) const
|
||||
bool operator()(const Matx<_Tp, m, n>& a, Matx<_Tp, n, m>& b, int method) const
|
||||
{
|
||||
Matx<_Tp, m, m> temp = a;
|
||||
|
||||
// assume that b is all 0's on input => make it a unity matrix
|
||||
for( int i = 0; i < m; i++ )
|
||||
b(i, i) = (_Tp)1;
|
||||
|
||||
if( method == DECOMP_CHOLESKY )
|
||||
return Cholesky(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m);
|
||||
|
||||
return LU(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m) != 0;
|
||||
return invert(a, b, method) != 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename _Tp> struct Matx_FastInvOp<_Tp, 2>
|
||||
template<typename _Tp, int m> struct Matx_FastInvOp<_Tp, m, m>
|
||||
{
|
||||
bool operator()(const Matx<_Tp, 2, 2>& a, Matx<_Tp, 2, 2>& b, int) const
|
||||
bool operator()(const Matx<_Tp, m, m>& a, Matx<_Tp, m, m>& b, int method) const
|
||||
{
|
||||
_Tp d = determinant(a);
|
||||
if( d == 0 )
|
||||
if (method == DECOMP_LU || method == DECOMP_CHOLESKY)
|
||||
{
|
||||
Matx<_Tp, m, m> temp = a;
|
||||
|
||||
// assume that b is all 0's on input => make it a unity matrix
|
||||
for (int i = 0; i < m; i++)
|
||||
b(i, i) = (_Tp)1;
|
||||
|
||||
if (method == DECOMP_CHOLESKY)
|
||||
return Cholesky(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m);
|
||||
|
||||
return LU(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m) != 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return invert(a, b, method) != 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<typename _Tp> struct Matx_FastInvOp<_Tp, 2, 2>
|
||||
{
|
||||
bool operator()(const Matx<_Tp, 2, 2>& a, Matx<_Tp, 2, 2>& b, int /*method*/) const
|
||||
{
|
||||
_Tp d = (_Tp)determinant(a);
|
||||
if (d == 0)
|
||||
return false;
|
||||
d = 1/d;
|
||||
b(1,1) = a(0,0)*d;
|
||||
@ -94,12 +109,12 @@ template<typename _Tp> struct Matx_FastInvOp<_Tp, 2>
|
||||
}
|
||||
};
|
||||
|
||||
template<typename _Tp> struct Matx_FastInvOp<_Tp, 3>
|
||||
template<typename _Tp> struct Matx_FastInvOp<_Tp, 3, 3>
|
||||
{
|
||||
bool operator()(const Matx<_Tp, 3, 3>& a, Matx<_Tp, 3, 3>& b, int) const
|
||||
bool operator()(const Matx<_Tp, 3, 3>& a, Matx<_Tp, 3, 3>& b, int /*method*/) const
|
||||
{
|
||||
_Tp d = (_Tp)determinant(a);
|
||||
if( d == 0 )
|
||||
if (d == 0)
|
||||
return false;
|
||||
d = 1/d;
|
||||
b(0,0) = (a(1,1) * a(2,2) - a(1,2) * a(2,1)) * d;
|
||||
@ -118,27 +133,43 @@ template<typename _Tp> struct Matx_FastInvOp<_Tp, 3>
|
||||
};
|
||||
|
||||
|
||||
template<typename _Tp, int m, int n> struct Matx_FastSolveOp
|
||||
template<typename _Tp, int m, int l, int n> struct Matx_FastSolveOp
|
||||
{
|
||||
bool operator()(const Matx<_Tp, m, l>& a, const Matx<_Tp, m, n>& b,
|
||||
Matx<_Tp, l, n>& x, int method) const
|
||||
{
|
||||
return cv::solve(a, b, x, method);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename _Tp, int m, int n> struct Matx_FastSolveOp<_Tp, m, m, n>
|
||||
{
|
||||
bool operator()(const Matx<_Tp, m, m>& a, const Matx<_Tp, m, n>& b,
|
||||
Matx<_Tp, m, n>& x, int method) const
|
||||
{
|
||||
Matx<_Tp, m, m> temp = a;
|
||||
x = b;
|
||||
if( method == DECOMP_CHOLESKY )
|
||||
return Cholesky(temp.val, m*sizeof(_Tp), m, x.val, n*sizeof(_Tp), n);
|
||||
if (method == DECOMP_LU || method == DECOMP_CHOLESKY)
|
||||
{
|
||||
Matx<_Tp, m, m> temp = a;
|
||||
x = b;
|
||||
if( method == DECOMP_CHOLESKY )
|
||||
return Cholesky(temp.val, m*sizeof(_Tp), m, x.val, n*sizeof(_Tp), n);
|
||||
|
||||
return LU(temp.val, m*sizeof(_Tp), m, x.val, n*sizeof(_Tp), n) != 0;
|
||||
return LU(temp.val, m*sizeof(_Tp), m, x.val, n*sizeof(_Tp), n) != 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return cv::solve(a, b, x, method);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<typename _Tp> struct Matx_FastSolveOp<_Tp, 2, 1>
|
||||
template<typename _Tp> struct Matx_FastSolveOp<_Tp, 2, 2, 1>
|
||||
{
|
||||
bool operator()(const Matx<_Tp, 2, 2>& a, const Matx<_Tp, 2, 1>& b,
|
||||
Matx<_Tp, 2, 1>& x, int) const
|
||||
{
|
||||
_Tp d = determinant(a);
|
||||
if( d == 0 )
|
||||
_Tp d = (_Tp)determinant(a);
|
||||
if (d == 0)
|
||||
return false;
|
||||
d = 1/d;
|
||||
x(0) = (b(0)*a(1,1) - b(1)*a(0,1))*d;
|
||||
@ -147,13 +178,13 @@ template<typename _Tp> struct Matx_FastSolveOp<_Tp, 2, 1>
|
||||
}
|
||||
};
|
||||
|
||||
template<typename _Tp> struct Matx_FastSolveOp<_Tp, 3, 1>
|
||||
template<typename _Tp> struct Matx_FastSolveOp<_Tp, 3, 3, 1>
|
||||
{
|
||||
bool operator()(const Matx<_Tp, 3, 3>& a, const Matx<_Tp, 3, 1>& b,
|
||||
Matx<_Tp, 3, 1>& x, int) const
|
||||
{
|
||||
_Tp d = (_Tp)determinant(a);
|
||||
if( d == 0 )
|
||||
if (d == 0)
|
||||
return false;
|
||||
d = 1/d;
|
||||
x(0) = d*(b(0)*(a(1,1)*a(2,2) - a(1,2)*a(2,1)) -
|
||||
@ -193,15 +224,8 @@ template<typename _Tp, int m, int n> inline
|
||||
Matx<_Tp, n, m> Matx<_Tp, m, n>::inv(int method, bool *p_is_ok /*= NULL*/) const
|
||||
{
|
||||
Matx<_Tp, n, m> b;
|
||||
bool ok;
|
||||
if( method == DECOMP_LU || method == DECOMP_CHOLESKY )
|
||||
ok = cv::internal::Matx_FastInvOp<_Tp, m>()(*this, b, method);
|
||||
else
|
||||
{
|
||||
Mat A(*this, false), B(b, false);
|
||||
ok = (invert(A, B, method) != 0);
|
||||
}
|
||||
if( NULL != p_is_ok ) { *p_is_ok = ok; }
|
||||
bool ok = cv::internal::Matx_FastInvOp<_Tp, m, n>()(*this, b, method);
|
||||
if (p_is_ok) *p_is_ok = ok;
|
||||
return ok ? b : Matx<_Tp, n, m>::zeros();
|
||||
}
|
||||
|
||||
@ -209,15 +233,7 @@ template<typename _Tp, int m, int n> template<int l> inline
|
||||
Matx<_Tp, n, l> Matx<_Tp, m, n>::solve(const Matx<_Tp, m, l>& rhs, int method) const
|
||||
{
|
||||
Matx<_Tp, n, l> x;
|
||||
bool ok;
|
||||
if( method == DECOMP_LU || method == DECOMP_CHOLESKY )
|
||||
ok = cv::internal::Matx_FastSolveOp<_Tp, m, l>()(*this, rhs, x, method);
|
||||
else
|
||||
{
|
||||
Mat A(*this, false), B(rhs, false), X(x, false);
|
||||
ok = cv::solve(A, B, X, method);
|
||||
}
|
||||
|
||||
bool ok = cv::internal::Matx_FastSolveOp<_Tp, m, n, l>()(*this, rhs, x, method);
|
||||
return ok ? x : Matx<_Tp, n, l>::zeros();
|
||||
}
|
||||
|
||||
@ -349,6 +365,8 @@ inline int RNG::uniform(int a, int b) { return a == b ? a : (int)(next(
|
||||
inline float RNG::uniform(float a, float b) { return ((float)*this)*(b - a) + a; }
|
||||
inline double RNG::uniform(double a, double b) { return ((double)*this)*(b - a) + a; }
|
||||
|
||||
inline bool RNG::operator ==(const RNG& other) const { return state == other.state; }
|
||||
|
||||
inline unsigned RNG::next()
|
||||
{
|
||||
state = (uint64)(unsigned)state* /*CV_RNG_COEFF*/ 4164903690U + (unsigned)(state >> 32);
|
||||
@ -363,6 +381,12 @@ template<typename _Tp> static inline _Tp randu()
|
||||
|
||||
///////////////////////////////// Formatted string generation /////////////////////////////////
|
||||
|
||||
/** @brief Returns a text string formatted using the printf-like expression.
|
||||
|
||||
The function acts like sprintf but forms and returns an STL string. It can be used to form an error
|
||||
message in the Exception constructor.
|
||||
@param fmt printf-compatible formatting specifiers.
|
||||
*/
|
||||
CV_EXPORTS String format( const char* fmt, ... );
|
||||
|
||||
///////////////////////////////// Formatted output of cv::Mat /////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user