提交 0a3a2df4 编写于 作者: R Rostislav Vasilikhin

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

上级 b28d1343
......@@ -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;
}
......
......@@ -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};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册