|
From: Scott C. L. <no...@gi...> - 2026-08-14 06:32:27
|
Branch: refs/heads/main Home: https://github.com/python-control/python-control Commit: 46081238fa775efcaf67816379112cf4b711dc0d https://github.com/python-control/python-control/commit/46081238fa775efcaf67816379112cf4b711dc0d Author: Kangwon Lee <219...@us...> Date: 2026-08-13 (Thu, 13 Aug 2026) Changed paths: M control/mateqn.py M control/tests/mateqn_test.py Log Message: ----------- Add scipy fallbacks for generalized Lyapunov and discrete Sylvester equations lyap and dlyap previously raised ControlArgument for method='scipy' (explicit, or auto-selected when slycot is absent) on three cases that SLICOT handles. Add pure scipy/numpy fallbacks for all three: - Generalized Lyapunov, continuous and discrete (E != I): congruence transform by inv(E) to a standard Lyapunov equation, then scipy's solve_continuous/discrete_lyapunov. Requires E nonsingular; SLICOT sg03ad (Penzl's generalized Schur method) also handles singular E and remains the method='slycot' path. A nonsingular-E failure raises a clear ControlArgument. Because the transform inverts E, an ill-conditioned E yields reduced accuracy; this now emits a UserWarning recommending method='slycot' (the continuous path was previously silent, while the discrete path warned only incidentally). - Discrete Sylvester (A X Q^T - X + C = 0): Bartels-Stewart method via complex Schur factors of A and Q^T with column-by-column triangular solves, O(n^3 + m^3), matching the Hessenberg-Schur cost of SLICOT sb04qd. Includes the solvability check that no eigenvalue pair of A and Q^T has product (almost) equal to 1. Also fix two incorrect slycot import-fallback aliases (sb0qmd -> sb04qd, sb04ad -> sg03ad) so the names resolve to None, not NameError, when slycot is absent; and correct the dlyap Notes, which described the scipy Sylvester path as a Kronecker O((nm)^3) solve (it is now Bartels-Stewart, O(n^3 + m^3)). Tests parametrize method=[None, 'scipy', 'slycot'] and cross-check that the scipy and slycot solutions agree, and cover the nonsingular-E requirement, the ill-conditioned-E warning, and the singular discrete-Sylvester case. Co-Authored-By: Claude Fable 5 <no...@an...> Co-Authored-By: Claude Opus 4.8 <no...@an...> Commit: 89b2f686c1d504c8fb0c480d629e143514883f65 https://github.com/python-control/python-control/commit/89b2f686c1d504c8fb0c480d629e143514883f65 Author: Kangwon Lee <219...@us...> Date: 2026-08-13 (Thu, 13 Aug 2026) Changed paths: M control/mateqn.py Log Message: ----------- Correct SG03AD singular-E claim in lyap/dlyap docs The generalized-Lyapunov Notes, the scipy-path comments, and the nonsingular-E error messages stated that SLICOT SG03AD "also handles singular E". It does not: SG03AD factors the matrix pencil without inverting E (its advantage for a nonsingular but ill-conditioned E), but a truly singular (descriptor) E returns a degenerate-pair warning and is out of scope for both the scipy and slycot paths. Correct all six spots (continuous lyap and discrete dlyap) to say so. Co-Authored-By: Claude Opus 4.8 <no...@an...> Commit: 3f6dbac2a4793b8bad535cfe16321acaf72f35eb https://github.com/python-control/python-control/commit/3f6dbac2a4793b8bad535cfe16321acaf72f35eb Author: Kangwon Lee <219...@us...> Date: 2026-08-13 (Thu, 13 Aug 2026) Changed paths: M control/mateqn.py Log Message: ----------- Correct ill-conditioned-E accuracy claim in lyap/dlyap The generalized-Lyapunov Notes and the _warn_ill_conditioned_E helper (its docstring and warning message) claimed method='slycot' is "preferable" / "more robust" than method='scipy' for ill-conditioned E. Benchmarking (scipy vs slycot, n=100, cond(E) swept 1 to 1e12 over 5 seeds) shows both methods lose accuracy at the same rate -- slycot is in fact 1.3-2x *less* accurate for cond(E) >= 1e4, never better. The generalized Lyapunov problem is itself ill-conditioned (about cond(E)^2) when E is, so no method beats that floor. Reword to say both degrade and slycot is not measurably more accurate, and drop the false "use method='slycot' for a more robust solution" line from the warning. Co-Authored-By: Claude Opus 4.8 <no...@an...> Commit: 2dabe33ccd4b9b9f3cf8fc54837fc183b09b86a4 https://github.com/python-control/python-control/commit/2dabe33ccd4b9b9f3cf8fc54837fc183b09b86a4 Author: Kangwon Lee <219...@us...> Date: 2026-08-13 (Thu, 13 Aug 2026) Changed paths: A benchmarks/scipy_fallback_bench.py Log Message: ----------- Add benchmarks for scipy vs slycot matrix-equation fallbacks Add benchmarks/scipy_fallback_bench.py (asv) comparing the pure-scipy fallbacks with slycot for generalized Lyapunov (continuous and discrete) and discrete Sylvester, plus an accuracy-vs-cond(E) track for the generalized Lyapunov solution. slycot parameterizations are skipped when slycot is not installed. Requested in the PR #1234 review. Co-Authored-By: Claude Opus 4.8 <no...@an...> Commit: a7754794dcc9d3ef2060cc1b2486bd42b73395cc https://github.com/python-control/python-control/commit/a7754794dcc9d3ef2060cc1b2486bd42b73395cc Author: Scott C. Livingston <sli...@cd...> Date: 2026-08-13 (Thu, 13 Aug 2026) Changed paths: A benchmarks/scipy_fallback_bench.py M control/mateqn.py M control/tests/mateqn_test.py Log Message: ----------- Merge pull request #1234 from @kangwonlee Add scipy fallbacks for generalized Lyapunov and discrete Sylvester equations Compare: https://github.com/python-control/python-control/compare/c7ea9c92915c...a7754794dcc9 To unsubscribe from these emails, change your notification settings at https://github.com/python-control/python-control/settings/notifications |