21 #ifndef SELDON_FILE_ITERATIVE_BICGSTABL_CXX
43 #ifdef SELDON_WITH_VIRTUAL
44 template<
class T,
class Vector1>
45 int BiCgStabl(
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 BiCgStabl(
const Matrix1& A, Vector1& x,
const Vector1& b,
54 const int N = A.GetM();
58 typedef typename Vector1::value_type Complexe;
61 Complexe rho_0, rho_1, alpha, beta, omega, sigma, zero, one;
70 std::vector<Vector1> r(l+1, b), u(l+1, b);
71 for (
int i = 0; i <= l; i++)
77 tau.Fill(zero); gamma.Fill(zero);
78 gamma_prime.Fill(zero); gamma_twice.Fill(zero);
83 iter.
MltAdd(-one, A, x, one, r[0]);
88 int success_init = iter.
Init(b);
89 if (success_init !=0 )
95 rho_0 = one; alpha = zero; omega = one;
105 for (
int j = 0; j < l; j++)
107 rho_1 = DotProd(r[j], r0);
110 iter.
Fail(1,
"Bicgstabl breakdown #1");
113 beta = alpha*(rho_1/rho_0);
115 for (
int i = 0; i <= j; i++)
118 Add(one, r[i], u[i]);
122 iter.
Mlt(A, q, u[j+1]);
125 sigma = DotProd(u[j+1], r0);
128 iter.
Fail(2,
"Bicgstabl Breakdown #2");
133 for (
int i = 0; i <= j; i++)
134 Add(-alpha, u[i+1], r[i]);
137 iter.
Mlt(A, q, r[j+1]);
143 for (
int j = 1; j <= l; j++)
145 for (
int i = 1; i < j; i++)
147 if (gamma(i) != zero)
149 tau(i,j) = DotProd(r[j], r[i])/gamma(i);
150 Add(-tau(i,j), r[i], r[j]);
153 gamma(j) = DotProd(r[j], r[j]);
154 if (gamma(j) != zero)
155 gamma_prime(j) = DotProd(r[0], r[j])/gamma(j);
159 gamma(l) = gamma_prime(l); omega = gamma(l);
160 for (
int j = l-1; j >= 1; j--)
163 for (
int i = j+1; i <= l; i++)
164 sigma += tau(j,i)*gamma(i);
166 gamma(j) = gamma_prime(j)-sigma;
170 for (
int j = 1; j <= l-1; j++)
173 for (
int i = j+1; i <= l-1; i++)
174 sigma += tau(j,i)*gamma(i+1);
176 gamma_twice(j) = gamma(j+1)+sigma;
180 Add(gamma(1), r[0], x);
181 Add(-gamma_prime(l), r[l], r[0]);
182 Add(-gamma(l), u[l], u[0]);
183 for (
int j = 1;j <= l-1; j++)
185 Add(-gamma(j), u[j], u[0]);
186 Add(gamma_twice(j), r[j], x);
187 Add(-gamma_prime(j), r[j], r[0]);
191 Copy(x,q); M.Solve(A, q, x);
197 #define SELDON_FILE_ITERATIVE_BICGSTABL_CXX