diff --git a/davidson.h b/davidson.h index 50cb390..c48e890 100644 --- a/davidson.h +++ b/davidson.h @@ -46,7 +46,7 @@ namespace LA { template -extern void davidson(const Matrix &bigmat, NRVec &eivals, NRVec *eivecs, const char *eivecsfile, +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, void (*initguess)(NRVec &)=NULL, const typename LA_traits::normtype *target=NULL) @@ -309,6 +309,25 @@ if(incore) {delete[] v0; delete[] v1;} else {delete s0; delete s1;} if(flag) laerror("no convergence in davidson"); +} //davidson + + +//reconstruction of explicit dense matrix from the implicit one (useful for debugging) +template +NRMat explicit_matrix(const Matrix &bigmat) +{ +NRMat r(bigmat.nrows(), bigmat.ncols()); +for(int i=0; i ket(bigmat.ncols()); + ket.clear(); + ket[i]=(T)1; + NRVec hket(bigmat.nrows()); + bigmat.gemv((T)0,hket,'n',(T)1,ket); + for(int l=0; l>n>>m; @@ -4650,5 +4650,14 @@ if(n<=20) } } +if(1); +{ +int n,m; +cin>> n>>m; +NRMat a(n,m); +a.randomize(1.); +NRMat b = explicit_matrix >(a); +cout <<"Error = "<<(a-b).norm()<