*** empty log message ***
This commit is contained in:
parent
bfb320e302
commit
4f3d079afa
10
conjgrad.h
10
conjgrad.h
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
template<typename T, typename Matrix>
|
template<typename T, typename Matrix>
|
||||||
extern void conjgrad(const Matrix &bigmat, const NRVec<T> &b, NRVec<T> &x, const bool doguess, const double tol, const int itmax, const bool verbose, bool issquare,const bool precondition)
|
extern bool conjgrad(const Matrix &bigmat, const NRVec<T> &b, NRVec<T> &x, const bool doguess, const double tol, const int itmax, const bool verbose, bool issquare,const bool precondition)
|
||||||
{
|
{
|
||||||
int m=bigmat.nrows();
|
int m=bigmat.nrows();
|
||||||
int n=bigmat.ncols();
|
int n=bigmat.ncols();
|
||||||
@ -47,7 +47,11 @@ for(int iter=0; iter<= itmax; iter++)
|
|||||||
if(verbose) cout << "conjgrad: iter= "<<iter<<" err= "<<
|
if(verbose) cout << "conjgrad: iter= "<<iter<<" err= "<<
|
||||||
setiosflags(ios::scientific)<<setprecision(8) <<err<<
|
setiosflags(ios::scientific)<<setprecision(8) <<err<<
|
||||||
resetiosflags(ios::scientific)<<setprecision(12)<<"\n";
|
resetiosflags(ios::scientific)<<setprecision(12)<<"\n";
|
||||||
if(err <= tol) break;
|
if(err <= tol)
|
||||||
|
{
|
||||||
|
if(!issquare) delete r;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bigmat.gemv(0,q,'n',1,p); //q.gemv(0,bigmat,'n',1,p);
|
bigmat.gemv(0,q,'n',1,p); //q.gemv(0,bigmat,'n',1,p);
|
||||||
tt= (*r) * rr;
|
tt= (*r) * rr;
|
||||||
@ -66,6 +70,6 @@ for(int iter=0; iter<= itmax; iter++)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!issquare) delete r;
|
if(!issquare) delete r;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
gmres.h
4
gmres.h
@ -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
|
//x contains ev. initial guess and on return the solution
|
||||||
template<typename T, typename Matrix>
|
template<typename T, typename Matrix>
|
||||||
void gmres(const Matrix &bigmat, const NRVec<T> &b, NRVec<T> &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)
|
bool gmres(const Matrix &bigmat, const NRVec<T> &b, NRVec<T> &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 zeilen=bigmat.nrows();
|
||||||
int spalten=bigmat.ncols();
|
int spalten=bigmat.ncols();
|
||||||
@ -232,6 +232,6 @@ myreturn:
|
|||||||
delete[] v;
|
delete[] v;
|
||||||
if(!incore) delete st;
|
if(!incore) delete st;
|
||||||
|
|
||||||
if(flag) laerror("no convergence in GMRES");
|
return !flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user