MRPT  1.9.9
CMatrixFixed_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <gtest/gtest.h>
11 #include <mrpt/math/CMatrixFixed.h>
12 #include <Eigen/Dense>
13 
14 TEST(CMatrixFixed, CtorUninit)
15 {
17  // do nothing, just test that the ctor above compiles
18  (void)M(0, 0);
19 }
20 
21 TEST(CMatrixFixed, CtorAllZeros)
22 {
24  for (int i = 0; i < 2; i++)
25  for (int j = 0; j < 2; j++) EXPECT_EQ(M(i, j), .0);
26 }
27 
28 TEST(CMatrixFixed, Identity)
29 {
31  M.setIdentity();
32  for (int i = 0; i < 3; i++) EXPECT_EQ(M(i, i), 1.0);
33 }
34 
35 TEST(CMatrixFixed, asString)
36 {
38  M.setIdentity();
39  EXPECT_EQ(std::string("1 0\n0 1"), M.asString());
40 }
41 
42 TEST(CMatrixFixed, GetSetEigen)
43 {
44  {
46  auto em = M.asEigen();
47  em.setIdentity();
48  for (int i = 0; i < 3; i++) EXPECT_EQ(M(i, i), 1.0);
49  }
50  {
52  auto em = M.asEigen();
53  for (int i = 0; i < 3; i++)
54  for (int j = 0; j < 3; j++)
55  {
56  const auto n = ((i + 1) * 3) + (j * 1001);
57  em(i, j) = n;
58  EXPECT_NEAR(M(i, j), em(i, j), 1e-9)
59  << "(i,j)=(" << i << "," << j << ")\n";
60  }
61  }
62 }
A compile-time fixed-size numeric matrix container.
Definition: CMatrixFixed.h:33
std::string asString() const
Returns a string representation of the vector/matrix, using Eigen&#39;s default settings.
GLenum GLsizei n
Definition: glext.h:5136
GLsizei const GLchar ** string
Definition: glext.h:4116
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object.
Definition: CMatrixFixed.h:251
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
TEST(CMatrixFixed, CtorUninit)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019