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");
78 Map<VectorXd> v_i(v_.vector, v_.vlen);
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",
104 Map<VectorXd> w_i(w_.vector, w_.vlen);
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_EIGEN3
172 #endif // HAVE_LAPACK