13 #include <gtest/gtest.h>
15 #include "../../include/ecl/statistics/covariance_ellipsoid.hpp"
23 using ecl::linear_algebra::Matrix2d;
24 using ecl::linear_algebra::Vector2d;
25 using ecl::linear_algebra::Matrix3d;
26 using ecl::linear_algebra::Vector3d;
32 TEST(CovarianceTests,ellipsoid2D) {
34 M << 3.0, 1.0, 1.0, 5.0;
39 const Vector2d& lengths = ellipse.lengths();
40 double eigen_value_0 = lengths[0]*lengths[0];
41 double angle = ellipse.rotation();
42 const Vector2d& intercepts = ellipse.intercepts();
43 const Matrix2d& axes = ellipse.axes();
45 EXPECT_GT(2.328,lengths[0]); EXPECT_LT(2.326,lengths[0]);
46 EXPECT_GT(5.415,eigen_value_0); EXPECT_LT(5.413,eigen_value_0);
47 EXPECT_GT(1.179,angle); EXPECT_LT(1.177,angle);
48 EXPECT_GT(1.674,intercepts[0]); EXPECT_LT(1.672,intercepts[0]);
49 EXPECT_GT(0.3828,axes(0,0)); EXPECT_LT(0.3826,axes(0,0));
69 TEST(CovarianceTests,ellipsoid3D) {
74 P << sigmaX*sigmaX, 0, 0, 0, sigmaY*sigmaY, 0, 0, 0, sigmaT*sigmaT;
77 const Vector3d& lengths = ellipse.lengths();
78 double eigen_value_0 = lengths[0]*lengths[0];
79 const Matrix3d& axes = ellipse.axes();
80 std::cout << axes << std::endl;
81 EXPECT_GT(0.101,lengths[0]); EXPECT_LT(0.099,lengths[0]);
82 EXPECT_GT(0.011,eigen_value_0); EXPECT_LT(0.009,eigen_value_0);
83 EXPECT_GT(1.001,axes(0,0)); EXPECT_LT(0.999,axes(0,0));
113 int main(
int argc,
char **argv) {
115 testing::InitGoogleTest(&argc,argv);
116 return RUN_ALL_TESTS();