Skip to content

Stop ConjugateGradientSolver from inverting A on every solve - #32

Merged
barrybecker4 merged 1 commit into
masterfrom
cursor/conjugate-gradient-no-invert-4157
Nov 8, 2026
Merged

barrybecker4 merged 1 commit into
masterfrom
cursor/conjugate-gradient-no-invert-4157

Conversation

@barrybecker4

Copy link
Copy Markdown
Member

Fixes #13

ConjugateGradientSolver.solve no longer builds a full inverse of A to measure convergence. It stops when the residual norm ||r|| falls below eps, which keeps each iteration to matrix–vector products instead of an O(n³) invert.

The default iteration limit is now 2 * n for an n × n system (still overridable with setMaxIterations), so classic CG can finish larger SPD problems that previously hit the hard cap of 8. Existing mismatch-size and low-max-iteration tests are unchanged; a 12×12 diagonal SPD case covers the new residual / default-limit behavior.

Open in Web Open in Cursor 

…verse

Stop measuring convergence with an A^{-1}-based residual that required a
full invert on every solve. Use ||r|| against eps, and default maxIterations
to 2*n so larger SPD systems can finish.

Co-authored-by: Barry G Becker <barrybecker4@yahoo.com>
@barrybecker4
barrybecker4 merged commit bbca107 into master Nov 8, 2026
1 check passed
@barrybecker4
barrybecker4 deleted the cursor/conjugate-gradient-no-invert-4157 branch November 8, 2026 14:40
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

Successfully merging this pull request may close these issues.

ConjugateGradientSolver inverts the full matrix on every solve

2 participants