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-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
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 
17 #include <mrpt/random.h>
18 #include <gtest/gtest.h>
19 
20 using namespace mrpt;
21 using namespace mrpt::utils;
22 using namespace mrpt::math;
23 using namespace mrpt::random;
24 using namespace mrpt::utils::metaprogramming;
25 using namespace std;
26 
27 TEST(Matrices, loadFromArray)
28 {
29  alignas(16)
30  const double nums[3 * 4] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
31 
33  mat.loadFromArray(nums);
34 
35  for (int r = 0; r < 3; r++)
36  for (int c = 0; c < 4; c++) EXPECT_EQ(nums[4 * r + c], mat(r, c));
37 }
38 
39 TEST(Matrices, CMatrixFixedNumeric_loadWithEigenMap)
40 {
41  alignas(16) double nums[3 * 4] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
42 
43  // Row major
45  Eigen::Map<CMatrixFixedNumeric<double, 3, 4>::Base, Eigen::Aligned>(
46  nums);
47 
48  for (int r = 0; r < 3; r++)
49  for (int c = 0; c < 4; c++) EXPECT_EQ(nums[4 * r + c], mat(r, c));
50 }
51 
52 TEST(Matrices, EigenMatrix_loadWithEigenMap)
53 {
54  alignas(16) double nums[3 * 4] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
55  // Col major
56  const Eigen::Matrix<double, 3, 4> mat =
57  Eigen::Map<Eigen::Matrix<double, 3, 4>, Eigen::Aligned>(nums);
58 
59  for (int r = 0; r < 3; r++) // Transposed!!
60  for (int c = 0; c < 4; c++) EXPECT_EQ(nums[3 * c + r], mat(r, c));
61 }
A namespace of pseudo-random numbers genrators of diferent distributions.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
STL namespace.
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
const GLubyte * c
Definition: glext.h:6313
A set of utility objects for metaprogramming with STL algorithms.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLdouble GLdouble GLdouble r
Definition: glext.h:3705
TEST(Matrices, loadFromArray)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019