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

This commit is contained in:
Rostislav Vasilikhin 2016-09-03 21:58:19 +03:00
parent b28d13430c
commit 0a3a2df433
2 changed files with 15 additions and 1 deletions

View File

@ -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;
}

View File

@ -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};