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_Geodesics.hpp 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. ///-------------------------------------------------------------------------------------------------
  2. ///
  3. /// \file test_Geodesics.hpp
  4. /// \brief Tests for Geodesic 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/Geodesic.hpp>
  16. //---------------------------------------------------------------------------------------------------
  17. class Tests_Geodesic : 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_Geodesic, Euclidian)
  26. {
  27. const std::vector<Eigen::MatrixXd> ref = InitGeodesics::Euclidian::Reference();
  28. const Eigen::MatrixXd mean = InitMeans::Euclidian::Reference();
  29. for (size_t i = 0; i < m_dataSet.size(); ++i)
  30. {
  31. Eigen::MatrixXd calc;
  32. Geodesic(mean, m_dataSet[i], calc, Geometry::EMetric::Euclidian, 0.5);
  33. EXPECT_TRUE(isAlmostEqual(ref[i], calc)) << ErrorMsg("Geodesic Euclidian Sample [" + std::to_string(i) + "]", ref[i], calc);
  34. }
  35. }
  36. //---------------------------------------------------------------------------------------------------
  37. //---------------------------------------------------------------------------------------------------
  38. TEST_F(Tests_Geodesic, LogEuclidian)
  39. {
  40. const std::vector<Eigen::MatrixXd> ref = InitGeodesics::LogEuclidian::Reference();
  41. const Eigen::MatrixXd mean = InitMeans::LogEuclidian::Reference();
  42. for (size_t i = 0; i < m_dataSet.size(); ++i)
  43. {
  44. Eigen::MatrixXd calc;
  45. Geodesic(mean, m_dataSet[i], calc, Geometry::EMetric::LogEuclidian, 0.5);
  46. EXPECT_TRUE(isAlmostEqual(ref[i], calc)) << ErrorMsg("Geodesic LogEuclidian Sample [" + std::to_string(i) + "]", ref[i], calc);
  47. }
  48. }
  49. //---------------------------------------------------------------------------------------------------
  50. //---------------------------------------------------------------------------------------------------
  51. TEST_F(Tests_Geodesic, Riemann)
  52. {
  53. const std::vector<Eigen::MatrixXd> ref = InitGeodesics::Riemann::Reference();
  54. const Eigen::MatrixXd mean = InitMeans::Riemann::Reference();
  55. for (size_t i = 0; i < m_dataSet.size(); ++i)
  56. {
  57. Eigen::MatrixXd calc;
  58. Geodesic(mean, m_dataSet[i], calc, Geometry::EMetric::Riemann, 0.5);
  59. EXPECT_TRUE(isAlmostEqual(ref[i], calc)) << ErrorMsg("Geodesic Riemann Sample [" + std::to_string(i) + "]", ref[i], calc);
  60. }
  61. }
  62. //---------------------------------------------------------------------------------------------------
  63. //---------------------------------------------------------------------------------------------------
  64. TEST_F(Tests_Geodesic, Identity)
  65. {
  66. const Eigen::MatrixXd mean = InitMeans::Riemann::Reference(), ref = Eigen::MatrixXd::Identity(NB_CHAN, NB_CHAN);
  67. for (size_t i = 0; i < m_dataSet.size(); ++i)
  68. {
  69. Eigen::MatrixXd calc;
  70. Geodesic(mean, m_dataSet[i], calc, Geometry::EMetric::Identity, 0.5);
  71. EXPECT_TRUE(isAlmostEqual(ref, calc)) << ErrorMsg("Geodesic Identity Sample [" + std::to_string(i) + "]", ref, calc);
  72. }
  73. }
  74. //---------------------------------------------------------------------------------------------------