From: Vadim Pisarevsky Date: Wed, 20 Mar 2013 07:58:19 +0000 (+0400) Subject: added test for bug #1448 and hopefully fixes the bug #2898 X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~1314^2~1410^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9a86245242f2dddc6149bd954bae1f0e307fa8d7;p=platform%2Fupstream%2Fopencv.git added test for bug #1448 and hopefully fixes the bug #2898 --- diff --git a/modules/core/src/lapack.cpp b/modules/core/src/lapack.cpp index 62206fa..b20273f 100644 --- a/modules/core/src/lapack.cpp +++ b/modules/core/src/lapack.cpp @@ -531,12 +531,12 @@ template<> inline int VBLAS::givensx(double* a, double* b, int n, double #endif template void -JacobiSVDImpl_(_Tp* At, size_t astep, _Tp* _W, _Tp* Vt, size_t vstep, int m, int n, int n1, double minval) +JacobiSVDImpl_(_Tp* At, size_t astep, _Tp* _W, _Tp* Vt, size_t vstep, + int m, int n, int n1, double minval, _Tp eps) { VBLAS<_Tp> vblas; AutoBuffer Wbuf(n); double* W = Wbuf; - _Tp eps = DBL_EPSILON*10; int i, j, k, iter, max_iter = std::max(m, 30); _Tp c, s; double sd; @@ -729,12 +729,12 @@ JacobiSVDImpl_(_Tp* At, size_t astep, _Tp* _W, _Tp* Vt, size_t vstep, int m, int static void JacobiSVD(float* At, size_t astep, float* W, float* Vt, size_t vstep, int m, int n, int n1=-1) { - JacobiSVDImpl_(At, astep, W, Vt, vstep, m, n, !Vt ? 0 : n1 < 0 ? n : n1, FLT_MIN); + JacobiSVDImpl_(At, astep, W, Vt, vstep, m, n, !Vt ? 0 : n1 < 0 ? n : n1, FLT_MIN, FLT_EPSILON*2); } static void JacobiSVD(double* At, size_t astep, double* W, double* Vt, size_t vstep, int m, int n, int n1=-1) { - JacobiSVDImpl_(At, astep, W, Vt, vstep, m, n, !Vt ? 0 : n1 < 0 ? n : n1, DBL_MIN); + JacobiSVDImpl_(At, astep, W, Vt, vstep, m, n, !Vt ? 0 : n1 < 0 ? n : n1, DBL_MIN, DBL_EPSILON*10); } /* y[0:m,0:n] += diag(a[0:1,0:m]) * x[0:m,0:n] */ diff --git a/modules/core/test/test_math.cpp b/modules/core/test/test_math.cpp index 1203961..c3d88bd 100644 --- a/modules/core/test/test_math.cpp +++ b/modules/core/test/test_math.cpp @@ -2487,6 +2487,35 @@ TEST(Core_SVBkSb, accuracy) { Core_SVBkSbTest test; test.safe_run(); } TEST(Core_Trace, accuracy) { Core_TraceTest test; test.safe_run(); } TEST(Core_SolvePoly, accuracy) { Core_SolvePolyTest test; test.safe_run(); } + +TEST(Core_SVD, flt) +{ + float a[] = { + 1.23377746e+011f, -7.05490125e+010f, -4.18380882e+010f, -11693456.f, + -39091328.f, 77492224.f, -7.05490125e+010f, 2.36211143e+011f, + -3.51093473e+010f, 70773408.f, -4.83386156e+005f, -129560368.f, + -4.18380882e+010f, -3.51093473e+010f, 9.25311222e+010f, -49052424.f, + 43922752.f, 12176842.f, -11693456.f, 70773408.f, -49052424.f, 8.40836094e+004f, + 5.17475293e+003f, -1.16122949e+004f, -39091328.f, -4.83386156e+005f, + 43922752.f, 5.17475293e+003f, 5.16047969e+004f, 5.68887842e+003f, 77492224.f, + -129560368.f, 12176842.f, -1.16122949e+004f, 5.68887842e+003f, + 1.28060578e+005f + }; + + float b[] = { + 283751232.f, 2.61604198e+009f, -745033216.f, 2.31125625e+005f, + -4.52429188e+005f, -1.37596525e+006f + }; + + Mat A(6, 6, CV_32F, a); + Mat B(6, 1, CV_32F, b); + Mat X, B1; + solve(A, B, X, DECOMP_SVD); + B1 = A*X; + EXPECT_LE(norm(B1, B, NORM_L2 + NORM_RELATIVE), FLT_EPSILON*10); +} + + // TODO: eigenvv, invsqrt, cbrt, fastarctan, (round, floor, ceil(?)),