From 25bbcba0ea268f211a4a01afe9dfdafe6f564c30 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Mon, 25 Feb 2013 22:02:24 +0400 Subject: [PATCH 1/3] fixed Core_MulSpectrums failure --- modules/core/test/test_dxt.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/core/test/test_dxt.cpp b/modules/core/test/test_dxt.cpp index 0fc0edbdf..16025fa8f 100644 --- a/modules/core/test/test_dxt.cpp +++ b/modules/core/test/test_dxt.cpp @@ -419,7 +419,9 @@ static void fixCCS( Mat& mat, int cols, int flags ) } } - +#if defined _MSC_VER && _MSC_VER >= 1700 +#pragma optimize("", off) +#endif static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags ) { dst.create(src1.rows, src1.cols, src1.type()); @@ -439,8 +441,8 @@ static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags ) if( !(flags & CV_DXT_MUL_CONJ) ) for( j = 0; j < cols; j += 2 ) { - double re = (double)a[j]*b[j] - (double)a[j+1]*b[j+1]; - double im = (double)a[j+1]*b[j] + (double)a[j]*b[j+1]; + double re = (double)a[j]*(double)b[j] - (double)a[j+1]*(double)b[j+1]; + double im = (double)a[j+1]*(double)b[j] + (double)a[j]*(double)b[j+1]; c[j] = (float)re; c[j+1] = (float)im; @@ -448,8 +450,8 @@ static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags ) else for( j = 0; j < cols; j += 2 ) { - double re = (double)a[j]*b[j] + (double)a[j+1]*b[j+1]; - double im = (double)a[j+1]*b[j] - (double)a[j]*b[j+1]; + double re = (double)a[j]*(double)b[j] + (double)a[j+1]*(double)b[j+1]; + double im = (double)a[j+1]*(double)b[j] - (double)a[j]*(double)b[j+1]; c[j] = (float)re; c[j+1] = (float)im; @@ -482,6 +484,9 @@ static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags ) } } } +#if defined _MSC_VER && _MSC_VER >= 1700 +#pragma optimize("", on) +#endif } From 087537463d5c5915241acb71202b23ddba8ea785 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Mon, 25 Feb 2013 22:46:30 +0400 Subject: [PATCH 2/3] attempt to make the ultimate fix for the failure in Core_Invert.small --- modules/core/src/lapack.cpp | 39 ++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/modules/core/src/lapack.cpp b/modules/core/src/lapack.cpp index 019d3616c..8bb40e0fc 100644 --- a/modules/core/src/lapack.cpp +++ b/modules/core/src/lapack.cpp @@ -1095,28 +1095,31 @@ double cv::invert( InputArray _src, OutputArray _dst, int method ) if( type == CV_32FC1 ) { double d = det3(Sf); - if( d != 0. ) - { - double t[12]; - result = true; - d = 1./d; - t[0] = (((double)Sf(1,1) * Sf(2,2) - (double)Sf(1,2) * Sf(2,1)) * d); - t[1] = (((double)Sf(0,2) * Sf(2,1) - (double)Sf(0,1) * Sf(2,2)) * d); - t[2] = (((double)Sf(0,1) * Sf(1,2) - (double)Sf(0,2) * Sf(1,1)) * d); + if( fabs(d) < 1e-4 || fabs(d) > 1e4 ) + result = invert(src, dst, DECOMP_SVD) > 0; + else + { + float t[12]; + float df = (float)(1./d); + result = true; - t[3] = (((double)Sf(1,2) * Sf(2,0) - (double)Sf(1,0) * Sf(2,2)) * d); - t[4] = (((double)Sf(0,0) * Sf(2,2) - (double)Sf(0,2) * Sf(2,0)) * d); - t[5] = (((double)Sf(0,2) * Sf(1,0) - (double)Sf(0,0) * Sf(1,2)) * d); + t[0] = (Sf(1,1) * Sf(2,2) - Sf(1,2) * Sf(2,1)) * df; + t[1] = (Sf(0,2) * Sf(2,1) - Sf(0,1) * Sf(2,2)) * df; + t[2] = (Sf(0,1) * Sf(1,2) - Sf(0,2) * Sf(1,1)) * df; - t[6] = (((double)Sf(1,0) * Sf(2,1) - (double)Sf(1,1) * Sf(2,0)) * d); - t[7] = (((double)Sf(0,1) * Sf(2,0) - (double)Sf(0,0) * Sf(2,1)) * d); - t[8] = (((double)Sf(0,0) * Sf(1,1) - (double)Sf(0,1) * Sf(1,0)) * d); + t[3] = (Sf(1,2) * Sf(2,0) - Sf(1,0) * Sf(2,2)) * df; + t[4] = (Sf(0,0) * Sf(2,2) - Sf(0,2) * Sf(2,0)) * df; + t[5] = (Sf(0,2) * Sf(1,0) - Sf(0,0) * Sf(1,2)) * df; - Df(0,0) = (float)t[0]; Df(0,1) = (float)t[1]; Df(0,2) = (float)t[2]; - Df(1,0) = (float)t[3]; Df(1,1) = (float)t[4]; Df(1,2) = (float)t[5]; - Df(2,0) = (float)t[6]; Df(2,1) = (float)t[7]; Df(2,2) = (float)t[8]; - } + t[6] = (Sf(1,0) * Sf(2,1) - Sf(1,1) * Sf(2,0)) * df; + t[7] = (Sf(0,1) * Sf(2,0) - Sf(0,0) * Sf(2,1)) * df; + t[8] = (Sf(0,0) * Sf(1,1) - Sf(0,1) * Sf(1,0)) * df; + + Df(0,0) = t[0]; Df(0,1) = t[1]; Df(0,2) = t[2]; + Df(1,0) = t[3]; Df(1,1) = t[4]; Df(1,2) = t[5]; + Df(2,0) = t[6]; Df(2,1) = t[7]; Df(2,2) = t[8]; + } } else { From 416432a8e54bd46b777fa574f6f144eb37e47214 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Mon, 25 Feb 2013 23:10:38 +0400 Subject: [PATCH 3/3] replaced tabs with spaces --- modules/core/src/lapack.cpp | 40 ++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/core/src/lapack.cpp b/modules/core/src/lapack.cpp index 8bb40e0fc..ce1995c68 100644 --- a/modules/core/src/lapack.cpp +++ b/modules/core/src/lapack.cpp @@ -1096,30 +1096,30 @@ double cv::invert( InputArray _src, OutputArray _dst, int method ) { double d = det3(Sf); - if( fabs(d) < 1e-4 || fabs(d) > 1e4 ) - result = invert(src, dst, DECOMP_SVD) > 0; - else - { - float t[12]; - float df = (float)(1./d); - result = true; + if( fabs(d) < 1e-4 || fabs(d) > 1e4 ) + result = invert(src, dst, DECOMP_SVD) > 0; + else + { + float t[12]; + float df = (float)(1./d); + result = true; - t[0] = (Sf(1,1) * Sf(2,2) - Sf(1,2) * Sf(2,1)) * df; - t[1] = (Sf(0,2) * Sf(2,1) - Sf(0,1) * Sf(2,2)) * df; - t[2] = (Sf(0,1) * Sf(1,2) - Sf(0,2) * Sf(1,1)) * df; + t[0] = (Sf(1,1) * Sf(2,2) - Sf(1,2) * Sf(2,1)) * df; + t[1] = (Sf(0,2) * Sf(2,1) - Sf(0,1) * Sf(2,2)) * df; + t[2] = (Sf(0,1) * Sf(1,2) - Sf(0,2) * Sf(1,1)) * df; - t[3] = (Sf(1,2) * Sf(2,0) - Sf(1,0) * Sf(2,2)) * df; - t[4] = (Sf(0,0) * Sf(2,2) - Sf(0,2) * Sf(2,0)) * df; - t[5] = (Sf(0,2) * Sf(1,0) - Sf(0,0) * Sf(1,2)) * df; + t[3] = (Sf(1,2) * Sf(2,0) - Sf(1,0) * Sf(2,2)) * df; + t[4] = (Sf(0,0) * Sf(2,2) - Sf(0,2) * Sf(2,0)) * df; + t[5] = (Sf(0,2) * Sf(1,0) - Sf(0,0) * Sf(1,2)) * df; - t[6] = (Sf(1,0) * Sf(2,1) - Sf(1,1) * Sf(2,0)) * df; - t[7] = (Sf(0,1) * Sf(2,0) - Sf(0,0) * Sf(2,1)) * df; - t[8] = (Sf(0,0) * Sf(1,1) - Sf(0,1) * Sf(1,0)) * df; + t[6] = (Sf(1,0) * Sf(2,1) - Sf(1,1) * Sf(2,0)) * df; + t[7] = (Sf(0,1) * Sf(2,0) - Sf(0,0) * Sf(2,1)) * df; + t[8] = (Sf(0,0) * Sf(1,1) - Sf(0,1) * Sf(1,0)) * df; - Df(0,0) = t[0]; Df(0,1) = t[1]; Df(0,2) = t[2]; - Df(1,0) = t[3]; Df(1,1) = t[4]; Df(1,2) = t[5]; - Df(2,0) = t[6]; Df(2,1) = t[7]; Df(2,2) = t[8]; - } + Df(0,0) = t[0]; Df(0,1) = t[1]; Df(0,2) = t[2]; + Df(1,0) = t[3]; Df(1,1) = t[4]; Df(1,2) = t[5]; + Df(2,0) = t[6]; Df(2,1) = t[7]; Df(2,2) = t[8]; + } } else {