SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
DirectEigenSolver.cpp
浏览该文件的文档.
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
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:378
index_t num_rows
Definition: SGMatrix.h:376
#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 机器学习工具包 - 项目文档