SHOGUN
v3.2.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 2013 Soumyajit De 00008 */ 00009 00010 #ifndef EIGEN_SOLVER_H_ 00011 #define EIGEN_SOLVER_H_ 00012 00013 #include <shogun/lib/config.h> 00014 #include <shogun/base/Parameter.h> 00015 #include <shogun/mathematics/linalg/linop/LinearOperator.h> 00016 00017 namespace shogun 00018 { 00019 00024 class CEigenSolver : public CSGObject 00025 { 00026 public: 00028 CEigenSolver() 00029 : CSGObject() 00030 { 00031 init(); 00032 } 00033 00040 CEigenSolver(CLinearOperator<float64_t>* linear_operator) 00041 : CSGObject() 00042 { 00043 init(); 00044 00045 m_linear_operator=linear_operator; 00046 SG_REF(m_linear_operator); 00047 } 00049 virtual ~CEigenSolver() 00050 { 00051 SG_UNREF(m_linear_operator); 00052 } 00053 00058 virtual void compute() = 0; 00059 00061 void set_min_eigenvalue(float64_t min_eigenvalue) 00062 { 00063 m_min_eigenvalue=min_eigenvalue; 00064 m_is_computed_min=true; 00065 } 00066 00068 const float64_t get_min_eigenvalue() const 00069 { 00070 return m_min_eigenvalue; 00071 } 00072 00074 void set_max_eigenvalue(float64_t max_eigenvalue) 00075 { 00076 m_max_eigenvalue=max_eigenvalue; 00077 m_is_computed_max=true; 00078 } 00079 00081 const float64_t get_max_eigenvalue() const 00082 { 00083 return m_max_eigenvalue; 00084 } 00085 00087 virtual const char* get_name() const 00088 { 00089 return "EigenSolver"; 00090 } 00091 protected: 00093 float64_t m_min_eigenvalue; 00094 00096 float64_t m_max_eigenvalue; 00097 00099 CLinearOperator<float64_t>* m_linear_operator; 00100 00102 bool m_is_computed_min; 00103 00105 bool m_is_computed_max; 00106 00107 private: 00109 void init() 00110 { 00111 m_min_eigenvalue=0.0; 00112 m_max_eigenvalue=0.0; 00113 m_linear_operator=NULL; 00114 m_is_computed_min=false; 00115 m_is_computed_max=false; 00116 00117 SG_ADD(&m_min_eigenvalue, "min_eigenvalue", 00118 "Minimum eigenvalue of a real valued self-adjoint linear operator", 00119 MS_NOT_AVAILABLE); 00120 00121 SG_ADD(&m_max_eigenvalue, "max_eigenvalue", 00122 "Maximum eigenvalue of a real valued self-adjoint linear operator", 00123 MS_NOT_AVAILABLE); 00124 00125 SG_ADD((CSGObject**)&m_linear_operator, "linear_operator", 00126 "Self-adjoint linear operator", 00127 MS_NOT_AVAILABLE); 00128 00129 SG_ADD(&m_is_computed_min, "is_computed_min", 00130 "Flag denoting that the minimum eigenvalue has already been computed", 00131 MS_NOT_AVAILABLE); 00132 00133 SG_ADD(&m_max_eigenvalue, "is_computed_max", 00134 "Flag denoting that the maximum eigenvalue has already been computed", 00135 MS_NOT_AVAILABLE); 00136 00137 } 00138 }; 00139 00140 } 00141 00142 #endif // EIGEN_SOLVER_H_