20 #ifndef SELDON_FILE_ITERATIVE_LSQR_CXX
40 #ifdef SELDON_WITH_VIRTUAL
41 template<
class T,
class Vector1>
42 int Lsqr(
const VirtualMatrix<T>& A, Vector1& x,
const Vector1& b,
43 Preconditioner_Base<T>& M,
44 Iteration<
typename ClassComplexType<T>::Treal>& iter)
46 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
47 int Lsqr(
const Matrix1& A, Vector1& x,
const Vector1& b,
51 const int N = A.GetM();
55 typedef typename Vector1::value_type Complexe;
56 Complexe rho, rho_bar, phi, phi_bar, theta, c, s, tmp;
57 typename ClassComplexType<Complexe>::Treal beta, alpha, rnorm;
58 Vector1 v(b), v1(b), u(b), u1(b), w(b);
63 int success_init = iter.
Init(b);
64 if (success_init != 0)
69 iter.
MltAdd(-one, A, x, one, u);
77 tmp = one/beta; Mlt(tmp, u);
79 iter.
Mlt(SeldonTrans, A, u, v);
81 tmp = one/alpha; Mlt(tmp, v);
83 Copy(v, w); x.Fill(zero);
85 phi_bar = beta; rho_bar = alpha;
98 iter.
Fail(1,
"Lsqr breakdown #1");
101 tmp = one/beta; Mlt(tmp, u1);
104 iter.
Mlt(SeldonTrans, A, u1, v1);
110 iter.
Fail(2,
"Lsqr breakdown #2");
113 tmp = one/alpha; Mlt(tmp, v1);
115 rho = sqrt(rho_bar*rho_bar+beta*beta);
118 iter.
Fail(3,
"Lsqr breakdown #3");
125 rho_bar = -c * alpha;
127 phi_bar = s * phi_bar;
137 rnorm = abs(phi_bar);
150 #define SELDON_FILE_ITERATIVE_LSQR_CXX