Let the caller set the iteration budget on the three doubling solvers #300 - #349
Open
nleonh wants to merge 2 commits into
Open
Let the caller set the iteration budget on the three doubling solvers #300#349nleonh wants to merge 2 commits into
nleonh wants to merge 2 commits into
Conversation
… (issue 300)
Add solve_discrete_riccati_with_budget to specify a custom budget
Add doctest for solve_discrete_riccati_with_budget
Add solve_discrete_lyapunov_with_budget to allow overwriting the default budget
* solve_discrete_lyapunov just invokes solve_discrete_lyapunov_with_budget with the default budget
* Added doctest
add budget option to eigendecomposition
Add new doctest to symmetric_eigendecomposition_with_budget
* Test how the maximum number of sweeps ("budget") affects the accuracy of the resulting eigenvalues
* Use a diferent matrix than symmetric_eigendecomposition
improve documentation of solve_discrete_lyapunov and solve_discrete_lyapunov_with_budget
fixed clippy warnings
(unnecessary returns in one-line functions)
kmolan
reviewed
Sep 13, 2026
| /// assert!((worse_values[1] - correct_eigvalds[1]).abs() > 1e-9); | ||
| /// assert!((worse_values[2] - correct_eigvalds[2]).abs() > 1e-9); | ||
| /// ``` | ||
| pub fn symmetric_eigendecomposition_with_budget( |
Owner
There was a problem hiding this comment.
unlike the _with_budget() counterparts of the other two, this one does not cleanly exit upon non-convergence. It runs for _ in 0..max_sweeps, then unconditionally reads the diagonal as the eigenvalues. There's no DidNotConverge on that path at all. With 60 sweeps hardcoded that never mattered, but now it does.
kmolan
requested changes
Sep 13, 2026
kmolan
left a comment
Owner
There was a problem hiding this comment.
- Please also add tests for the newly added functions
lib.rsre-exportssolve_discrete_lyapunov,solve_discrete_riccatiat the crate root, but the new_with_budgetvariants weren't added there
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Fixes issue #300.
Allow users to specify a budget (number of passes/sweeps) when using
solve_discrete_riccati,solve_discrete_lyapunov,symmetric_eigendecomposition. In order to not break any existing project using this API, I have added functionssolve_discrete_riccati_with_budget,solve_discrete_lyapunov_with_budget,symmetric_eigendecomposition_with_budget. The old functions just invoke these with the default value (64, 64, 60). I have added sample code (doctests) that demonstrate how the outcome depends on the budget.I haven't changed the doctests of the functions without
_with_budgetto verify that they're still working.If there's anything wrong, please let me now - I'd be happy to improve the changes.
Checklist
cargo test+cargo clippy --all-targetsclean locallyunwrap/expect/panicon library paths (typed errors instead)