20 #ifndef SELDON_FILE_ITERATIVE_CGNE_CXX
43 #ifdef SELDON_WITH_VIRTUAL
44 template<
class T,
class Vector1>
45 int Cgne(
const VirtualMatrix<T>& A, Vector1& x,
const Vector1& b,
46 Preconditioner_Base<T>& M,
47 Iteration<
typename ClassComplexType<T>::Treal>& iter)
49 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
50 int Cgne(
const Matrix1& A, Vector1& x,
const Vector1& b,
54 const int N = A.GetM();
58 typedef typename Vector1::value_type Complexe;
59 Complexe rho, rho_1, alpha, beta, delta;
60 Vector1 p(b), q(b), r(b), z(b);
64 rho = one; rho_1 = zero;
73 iter.
MltAdd(-one, A, x, one, r);
77 iter.
Mlt(SeldonTrans, A, r, q);
81 int success_init = iter.
Init(q);
82 if (success_init != 0)
90 M.TransSolve(A, r, q);
96 iter.
Fail(1,
"Cgne breakdown #1");
111 iter.
Mlt(SeldonTrans, A, q, z);
113 delta = DotProd(p, z);
116 iter.
Fail(2,
"Cgne breakdown #2");
137 #define SELDON_FILE_ITERATIVE_CGNE_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.
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)
void SetNumberIteration(int nb)
Changes the number of iterations.
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.