Menu

Incorrect tolerance in pCG docs?

Thomas
2013-04-24
2013-06-12
  • Thomas

    Thomas - 2013-04-24

    I have used the viennacl preconditioned CG solver (with OpenCL) and i wondered how the tolerance value defined by the cg_tag is handled?

    From the docs of the cg_tag class http://viennacl.sourceforge.net/doc/classviennacl_1_1linalg_1_1cg__tag.html i have:

    tol: Relative tolerance for the residual (solver quits if ||r|| < tol * ||r_initial||)

    For solving Ax=b i would assume that means |(Ax_i -b)| / |(Ax_0 - b)| <tol, where x_0 is the start value and x_i the current iteration value of x. However in cg.hpp i have seen:

            
    new_ipp_rr_over_norm_rhs = new_ip_rr / norm_rhs_squared;
    if (std::fabs(new_ipp_rr_over_norm_rhs) < tag.tolerance() *  tag.tolerance())    //squared norms involved here
              break;
    

    which looks more like |Ax-b|² / |b|² < tol².

    Are the docs wrong or am i missing sth?

     
  • Karl Rupp

    Karl Rupp - 2013-04-24

    Hi,

    since x_0 is always taken to be the all-zero-guess, Ax_0 vanishes and hence the two expressions are indeed the same.
    Note that any nonzero initial guess y can be incorporated into a solution for z as
    Az = b,      z = y + x,   y given
    Ax = b - Ay
    Ax = b*     with b* = b - Ay.

    Best regards,
    Karli

     
  • Thomas

    Thomas - 2013-04-24

    Hi Karli, thanks for clarification - that makes perfect sense.
    I thought I had used solveWithGuess(…), but it seems i confused that with eigen…

    All questions resolved :)

     
  • Karl Rupp

    Karl Rupp - 2013-04-24

    ok, great - you're welcome :-)

     

Log in to post a comment.