mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
fixed U non-orthogonality in SVD (http://code.opencv.org/issues/3801)
This commit is contained in:
parent
135fa85e8f
commit
7918267d02
@ -527,7 +527,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;
|
||||
}
|
||||
|
@ -1209,3 +1209,17 @@ 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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user