7 #ifndef GEN_EIGS_SOLVER_H
8 #define GEN_EIGS_SOLVER_H
19 #include "LinAlg/UpperHessenbergQR.h"
20 #include "LinAlg/DoubleShiftQR.h"
21 #include "LinAlg/UpperHessenbergEigen.h"
22 #include "MatOp/DenseGenMatProd.h"
23 #include "MatOp/DenseGenRealShiftSolve.h"
80 template <
typename Scalar = double,
86 typedef arma::Mat<Scalar> Matrix;
87 typedef arma::Col<Scalar> Vector;
88 typedef arma::uvec BoolVector;
90 typedef std::complex<Scalar> Complex;
91 typedef arma::Mat<Complex> ComplexMatrix;
92 typedef arma::Col<Complex> ComplexVector;
114 ComplexVector ritz_val;
117 ComplexMatrix ritz_vec;
118 BoolVector ritz_conv;
126 inline void factorize_from(
int from_k,
int to_m,
const Vector &fk);
128 static bool is_complex(Complex v, Scalar eps)
130 return std::abs(v.imag()) > eps;
133 static bool is_conj(Complex v1, Complex v2, Scalar eps)
135 return std::abs(v1 - std::conj(v2)) < eps;
139 inline void restart(
int k);
142 inline int num_converged(Scalar tol);
145 inline int nev_adjusted(
int nconv);
148 inline void retrieve_ritzpair();
153 inline virtual void sort_ritzpair();
177 ncv(ncv_ > dim_n ? dim_n : ncv_),
180 prec(std::pow(std::numeric_limits<Scalar>::epsilon(), Scalar(2.0) / 3))
182 if(nev_ < 1 || nev_ > dim_n - 2)
183 throw std::invalid_argument(
"nev must satisfy 1 <= nev <= n - 2, n is the size of matrix");
185 if(ncv_ < nev_ + 2 || ncv_ > dim_n)
186 throw std::invalid_argument(
"ncv must satisfy nev + 2 <= ncv <= n, n is the size of matrix");
198 inline void init(Scalar *init_resid);
217 inline int compute(
int maxit = 1000, Scalar tol = 1e-10);
256 #include "GenEigsSolver_Impl.h"
278 template <
typename Scalar = double,
284 typedef arma::Col<Scalar> Vector;
285 typedef std::complex<Scalar> Complex;
286 typedef arma::Col<Complex> ComplexVector;
293 ComplexVector ritz_val_org = Scalar(1.0) / this->ritz_val.head(this->nev) + sigma;
294 this->ritz_val.head(this->nev) = ritz_val_org;
317 GenEigsSolver<Scalar, SelectionRule, OpType>(op_, nev_, ncv_),
320 this->op->set_shift(sigma);
324 #endif // GEN_EIGS_SOLVER_H
GenEigsRealShiftSolver(OpType *op_, int nev_, int ncv_, Scalar sigma_)
ComplexVector eigenvalues()
GenEigsSolver(OpType *op_, int nev_, int ncv_)
int compute(int maxit=1000, Scalar tol=1e-10)
ComplexMatrix eigenvectors()