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