29 errorQuda(
"Only real spectrum type (LR or SR) can be passed to the TR Lanczos solver");
48 for (
int i = 0; i < arrow_mat_array_size; i++) {
90 double mat_norm = 0.0;
114 if (fabs(
alpha[i]) > mat_norm) mat_norm = fabs(
alpha[i]);
172 for (
int i = 0; i <
n_kr; i++) {
188 errorQuda(
"BLOCK TRLM failed to compute the requested %d vectors with a %d search space, %d block size, "
189 "and %d Krylov space in %d restart steps. Exiting.",
192 warningQuda(
"BLOCK TRLM failed to compute the requested %d vectors with a %d search space, %d block size, "
193 "and %d Krylov space in %d restart steps. Continuing with current lanczos factorisation.",
198 printfQuda(
"BLOCK TRLM computed the requested %d vectors in %d restart steps with %d block size and "
199 "%d BLOCKED OP*x operations.\n",
203 for (
int i = 0; i <
n_conv; i++) {
232 int idx = 0, idx_conj = 0;
241 std::vector<ColorSpinorField *> r_;
243 for (
int i = 0; i <
block_size; i++) r_.push_back(
r[i]);
246 std::vector<Complex> beta_;
251 for (
int i = 0; i < blocks; i++) {
256 beta_.push_back(-
block_beta[block_offset + idx]);
261 std::vector<ColorSpinorField *> v_;
262 v_.reserve(j -
start);
263 for (
int i =
start; i < j; i++) { v_.push_back(v[i]); }
271 std::vector<ColorSpinorField *> vecs_ptr;
273 for (
int b = 0; b <
block_size; b++) { vecs_ptr.push_back(v[j + b]); }
307 while (!orthed && k < kmax) {
346 for (
int c = 0; c < b + 1; c++) {
361 for (
int c = 0; c < b + 1; c++) {
373 for (
int c = 0; c < b + 1; c++) {
394 MatrixXcd T = MatrixXcd::Zero(
dim,
dim);
399 for (
int i = 0; i < block_arrow_pos; i++) {
415 for (
int i = block_arrow_pos; i < blocks; i++) {
425 for (
int i = block_arrow_pos; i < blocks - 1; i++) {
427 for (
int c = 0; c < b + 1; c++) {
439 for (
int b = 0; b <
dim; b++) {
440 for (
int c = 0; c <
dim; c++) {
443 if (b == c && b < arrow_pos && c < arrow_pos) T(c, b) *= -1.0;
449 SelfAdjointEigenSolver<MatrixXcd> eigensolver;
450 eigensolver.compute(T);
456 for (
int i = 0; i <
dim; i++)
457 for (
int j = 0; j <
dim; j++)
block_ritz_mat[
dim * i + j] = eigensolver.eigenvectors().col(i)[j];
459 for (
int i = 0; i < blocks; i++) {
477 for (
int j = 0; j <
dim; j++) {
497 for (
int c = 0; c < b + 1; c++) {
502 for (
int i = 0; i < blocks; i++) {
std::vector< Complex > block_ritz_mat
void operator()(std::vector< ColorSpinorField * > &kSpace, std::vector< Complex > &evals)
Compute eigenpairs.
void eigensolveFromBlockArrowMat()
Get the eigendecomposition from the current block arrow matrix.
void computeBlockKeptRitz(std::vector< ColorSpinorField * > &kSpace)
Rotate the Ritz vectors usinng the arrow matrix eigendecomposition Uses a complex ritz matrix.
BLKTRLM(const DiracMatrix &mat, QudaEigParam *eig_param, TimeProfile &profile)
Constructor for Thick Restarted Eigensolver class.
void updateBlockBeta(int k, int arrow_offset)
Accumulate the R products of QR into the block beta array.
virtual ~BLKTRLM()
Destructor for Thick Restarted Eigensolver class.
void blockLanczosStep(std::vector< ColorSpinorField * > v, int j)
block lanczos step: extends the Krylov space in block step
void blockOrthogonalize(std::vector< ColorSpinorField * > v, std::vector< ColorSpinorField * > &r, int j)
Orthogonalise input vectors r against vector space v using block-BLAS.
bool orthoCheck(std::vector< ColorSpinorField * > v, int j)
Check orthonormality of input vector space v.
void prepareInitialGuess(std::vector< ColorSpinorField * > &kSpace)
Check for an initial guess. If none present, populate with rands, then orthonormalise.
std::vector< ColorSpinorField * > r
void checkChebyOpMax(const DiracMatrix &mat, std::vector< ColorSpinorField * > &kSpace)
Check for a maximum of the Chebyshev operator.
double setEpsilon(const QudaPrecision prec)
Set the epsilon parameter.
void computeEvals(const DiracMatrix &mat, std::vector< ColorSpinorField * > &evecs, std::vector< Complex > &evals, int size)
Compute eigenvalues and their residiua.
void rotateVecsComplex(std::vector< ColorSpinorField * > &kSpace, const Complex *rot_array, const int offset, const int dim, const int keep, const int locked, TimeProfile &profile)
Rotate the Krylov space.
void queryPrec(const QudaPrecision prec)
Query the eigensolver precision to stdout.
void prepareKrylovSpace(std::vector< ColorSpinorField * > &kSpace, std::vector< Complex > &evals)
Extend the Krylov space.
void loadFromFile(const DiracMatrix &mat, std::vector< ColorSpinorField * > &eig_vecs, std::vector< Complex > &evals)
Load and check eigenpairs from file.
void cleanUpEigensolver(std::vector< ColorSpinorField * > &kSpace, std::vector< Complex > &evals)
Release memory, save eigenvectors, resize the Krylov space to its original dimension.
void printEigensolverSetup()
Dump the eigensolver parameters to stdout.
void chebyOp(const DiracMatrix &mat, ColorSpinorField &out, const ColorSpinorField &in)
Promoted the specified matVec operation: M, Mdag, MMdag, MdagM to a Chebyshev polynomial.
std::vector< double > residua
Thick Restarted Lanczos Method.
bool isRunning(QudaProfileType idx)
void mat(void *out, void **link, void *in, int dagger_bit, int mu, QudaPrecision sPrecision, QudaPrecision gPrecision)
#define safe_malloc(size)
void ax(double a, ColorSpinorField &x)
double norm2(const ColorSpinorField &a)
void caxpy_L(const Complex *a, std::vector< ColorSpinorField * > &x, std::vector< ColorSpinorField * > &y)
Compute the block "caxpy_L" with over the set of ColorSpinorFields. E.g., it computes.
void caxpy(const Complex &a, ColorSpinorField &x, ColorSpinorField &y)
Complex cDotProduct(ColorSpinorField &, ColorSpinorField &)
void start()
Start profiling.
__host__ __device__ ValueType conj(ValueType x)
void saveTuneCache(bool error=false)
std::complex< double > Complex
__host__ __device__ ValueType sqrt(ValueType x)
__host__ __device__ ValueType norm(const complex< ValueType > &z)
Returns the magnitude of z squared.
QudaEigSpectrumType spectrum
QudaBoolean require_convergence
DEVICEHOST void swap(Real &a, Real &b)
QudaVerbosity getVerbosity()