Main MRPT website > C++ reference for MRPT 1.5.7
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 
14 
18 #include <mrpt/random.h>
19 #include <gtest/gtest.h>
20 
21 using namespace mrpt;
22 using namespace mrpt::utils;
23 using namespace mrpt::math;
24 using namespace mrpt::random;
25 using namespace mrpt::utils::metaprogramming;
26 using namespace std;
27 
28 
29 TEST(Matrices, loadFromArray)
30 {
31  MRPT_ALIGN16 const double nums[3*4] = {
32  1,2,3,4,
33  5,6,7,8,
34  9,10,11,12 };
35 
37  mat.loadFromArray(nums);
38 
39  for (int r=0;r<3;r++)
40  for (int c=0;c<4;c++)
41  EXPECT_EQ( nums[4*r+c], mat(r,c) );
42 }
43 
44 TEST(Matrices, CMatrixFixedNumeric_loadWithEigenMap)
45 {
46  MRPT_ALIGN16 double nums[3*4] = {
47  1,2,3,4,
48  5,6,7,8,
49  9,10,11,12 };
50 
51  // Row major
52  const CMatrixFixedNumeric<double,3,4> mat = Eigen::Map<CMatrixFixedNumeric<double,3,4>::Base, Eigen::Aligned >(nums);
53 
54  for (int r=0;r<3;r++)
55  for (int c=0;c<4;c++)
56  EXPECT_EQ( nums[4*r+c], mat(r,c) );
57 }
58 
59 TEST(Matrices, EigenMatrix_loadWithEigenMap)
60 {
61  MRPT_ALIGN16 double nums[3*4] = {
62  1,2,3,4,
63  5,6,7,8,
64  9,10,11,12 };
65  // Col major
66  const Eigen::Matrix<double,3,4> mat = Eigen::Map<Eigen::Matrix<double,3,4>, Eigen::Aligned >(nums);
67 
68  for (int r=0;r<3;r++) // Transposed!!
69  for (int c=0;c<4;c++)
70  EXPECT_EQ( nums[3*c+r], mat(r,c) );
71 }
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.
Definition: zip.h:16
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:5590
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:3618
TEST(Matrices, loadFromArray)
#define MRPT_ALIGN16



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 8277875f6 Mon Jun 11 02:47:32 2018 +0200 at lun oct 28 01:50:49 CET 2019