void Core_EigenTest_64::run(int) { check_full(CV_64FC1); }
Core_EigenTest::Core_EigenTest()
-: eps_val_32(1e-3f), eps_vec_32(12e-3f),
- eps_val_64(1e-4f), eps_vec_64(1e-3f), ntests(100) {}
+: eps_val_32(1e-3f), eps_vec_32(1e-3f),
+ eps_val_64(1e-4f), eps_vec_64(1e-4f), ntests(100) {}
Core_EigenTest::~Core_EigenTest() {}
bool Core_EigenTest::check_pair_count(const cv::Mat& src, const cv::Mat& evalues, int low_index, int high_index)
for (int i = 0; i < COUNT_NORM_TYPES; ++i)
{
- double diff = cvtest::norm(UUt, E, NORM_TYPE[i]);
+ double diff = cvtest::norm(UUt, E, NORM_TYPE[i] | cv::NORM_RELATIVE);
if (diff > eps_vec)
{
std::cout << endl; std::cout << "Checking orthogonality of matrix " << U << ": ";
cv::Mat eigen_vectors_t; cv::transpose(eigen_vectors, eigen_vectors_t);
- cv::Mat src_evec(src.rows, src.cols, type);
- src_evec = src*eigen_vectors_t;
+ // Check:
+ // src * eigenvector = eigenval * eigenvector
+ cv::Mat lhs(src.rows, src.cols, type);
+ cv::Mat rhs(src.rows, src.cols, type);
- cv::Mat eval_evec(src.rows, src.cols, type);
+ lhs = src*eigen_vectors_t;
- switch (type)
+ for (int i = 0; i < src.cols; ++i)
{
- case CV_32FC1:
- {
- for (int i = 0; i < src.cols; ++i)
- {
- cv::Mat tmp = eigen_values.at<float>(i, 0) * eigen_vectors_t.col(i);
- for (int j = 0; j < src.rows; ++j) eval_evec.at<float>(j, i) = tmp.at<float>(j, 0);
- }
-
- break;
- }
-
- case CV_64FC1:
+ double eigenval = 0;
+ switch (type)
{
- for (int i = 0; i < src.cols; ++i)
- {
- cv::Mat tmp = eigen_values.at<double>(i, 0) * eigen_vectors_t.col(i);
- for (int j = 0; j < src.rows; ++j) eval_evec.at<double>(j, i) = tmp.at<double>(j, 0);
- }
-
- break;
+ case CV_32FC1: eigenval = eigen_values.at<float>(i, 0); break;
+ case CV_64FC1: eigenval = eigen_values.at<double>(i, 0); break;
}
-
- default:;
+ cv::Mat rhs_v = eigenval * eigen_vectors_t.col(i);
+ rhs_v.copyTo(rhs.col(i));
}
- cv::Mat disparity = src_evec - eval_evec;
-
for (int i = 0; i < COUNT_NORM_TYPES; ++i)
{
- double diff = cvtest::norm(disparity, NORM_TYPE[i]);
+ double diff = cvtest::norm(lhs, rhs, NORM_TYPE[i] | cv::NORM_RELATIVE);
if (diff > eps_vec)
{
std::cout << endl; std::cout << "Checking accuracy of eigen vectors computing for matrix " << src << ": ";
for (int i = 0; i < COUNT_NORM_TYPES; ++i)
{
- double diff = cvtest::norm(eigen_values_1, eigen_values_2, NORM_TYPE[i]);
+ double diff = cvtest::norm(eigen_values_1, eigen_values_2, NORM_TYPE[i] | cv::NORM_RELATIVE);
if (diff > eps_val)
{
std::cout << endl; std::cout << "Checking accuracy of eigen values computing for matrix " << src << ": ";