Main MRPT website > C++ reference for MRPT 1.9.9
matrix_eigen_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 #include <Eigen/Dense>
11 #include <gtest/gtest.h>
12 
13 using namespace Eigen;
14 using namespace std;
15 
16 /** A macro for obtaining the name of the current function: */
17 #if defined(__BORLANDC__)
18 #define __CURRENT_FUNCTION_NAME__ __FUNC__
19 #elif defined(_MSC_VER) && (_MSC_VER >= 1300)
20 #define __CURRENT_FUNCTION_NAME__ __FUNCTION__
21 #elif defined(_MSC_VER) && (_MSC_VER < 1300)
22 // Visual C++ 6 HAS NOT A __FUNCTION__ equivalent.
23 #define __CURRENT_FUNCTION_NAME__ ::system::extractFileName(__FILE__).c_str()
24 #else
25 #define __CURRENT_FUNCTION_NAME__ __PRETTY_FUNCTION__
26 #endif
27 
28 #if 0
29 
30 template <int ColRowOrder>
31 void do_test_EigenVal4x4_sym_vs_generic_eigen()
32 {
33  typedef Matrix<double,4,4,ColRowOrder> Mat44;
34 
35  const double dat_C1[] = {
36  13.737245,10.248641,-5.839599,11.108320,
37  10.248641,14.966139,-5.259922,11.662222,
38  -5.839599,-5.259922,9.608822,-4.342505,
39  11.108320,11.662222,-4.342505,12.121940 };
40  const Mat44 C1(dat_C1); // It doesn't mind the row/col major order since data are symetric
41 
42  // Symetric --------------------
43  // This solver returns the eigenvectors already sorted.
44  Eigen::SelfAdjointEigenSolver<Mat44> eigensolver(C1);
45 // MatrixXd eVecs_s = eigensolver.eigenvectors();
46 // MatrixXd eVals_s = eigensolver.eigenvalues();
47 
48  cout << endl << __CURRENT_FUNCTION_NAME__ << endl
49  << "SelfAdjointEigenSolver:\n"
50  << "eigvecs: " << endl << eigensolver.eigenvectors() << endl
51  << "eigvals: " << endl << eigensolver.eigenvalues() << endl;
52 
53  // Generic ---------------------
54  Eigen::EigenSolver<Mat44> es(C1, true);
55 // MatrixXd eVecs_g = es.eigenvectors().real();
56 // MatrixXd eVals_g = es.eigenvalues().real();
57 
58  cout << endl
59  << "EigenSolver:\n"
60  << "eigvecs: " << endl << es.eigenvectors() << endl
61  << "eigvals: " << endl << es.eigenvalues() << endl;
62 }
63 
64 // Compare the two ways of computing matrix eigenvectors: generic & for symmetric matrices:
65 TEST(MatricesEigen,EigenVal4x4_sym_vs_generic)
66 {
67  do_test_EigenVal4x4_sym_vs_generic_eigen<Eigen::ColMajor>();
68  do_test_EigenVal4x4_sym_vs_generic_eigen<Eigen::RowMajor>();
69 }
70 
71 #endif
STL namespace.
TEST(Compress, DataBlockGZ)
#define __CURRENT_FUNCTION_NAME__
A macro for obtaining the name of the current function:



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