38 #ifndef GMM_LEAST_SQUARES_CG_H__ 39 #define GMM_LEAST_SQUARES_CG_H__ 47 template <
typename Matrix,
typename Vector1,
typename Vector2>
48 void least_squares_cg(
const Matrix& C, Vector1& x,
const Vector2& y,
51 typedef typename temporary_dense_vector<Vector1>::vector_type temp_vector;
52 typedef typename linalg_traits<Vector1>::value_type T;
55 temp_vector p(vect_size(x)), q(vect_size(y)), g(vect_size(x));
56 temp_vector r(vect_size(y));
57 iter.set_rhsnorm(gmm::sqrt(gmm::abs(
vect_hp(y, y))));
59 if (iter.get_rhsnorm() == 0.0)
62 mult(C, scaled(x, T(-1)), y, r);
67 while (!iter.finished_vect(g)) {
71 add(g, scaled(p, rho / rho_1), p);
78 add(scaled(q, -a), r);
88 template <
typename Matrix,
typename Precond,
89 typename Vector1,
typename Vector2>
inline 90 void least_squares_cg(
const Matrix& C,
const Vector1& x,
const Vector2& y,
92 { least_squares_cg(C, linalg_const_cast(x), y, iter); }
96 #endif // GMM_SOLVER_CG_H__ handle conjugation of complex matrices/vectors.
conjugated_return< L >::return_type conjugated(const L &v)
return a conjugated view of the input matrix or vector.
void copy(const L1 &l1, L2 &l2)
*/
Include the base gmm files.
void clear(L &l)
clear (fill with zeros) a vector or matrix.
strongest_value_type< V1, V2 >::value_type vect_hp(const V1 &v1, const V2 &v2)
*/
void add(const L1 &l1, L2 &l2)
*/