[opencv] 55/71: fixed U non-orthogonality in SVD (http://code.opencv.org/issues/3801)

Nobuhiro Iwamatsu iwamatsu at moszumanska.debian.org
Mon Oct 17 20:16:29 UTC 2016


This is an automated email from the git hooks/post-receive script.

iwamatsu pushed a commit to annotated tag 2.4.13.1
in repository opencv.

commit 0a3a2df4333bfbf6a43f96a3fa2415f17c7145b9
Author: Rostislav Vasilikhin <rostislav.vasilikhin at intel.com>
Date:   Sat Sep 3 21:58:19 2016 +0300

    fixed U non-orthogonality in SVD (http://code.opencv.org/issues/3801)
---
 modules/core/src/lapack.cpp    |  2 +-
 modules/core/test/test_mat.cpp | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/modules/core/src/lapack.cpp b/modules/core/src/lapack.cpp
index 7ee84a6..0168610 100644
--- a/modules/core/src/lapack.cpp
+++ b/modules/core/src/lapack.cpp
@@ -688,7 +688,7 @@ JacobiSVDImpl_(_Tp* At, size_t astep, _Tp* _W, _Tp* Vt, size_t vstep,
                         At[i*astep + k] = t;
                         asum += std::abs(t);
                     }
-                    asum = asum ? 1/asum : 0;
+                    asum = asum > eps * 100 ? 1 / asum : 0;
                     for( k = 0; k < m; k++ )
                         At[i*astep + k] *= asum;
                 }
diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp
index f854abe..0aef147 100644
--- a/modules/core/test/test_mat.cpp
+++ b/modules/core/test/test_mat.cpp
@@ -919,6 +919,20 @@ TEST(Core_Mat, copyNx1ToVector)
     ASSERT_PRED_FORMAT2(cvtest::MatComparator(0, 0), ref_dst16, cv::Mat_<ushort>(dst16));
 }
 
+TEST(Core_SVD, orthogonality)
+{
+    for (int i = 0; i < 2; i++)
+    {
+        int type = i == 0 ? CV_32F : CV_64F;
+        Mat mat_D(2, 2, type);
+        mat_D.setTo(88.);
+        Mat mat_U, mat_W;
+        SVD::compute(mat_D, mat_W, mat_U, noArray(), SVD::FULL_UV);
+        mat_U *= mat_U.t();
+        ASSERT_LT(norm(mat_U, Mat::eye(2, 2, type), NORM_INF), 1e-5);
+    }
+}
+
 TEST(Core_Mat, multiDim)
 {
     int d[]={3,3,3};

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opencv.git



More information about the debian-science-commits mailing list