Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error in CG implementation #15

Closed
HuyD24 opened this issue Jul 5, 2023 · 2 comments
Closed

[BUG] Error in CG implementation #15

HuyD24 opened this issue Jul 5, 2023 · 2 comments

Comments

@HuyD24
Copy link

HuyD24 commented Jul 5, 2023

p_new = [rr + beta * pp for rr, pp in zip(r, p)]

I think p_new should be calculated based on r_new instead of r here. In the Wikipedia version (https://en.wikipedia.org/wiki/Conjugate_gradient_method) the corresponding formula is $p_{k+1} = r_{k+1} + \beta_k p_k$ with $r_{k+1}$ corresponding to r_new.

@sangkeun00
Copy link
Contributor

Hello @HuyD24,

Thanks for your interest and pointing out the error in my code. I think you are right, and thus I fixed the code to use r_new instead of r. When I ran several benchmarks with both r and r_new, I didn't experience any noticeable performance differences, and hope your experiments also didn't get affected by this bug. Let me know if you have other concerns.

Best,
Sang

@sangkeun00
Copy link
Contributor

Closing the issue as the bug is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants