You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_Featurization.hpp 4.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ///-------------------------------------------------------------------------------------------------
  2. ///
  3. /// \file test_Featurization.hpp
  4. /// \brief Tests for Matrix Featurization Functions.
  5. /// \author Thibaut Monseigne (Inria).
  6. /// \version 1.0.
  7. /// \date 09/01/2019.
  8. /// \copyright <a href="https://choosealicense.com/licenses/agpl-3.0/">GNU Affero General Public License v3.0</a>.
  9. ///
  10. ///-------------------------------------------------------------------------------------------------
  11. #pragma once
  12. #include "gtest/gtest.h"
  13. #include "misc.hpp"
  14. #include "init.hpp"
  15. #include <geometry/Featurization.hpp>
  16. //---------------------------------------------------------------------------------------------------
  17. class Tests_Featurization : public testing::Test
  18. {
  19. protected:
  20. std::vector<Eigen::MatrixXd> m_dataSet;
  21. void SetUp() override { m_dataSet = Geometry::Vector2DTo1D(InitCovariance::LWF::Reference()); }
  22. };
  23. //---------------------------------------------------------------------------------------------------
  24. //---------------------------------------------------------------------------------------------------
  25. TEST_F(Tests_Featurization, TangentSpace)
  26. {
  27. const std::vector<Eigen::RowVectorXd> ref = InitFeaturization::TangentSpace::Reference();
  28. const Eigen::MatrixXd mean = InitMeans::Riemann::Reference();
  29. for (size_t i = 0; i < m_dataSet.size(); ++i)
  30. {
  31. Eigen::RowVectorXd calc;
  32. EXPECT_TRUE(Geometry::Featurization(m_dataSet[i], calc, true, mean)) << "Error During Processing";
  33. EXPECT_TRUE(isAlmostEqual(ref[i], calc)) << ErrorMsg("TangentSpace Sample [" + std::to_string(i) + "]", ref[i], calc);
  34. }
  35. }
  36. //---------------------------------------------------------------------------------------------------
  37. //---------------------------------------------------------------------------------------------------
  38. TEST_F(Tests_Featurization, UnTangentSpace)
  39. {
  40. const std::vector<Eigen::RowVectorXd> ref = InitFeaturization::TangentSpace::Reference();
  41. const Eigen::MatrixXd mean = InitMeans::Riemann::Reference();
  42. for (size_t i = 0; i < m_dataSet.size(); ++i)
  43. {
  44. Eigen::MatrixXd calc;
  45. EXPECT_TRUE(Geometry::UnFeaturization(ref[i], calc, true, mean)) << "Error During Processing";
  46. EXPECT_TRUE(isAlmostEqual(m_dataSet[i], calc)) << ErrorMsg("UnTangentSpace Sample [" + std::to_string(i) + "]", m_dataSet[i], calc);
  47. }
  48. }
  49. //---------------------------------------------------------------------------------------------------
  50. //---------------------------------------------------------------------------------------------------
  51. TEST_F(Tests_Featurization, Squeeze)
  52. {
  53. const std::vector<Eigen::RowVectorXd> ref = InitFeaturization::Squeeze::Reference();
  54. const std::vector<Eigen::RowVectorXd> refDiag = InitFeaturization::SqueezeDiag::Reference();
  55. const Eigen::MatrixXd mean = InitMeans::Riemann::Reference();
  56. for (size_t i = 0; i < m_dataSet.size(); ++i)
  57. {
  58. Eigen::RowVectorXd calc;
  59. EXPECT_TRUE(Geometry::Featurization(m_dataSet[i], calc, false, mean)) << "Error During Processing";
  60. EXPECT_TRUE(isAlmostEqual(ref[i], calc)) << ErrorMsg("Squeeze Sample [" + std::to_string(i) + "]", ref[i], calc);
  61. EXPECT_TRUE(Geometry::SqueezeUpperTriangle(m_dataSet[i], calc, false)) << "Error During Processing";
  62. EXPECT_TRUE(isAlmostEqual(refDiag[i], calc)) << ErrorMsg("Squeeze Sample [" + std::to_string(i) + "]", refDiag[i], calc);
  63. }
  64. }
  65. //---------------------------------------------------------------------------------------------------
  66. //---------------------------------------------------------------------------------------------------
  67. TEST_F(Tests_Featurization, UnSqueeze)
  68. {
  69. const std::vector<Eigen::RowVectorXd> ref = InitFeaturization::Squeeze::Reference();
  70. const std::vector<Eigen::RowVectorXd> refDiag = InitFeaturization::SqueezeDiag::Reference();
  71. const Eigen::MatrixXd mean = InitMeans::Riemann::Reference();
  72. for (size_t i = 0; i < m_dataSet.size(); ++i)
  73. {
  74. Eigen::MatrixXd calc;
  75. EXPECT_TRUE(Geometry::UnFeaturization(ref[i], calc, false, mean)) << "Error During Processing";
  76. EXPECT_TRUE(isAlmostEqual(m_dataSet[i], calc)) << ErrorMsg("UnSqueeze Sample [" + std::to_string(i) + "]", m_dataSet[i], calc);
  77. EXPECT_TRUE(Geometry::UnSqueezeUpperTriangle(refDiag[i], calc, false)) << "Error During Processing";
  78. EXPECT_TRUE(isAlmostEqual(m_dataSet[i], calc)) << ErrorMsg("UnSqueeze Sample [" + std::to_string(i) + "]", m_dataSet[i], calc);
  79. }
  80. }
  81. //---------------------------------------------------------------------------------------------------