davidson: added root targeting

This commit is contained in:
2025-12-09 16:03:04 +01:00
parent 3d284d544a
commit 1cb536421f
2 changed files with 46 additions and 3 deletions

27
t.cc
View File

@@ -4500,7 +4500,7 @@ cout <<"Error = "<<(xt-y).norm()<<endl;
}
if(1)
if(0)
{
//n must not be too small
int n,m;
@@ -4537,4 +4537,29 @@ for(int i=0; i<m; ++i)
}
if(1)
{
int n,m;
cin>>n >>m;
NRSMat<double> a(n);
NRVec<double> rr(n);
for(int i=0;i<n;++i) for(int j=0;j<=i;++j)
{
a(i,j)= RANDDOUBLE();
if(i==j) a(i,i)+= .5*(i-n*.5);
}
NRSMat<double> aa;
NRMat<double> vv(n,n);
aa=a; diagonalize(aa,rr,&vv);
NRVec<double> r(m);
NRVec<double> *eivecs = new NRVec<double>[m];
double target= 0;
cout <<"Exact energies " <<rr<<endl;
davidson(a,r,eivecs,NULL,m,1,1e-6,1,200,300,(void (*)(LA::NRVec<double>&))NULL,&target);
cout <<"Davidson energies " <<r;
}
}//main