23 using namespace Eigen;
28 CLanczosEigenSolver::CLanczosEigenSolver()
41 void CLanczosEigenSolver::init()
43 m_max_iteration_limit=1000;
44 m_relative_tolerence=1E-6;
45 m_absolute_tolerence=1E-6;
47 SG_ADD(&m_max_iteration_limit,
"max_iteration_limit",
50 SG_ADD(&m_relative_tolerence,
"relative_tolerence",
53 SG_ADD(&m_absolute_tolerence,
"absolute_tolerence",
67 SG_DEBUG(
"Minimum/maximum eigenvalues are already computed, exiting\n");
79 v_i=VectorXd::Random(v_.vlen);
84 m_relative_tolerence, m_absolute_tolerence);
87 std::vector<float64_t> alpha;
90 std::vector<float64_t> beta;
96 for (it.
begin(v_i); !it.
end(v_i); ++it)
98 SG_DEBUG(
"CG iteration %d, residual norm %f\n",
112 w_i-=alpha_i*v_i+beta_i*v;
118 alpha.push_back(alpha_i);
119 beta.push_back(beta_i);
129 std::vector<float64_t> alpha_orig=alpha;
130 std::vector<float64_t> beta_orig=beta;
135 wrap_dstemr(
'N',
'I', alpha.size(), &alpha[0], &beta[0],
136 0.0, 0.0, 1, 1, &M, w.vector, NULL, 1, 1, NULL, 0.0, &info);
140 SG_INFO(
"Iteration took %ld times, residual norm=%.20lf\n",
147 SG_WARNING(
"Some error occured while computing eigenvalues!\n");
153 wrap_dstemr(
'N',
'I', alpha_orig.size(), &alpha_orig[0], &beta_orig[0],
154 0.0, 0.0, w.vlen, w.vlen, &M, w.vector, NULL, 1, 1, NULL, 0.0, &info);
158 SG_INFO(
"Iteration took %ld times, residual norm=%.20lf\n",
164 SG_WARNING(
"Some error occured while computing eigenvalues!\n");
171 #endif // HAVE_LAPACK
void begin(const VectorXt &residual)
const index_t get_dimension() const
float64_t m_min_eigenvalue
float64_t m_max_eigenvalue
const bool end(const VectorXt &residual)
void wrap_dstemr(char jobz, char range, int n, double *diag, double *subdiag, double vl, double vu, int il, int iu, int *m, double *w, double *z__, int ldz, int nzc, int *isuppz, int tryrac, int *info)
template class that is used as an iterator for an iterative linear solver. In the iteration of solvin...
virtual ~CLanczosEigenSolver()
const IterInfo get_iter_info() const
virtual SGVector< T > apply(SGVector< T > b) const =0
Abstract base class that provides an abstract compute method for computing eigenvalues of a real valu...
all of classes and functions are contained in the shogun namespace
CLinearOperator< float64_t > * m_linear_operator