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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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:
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:
which looks more like |Ax-b|² / |b|² < tol².
Are the docs wrong or am i missing sth?
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
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 :)
ok, great - you're welcome :-)