20 #ifndef SELDON_FILE_ITERATIVE_HXX
32 #ifdef SELDON_WITH_VIRTUAL
38 virtual void SetInputPreconditioning(
const string&,
const Vector<string>&);
42 template<
class Matrix1,
class Vector1>
43 void Solve(
const Matrix1& A,
const Vector1 & r, Vector1 & z);
46 template<
class Matrix1,
class Vector1>
47 void TransSolve(
const Matrix1& A,
const Vector1& r, Vector1 & z);
79 string file_name_history;
84 Iteration(
int max_iteration,
const Titer& tol);
93 void SetSolver(
int type_resolution,
int param_restart,
int type_prec);
104 template<
class Vector1>
105 int Init(
const Vector1& r);
111 template<
class Vector1>
112 bool Finished(
const Vector1& r)
const;
113 bool Finished(
const Titer& r)
const;
115 void Fail(
int i,
const string& s);
121 template<
class T1,
class Matrix1,
class Vector1>
122 void MltAdd(
const T1& alpha,
const Matrix1& A,
const Vector1& x,
123 const T1& beta, Vector1& y);
125 template<
class Matrix1,
class Vector1>
126 void Mlt(
const Matrix1& A,
const Vector1& x, Vector1& y);
128 template<
class Matrix1,
class Vector1>
130 const Matrix1& A,
const Vector1& x, Vector1& y);
135 #ifdef SELDON_WITH_VIRTUAL
136 template<
class T,
class Vector1>
139 Iteration<
typename ClassComplexType<T>::Treal>& iter);
141 template<
class T,
class Vector1>
144 Iteration<
typename ClassComplexType<T>::Treal>& iter);
146 template<
class T,
class Vector1>
149 Iteration<
typename ClassComplexType<T>::Treal>& iter);
151 template<
class T,
class Vector1>
154 Iteration<
typename ClassComplexType<T>::Treal>& iter);
156 template<
class T,
class Vector1>
159 Iteration<
typename ClassComplexType<T>::Treal>& iter);
161 template<
class T,
class Vector1>
164 Iteration<
typename ClassComplexType<T>::Treal>& iter);
166 template<
class T,
class Vector1>
169 Iteration<
typename ClassComplexType<T>::Treal>& iter);
171 template<
class T,
class Vector1>
174 Iteration<
typename ClassComplexType<T>::Treal>& iter);
176 template<
class T,
class Vector1>
179 Iteration<
typename ClassComplexType<T>::Treal>& outer);
181 template<
class T,
class Vector1>
184 Iteration<
typename ClassComplexType<T>::Treal>& outer);
186 template<
class T,
class Vector1>
189 Iteration<
typename ClassComplexType<T>::Treal>& iter);
191 template<
class T,
class Vector1>
194 Iteration<
typename ClassComplexType<T>::Treal>& iter);
196 template<
class T,
class Vector1>
199 Iteration<
typename ClassComplexType<T>::Treal>& iter);
201 template<
class T,
class Vector1>
204 Iteration<
typename ClassComplexType<T>::Treal>& iter);
206 template<
class T,
class Vector1>
209 Iteration<
typename ClassComplexType<T>::Treal>& iter);
211 template<
class T,
class Vector1>
214 Iteration<
typename ClassComplexType<T>::Treal>& iter);
216 template<
class T,
class Vector1>
219 Iteration<
typename ClassComplexType<T>::Treal>& iter);
222 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
223 int BiCg(
const Matrix1& A, Vector1& x,
const Vector1& b,
226 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
227 int BiCgStab(
const Matrix1& A, Vector1& x,
const Vector1& b,
230 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
231 int BiCgStabl(
const Matrix1& A, Vector1& x,
const Vector1& b,
234 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
235 int BiCgcr(
const Matrix1& A, Vector1& x,
const Vector1& b,
238 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
239 int Cg(
const Matrix1& A, Vector1& x,
const Vector1& b,
242 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
243 int Cgne(
const Matrix1& A, Vector1& x,
const Vector1& b,
246 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
247 int Cgs(
const Matrix1& A, Vector1& x,
const Vector1& b,
250 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
251 int CoCg(
const Matrix1& A, Vector1& x,
const Vector1& b,
254 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
255 int Gcr(
const Matrix1& A, Vector1& x,
const Vector1& b,
258 template <
class Titer,
class MatrixSparse,
class Vector1,
class Preconditioner>
259 int Gmres(
const MatrixSparse& A, Vector1& x,
const Vector1& b,
262 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
263 int Lsqr(
const Matrix1& A, Vector1& x,
const Vector1& b,
266 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
267 int MinRes(
const Matrix1& A, Vector1& x,
const Vector1& b,
270 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
271 int QCgs(
const Matrix1& A, Vector1& x,
const Vector1& b,
274 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
275 int Qmr(
const Matrix1& A, Vector1& x,
const Vector1& b,
278 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
279 int QmrSym(
const Matrix1& A, Vector1& x,
const Vector1& b,
282 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
283 int Symmlq(
const Matrix1& A, Vector1& x,
const Vector1& b,
286 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
287 int TfQmr(
const Matrix1& A, Vector1& x,
const Vector1& b,
294 #define SELDON_FILE_ITERATIVE_HXX
int parameter_restart
restart parameter (for Gmres and Gcr)
Preconditioner_Base()
Default constructor.
bool First() const
Returns true if it is the first iteration.
int max_iter
maximum number of iterations
int GetNumberIteration() const
Returns the number of iterations.
int GetRestart() const
Returns the restart parameter.
int QCgs(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &iter)
Solves linear system using Quasi-minimized Conjugate Gradient Squared.
Titer GetTolerance() const
Returns stopping criterion.
int TfQmr(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &iter)
Solves a linear system by using Transpose Free Quasi-Minimal Residual.
bool fail_convergence
true if the iterative solver has converged print level
int Cgs(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &iter)
Solves linear system using Conjugate Gradient Squared (CGS)
int type_solver
iterative solver used
int GetTypeSolver() const
Returns the type of solver.
void SaveFullHistory(const string &file)
History of residuals is printed in a file.
void SetMaxNumberIteration(int max_iteration)
Changes the maximum number of iterations.
int Init(const Vector1 &r)
Initialization with the right hand side.
Iteration & operator++(void)
Increment the number of iterations.
void Mlt(const Matrix1 &A, const Vector1 &x, Vector1 &y)
Computes y = A x.
int Cg(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &iter)
Solves a linear system by using Conjugate Gradient (CG)
void ShowMessages()
Sets to a normal display (residual each 100 iterations)
int ErrorCode()
Returns the error code (if an error occured)
int BiCgcr(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &iter)
Solves a linear system by using BiCgCr.
Iteration()
Default constructor.
void ShowFullHistory()
Sets to a complete display (residual each iteration)
int Gmres(const MatrixSparse &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &outer)
Solves a linear system by using Generalized Minimum Residual (GMRES)
Titer GetFactor() const
Returns used coefficient to compute relative residual.
Titer tolerance
stopping criterion
void Fail(int i, const string &s)
Informs of a failure in the iterative solver.
int MinRes(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &iter)
Solves a linear system by using Minimum Residual (MinRes)
int error_code
error code returned by iterative solver
int nb_iter
number of iterations
bool init_guess_null
true if initial guess is null
void MltAdd(const T1 &alpha, const Matrix1 &A, const Vector1 &x, const T1 &beta, Vector1 &y)
Computes y = beta y + alpha A x.
int Cgne(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &iter)
Solves a linear system using Conjugate Gradient Normal Equation (CGNE)
int Symmlq(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &iter)
Solves a linear system by using Symmetric LQ (SymmLQ)
void SetTolerance(Titer stopping_criterion)
Changes the stopping criterion.
void TransSolve(const Matrix1 &A, const Vector1 &r, Vector1 &z)
Solves M^t z = r.
Titer facteur_reste
inverse of norm of first residual
void SetNumberIteration(int nb)
Changes the number of iterations.
int CoCg(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &iter)
Solves a linear system by using Conjugate Orthogonal Conjugate Gradient.
int Qmr(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &iter)
Solves a linear system by using Quasi-Minimal Residual (QMR)
int Lsqr(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &iter)
Solves a linear system by using Least Squares (LSQR)
int BiCg(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &iter)
Solves a linear system by using BiConjugate Gradient (BICG)
int type_preconditioning
preconditioner used
int QmrSym(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &iter)
Solves linear system using Symmetric Quasi-Minimal Residual (SQMR)
Class containing parameters for an iterative resolution.
int BiCgStabl(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &iter)
Implements BiConjugate Gradient Stabilized (BICG-STAB(l))
bool IsInitGuess_Null() const
Returns true if the initial guess is null.
int Gcr(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &outer)
Solves a linear system by using Generalized Conjugate Residual (GCR)
void Solve(const Matrix1 &A, const Vector1 &r, Vector1 &z)
Solves M z = r.
void SetSolver(int type_resolution, int param_restart, int type_prec)
Changes the type of solver and preconditioning.
void SetRestart(int m)
Changes the restart parameter.
void HideMessages()
Doesn't display any information.
Abstract base class for all matrices.
bool Finished(const Vector1 &r) const
Returns true if the iterative solver has reached its end.
Base class for preconditioners.
int BiCgStab(const Matrix1 &A, Vector1 &x, const Vector1 &b, Preconditioner &M, Iteration< Titer > &iter)
Implements BiConjugate Gradient Stabilized (BICG-STAB)
void SetInitGuess(bool type)
informs if the initial guess is null