The CG solver provided with ViennaCL works without issue for negative definite left hand sides. When provided with the Jacobi preconditioner, however, the CG solver immediately returns a solution of 0 if the left hand side is negative definite. Adding an absolute value to the variable norm_rhs_squared on line 286 of http://viennacl.sourceforge.net/doc/cg_8hpp_source.html seems to resolve the issue, in my tests.
While I have of course modified the code on my side to provide a positive definite matrix, other CG implementations (including the one provided with Eigen with a Jacobi preconditioner) work fine if all eigenvalues are negative.
Is the intended behavior to return a solution of 0? Is this fix sufficient?
Thank you!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The CG solver provided with ViennaCL works without issue for negative definite left hand sides. When provided with the Jacobi preconditioner, however, the CG solver immediately returns a solution of 0 if the left hand side is negative definite. Adding an absolute value to the variable norm_rhs_squared on line 286 of http://viennacl.sourceforge.net/doc/cg_8hpp_source.html seems to resolve the issue, in my tests.
While I have of course modified the code on my side to provide a positive definite matrix, other CG implementations (including the one provided with Eigen with a Jacobi preconditioner) work fine if all eigenvalues are negative.
Is the intended behavior to return a solution of 0? Is this fix sufficient?
Thank you!
Thanks for reporting this issue, Breannan! I agree that this is a bug. It is now fixed in the developer repository: https://github.com/viennacl/viennacl-dev/commit/0d1b0979f808b8425b3faa6e96a7aa26998eaf71
Thanks again and best regards,
Karli