Main MRPT website > C++ reference for MRPT 1.9.9
matrix_ops5_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
8  +------------------------------------------------------------------------+ */
9
10 // Note: Matrices unit tests have been split in different files since
11 // building them with eigen3 eats a lot of RAM and may be a problem while
12 // compiling in small systems.
13
15 #include <mrpt/random.h>
16 #include <gtest/gtest.h>
17
18 using namespace mrpt;
19 using namespace mrpt::math;
20 using namespace mrpt::random;
21 using namespace std;
22
24 {
25  alignas(MRPT_MAX_ALIGN_BYTES)
26  const double nums[3 * 4] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
27
30
31  for (int r = 0; r < 3; r++)
32  for (int c = 0; c < 4; c++) EXPECT_EQ(nums[4 * r + c], mat(r, c));
33 }
34
35 alignas(MRPT_MAX_ALIGN_BYTES) static double test_nums[3 * 4] = {
36  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
37
39 {
40  // Row major
42  Eigen::Map<CMatrixFixedNumeric<double, 3, 4>::Base, MRPT_MAX_ALIGN_BYTES>(
43  test_nums);
44
45  for (int r = 0; r < 3; r++)
46  for (int c = 0; c < 4; c++) EXPECT_EQ(test_nums[4 * r + c], mat(r, c));
47 }
48
50 {
51  // Col major
52  const Eigen::Matrix<double, 3, 4> mat =
53  Eigen::Map<Eigen::Matrix<double, 3, 4>, MRPT_MAX_ALIGN_BYTES>(test_nums);
54
55  for (int r = 0; r < 3; r++) // Transposed!!
56  for (int c = 0; c < 4; c++) EXPECT_EQ(test_nums[3 * c + r], mat(r, c));
57 }
A namespace of pseudo-random numbers generators of diferent distributions.
#define MRPT_MAX_ALIGN_BYTES
static double test_nums[3 *4]
STL namespace.
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
const GLubyte * c
Definition: glext.h:6313
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLdouble GLdouble GLdouble r
Definition: glext.h:3705