SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DirectEigenSolver.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2013 Soumyajit De
8  */
9 
10 #include <shogun/lib/config.h>
11 
12 #ifdef HAVE_EIGEN3
13 #include <shogun/lib/SGMatrix.h>
17 
18 using namespace Eigen;
19 
20 namespace shogun
21 {
22 
23 CDirectEigenSolver::CDirectEigenSolver()
24  : CEigenSolver()
25 {
26  SG_GCDEBUG("%s created (%p)\n", this->get_name(), this)
27 }
28 
30  CDenseMatrixOperator<float64_t>* linear_operator)
31  : CEigenSolver((CLinearOperator<float64_t>*)linear_operator)
32 {
33  SG_GCDEBUG("%s created (%p)\n", this->get_name(), this)
34 }
35 
37 {
38  SG_GCDEBUG("%s destroyed (%p)\n", this->get_name(), this)
39 }
40 
42 {
44  {
45  SG_DEBUG("Minimum/maximum eigenvalues are already computed, exiting\n");
46  return;
47  }
48 
51  REQUIRE(op, "Linear operator is not of CDenseMatrixOperator type!\n");
52 
54  Map<MatrixXd> map_m(m.matrix, m.num_rows, m.num_cols);
55 
56  // compute the eigenvalues with Eigen3
57  SelfAdjointEigenSolver<MatrixXd> eig_solver(map_m);
58  m_min_eigenvalue=eig_solver.eigenvalues()[0];
59  m_max_eigenvalue=eig_solver.eigenvalues()[op->get_dimension()-1];
60 
61  m_is_computed_min=true;
62  m_is_computed_max=false;
63 }
64 
65 }
66 #endif // HAVE_EIGEN3

SHOGUN Machine Learning Toolbox - Documentation