From bfb320e30296f815cc9b941b1ea5401306b4b5a5 Mon Sep 17 00:00:00 2001 From: jiri Date: Wed, 25 Oct 2006 08:29:57 +0000 Subject: [PATCH] *** empty log message *** --- conjgrad.h | 12 ++++++------ gmres.h | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/conjgrad.h b/conjgrad.h index f181841..f27d590 100644 --- a/conjgrad.h +++ b/conjgrad.h @@ -7,7 +7,7 @@ //conjugate gradient solution of a linear system -//matrix can be any class which has nrows(), ncols(), diagonalof() and NRVec::gemv() available +//matrix can be any class which has nrows(), ncols(), diagonalof() and gemv() available //does not even have to be explicitly stored //Conjugate gradient algorithm, cf. Bulirsch-Stoer book @@ -29,14 +29,14 @@ if(issquare) r=&s; else r = new NRVec(m); if(doguess) { - x.gemv(0,bigmat,'t',-1.,b); + bigmat.gemv(0,x,'t',-1.,b); //x.gemv(0,bigmat,'t',-1.,b); if(precondition) bigmat.diagonalof(x,true); x.normalize(); } -s.gemv(0,bigmat,'n',-1.,x); +bigmat.gemv(0,s,'n',-1.,x); //s.gemv(0,bigmat,'n',-1.,x); s+=b; -if(!issquare) (*r).gemv(0,bigmat,'t',1,s); +if(!issquare) bigmat.gemv(0,*r,'t',1,s); //(*r).gemv(0,bigmat,'t',1,s); rr= *r; if(precondition) bigmat.diagonalof(rr,true); p=rr; @@ -49,14 +49,14 @@ for(int iter=0; iter<= itmax; iter++) resetiosflags(ios::scientific)< void gmres_backsubstitute(const NRMat &R, NRVec &c, const NRVec &d, const int k) @@ -28,7 +28,7 @@ for (int i=k-1;i>=0;i--) c[i] = (d[i]-xdot(k-i,&R(i,i+1),1,&c[i+1],1)) / R(i,i); //x contains ev. initial guess and on return the solution template -void gmres(const Matrix &bigmat, const NRVec &b, NRVec &x, const bool doguess, const double eps, const int MAXIT, const bool verbose, bool square,const bool precondition, int neustart, const int incore) +void gmres(const Matrix &bigmat, const NRVec &b, NRVec &x, const bool doguess=1, const double eps=1e-7, const int MAXIT=50, const bool verbose=1, bool square=1,const bool precondition=1, int neustart=0, const int incore=1) { int zeilen=bigmat.nrows(); int spalten=bigmat.ncols(); @@ -55,7 +55,7 @@ st = incore?NULL:new AuxStorage; if(doguess) { - x.gemv(0,bigmat,'t',-1.,b); + bigmat.gemv(0,x,'t',-1.,b); //x.gemv(0,bigmat,'t',-1.,b); if(precondition) bigmat.diagonalof(x,true); x.normalize(); } @@ -65,15 +65,15 @@ for (int l=0;l dum(zeilen); - dum.gemv(0,bigmat,'n',1,x); - r_k.gemv(0,bigmat,'t',1,dum); - z.gemv(0,bigmat,'t',-1.,b); + bigmat.gemv(0,dum,'n',1,x); //dum.gemv(0,bigmat,'n',1,x); + bigmat.gemv(0,r_k,'t',1,dum); //r_k.gemv(0,bigmat,'t',1,dum); + bigmat.gemv(0,z,'t',-1.,b); //z.gemv(0,bigmat,'t',-1.,b); r_k += z; } @@ -94,13 +94,13 @@ for (int l=0;lget(v[0],k); if(square) { - z.gemv(0,bigmat,'n',1,v[incore?k:0]); + bigmat.gemv(0,z,'n',1,v[incore?k:0]); //z.gemv(0,bigmat,'n',1,v[incore?k:0]); } else { NRVec dum(zeilen); - dum.gemv(0,bigmat,'n',1,v[incore?k:0]); - z.gemv(0,bigmat,'t',1,dum); + bigmat.gemv(0,dum,'n',1,v[incore?k:0]); //dum.gemv(0,bigmat,'n',1,v[incore?k:0]); + bigmat.gemv(0,z,'t',1,dum); //z.gemv(0,bigmat,'t',1,dum); } if(precondition) bigmat.diagonalof(z,true);