20 #ifndef SELDON_FILE_ITERATIVE_COCG_CXX
44 #ifdef SELDON_WITH_VIRTUAL
45 template<
class T,
class Vector1>
46 int CoCg(
const VirtualMatrix<T>& A, Vector1& x,
const Vector1& b,
47 Preconditioner_Base<T>& M,
48 Iteration<
typename ClassComplexType<T>::Treal>& iter)
50 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
51 int CoCg(
const Matrix1& A, Vector1& x,
const Vector1& b,
55 const int N = A.GetM();
59 typedef typename Vector1::value_type Complexe;
60 Complexe rho, rho_1, alpha, beta, delta;
67 Vector1 p(b), q(b), r(b), z(b);
68 p.Fill(zero); q.Fill(zero); r.Fill(zero); z.Fill(zero);
72 int success_init = iter.
Init(b);
73 if (success_init != 0)
78 iter.
MltAdd(-one, A, x, one, r);
95 iter.
Fail(1,
"Cocg breakdown #1");
111 delta = DotProd(p, q);
114 iter.
Fail(2,
"Cocg breakdown #2");
132 #define SELDON_FILE_ITERATIVE_COCG_CXX
bool First() const
Returns true if it is the first iteration.
int Init(const Vector1 &r)
Initialization with the right hand side.
void Mlt(const Matrix1 &A, const Vector1 &x, Vector1 &y)
Computes y = A x.
int ErrorCode()
Returns the error code (if an error occured)
void Fail(int i, const string &s)
Informs of a failure in the iterative solver.
void MltAdd(const T1 &alpha, const Matrix1 &A, const Vector1 &x, const T1 &beta, Vector1 &y)
Computes y = beta y + alpha A x.
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.
Class containing parameters for an iterative resolution.
bool IsInitGuess_Null() const
Returns true if the initial guess is null.
bool Finished(const Vector1 &r) const
Returns true if the iterative solver has reached its end.