diff --git a/davidson.h b/davidson.h index 0bcb06e..a07e613 100644 --- a/davidson.h +++ b/davidson.h @@ -36,7 +36,8 @@ namespace LA { template extern void davidson(const Matrix &bigmat, NRVec &eivals, NRVec *eivecs, const char *eivecsfile, int nroots=1, const bool verbose=0, const double eps=1e-6, - const bool incore=1, int maxit=100, const int maxkrylov = 500); + const bool incore=1, int maxit=100, const int maxkrylov = 500, + void (*initguess)(NRVec &)=NULL); //@@@options: left eigenvectors by matrix transpose, overridesymmetric (for nrmat) //@@@small matrix gdiagonalize - shift complex roots up (option to gdiagonalize?) @@ -50,7 +51,8 @@ extern void davidson(const Matrix &bigmat, NRVec &eivals, NRVec *eivecs, c template void davidson(const Matrix &bigmat, NRVec &eivals, NRVec *eivecs, const char *eivecsfile, int nroots, const bool verbose, const double eps, - const bool incore, int maxit, const int maxkrylov) + const bool incore, int maxit, const int maxkrylov, + void (*initguess)(NRVec &)) { bool flag=0; int n=bigmat.nrows(); @@ -82,12 +84,18 @@ int nroot=0; int oldnroot; smallS=0; smallH=0; -//guess based on lowest diagonal element of the matrix -const T *diagonal = bigmat.diagonalof(vec2,false,true); -vec1=0; -{T t=1e100; int i,j; -for(i=0, j= -1; iget(vec2,j); vec1.axpy(smallV(j,nroot),incore?v1[j]:vec2); } -diagonal = bigmat.diagonalof(vec2,false,true); + +{ +const T *diagonal = bigmat.diagonalof(vec2,false,true); eival_n = r[nroot]; for(i=0; i