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



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST