From 68a593ada3989c301ff2b7d8a0f471ac66e04aa4 Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Fri, 15 May 2026 19:34:44 +0200 Subject: [PATCH] Fix isstable for discrete Dual state-space to check eigenvalues The discrete `ForwardDiff.Dual` specialization of `isstable` compared the magnitudes of `A`'s entries against 1 instead of the magnitudes of its eigenvalues, which is unrelated to discrete-time stability. For example, `A = 0.9*ones(2,2)` has all entries below 1 but eigenvalue 1.8. Now mirrors the continuous-time `ForwardDiff.Dual` specialization on the line above and uses `eigvals` to evaluate the stability criterion. Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/ControlSystemsBase/src/types/StateSpace.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ControlSystemsBase/src/types/StateSpace.jl b/lib/ControlSystemsBase/src/types/StateSpace.jl index ae37a2b33..83b6671a7 100644 --- a/lib/ControlSystemsBase/src/types/StateSpace.jl +++ b/lib/ControlSystemsBase/src/types/StateSpace.jl @@ -233,7 +233,7 @@ function isstable(sys::StateSpace{Continuous, <:ForwardDiff.Dual}) all(real.(eigvals(ForwardDiff.value.(sys.A))) .< 0) end function isstable(sys::StateSpace{<:Discrete, <:ForwardDiff.Dual}) - all(abs.(ForwardDiff.value.(sys.A)) .< 1) + all(abs.(eigvals(ForwardDiff.value.(sys.A))) .< 1) end isrational(::AbstractStateSpace) = true