SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 #include <shogun/lib/SGMatrix.h>
16 
17 using namespace Eigen;
18 
19 namespace shogun
20 {
21 
22 CDirectEigenSolver::CDirectEigenSolver()
23  : CEigenSolver()
24 {
25  SG_GCDEBUG("%s created (%p)\n", this->get_name(), this)
26 }
27 
29  CDenseMatrixOperator<float64_t>* linear_operator)
30  : CEigenSolver((CLinearOperator<float64_t>*)linear_operator)
31 {
32  SG_GCDEBUG("%s created (%p)\n", this->get_name(), this)
33 }
34 
36 {
37  SG_GCDEBUG("%s destroyed (%p)\n", this->get_name(), this)
38 }
39 
41 {
43  {
44  SG_DEBUG("Minimum/maximum eigenvalues are already computed, exiting\n");
45  return;
46  }
47 
50  REQUIRE(op, "Linear operator is not of CDenseMatrixOperator type!\n");
51 
53  Map<MatrixXd> map_m(m.matrix, m.num_rows, m.num_cols);
54 
55  // compute the eigenvalues with Eigen3
56  SelfAdjointEigenSolver<MatrixXd> eig_solver(map_m);
57  m_min_eigenvalue=eig_solver.eigenvalues()[0];
58  m_max_eigenvalue=eig_solver.eigenvalues()[op->get_dimension()-1];
59 
60  m_is_computed_min=true;
61  m_is_computed_max=false;
62 }
63 
64 }
SGMatrix< T > get_matrix_operator() const
const index_t get_dimension() const
float64_t m_min_eigenvalue
Definition: EigenSolver.h:93
Definition: SGMatrix.h:20
float64_t m_max_eigenvalue
Definition: EigenSolver.h:96
#define REQUIRE(x,...)
Definition: SGIO.h:206
index_t num_cols
Definition: SGMatrix.h:376
index_t num_rows
Definition: SGMatrix.h:374
#define SG_GCDEBUG(...)
Definition: SGIO.h:102
double float64_t
Definition: common.h:50
virtual const char * get_name() const
#define SG_DEBUG(...)
Definition: SGIO.h:107
Abstract base class that provides an abstract compute method for computing eigenvalues of a real valu...
Definition: EigenSolver.h:24
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
Abstract template base class that represents a linear operator, e.g. a matrix.
CLinearOperator< float64_t > * m_linear_operator
Definition: EigenSolver.h:99

SHOGUN Machine Learning Toolbox - Documentation