Skip to content

Fix isstable for discrete Dual state-space to check eigenvalues#1057

Merged
baggepinnen merged 1 commit into
masterfrom
fix/isstable-dual-discrete
May 16, 2026
Merged

Fix isstable for discrete Dual state-space to check eigenvalues#1057
baggepinnen merged 1 commit into
masterfrom
fix/isstable-dual-discrete

Conversation

@baggepinnen
Copy link
Copy Markdown
Member

Summary

The isstable specialization for StateSpace{<:Discrete, <:ForwardDiff.Dual} checked |A[i,j]| < 1 element-wise rather than |λ(A)| < 1. This is unrelated to discrete-time stability.

Example counter-example before the fix:

A = 0.9 * ones(2,2)   # entries all < 1
# eigenvalues: 0.0, 1.8 → not stable, but old code returned true

The continuous-time Dual specialization immediately above already uses eigvals correctly; this aligns the discrete one with it.

Test plan

  • Construct a discrete Dual state-space with entries < 1 but spectral radius > 1, confirm isstable returns false.
  • Existing tests still pass.

🤖 Generated with Claude Code

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) <noreply@anthropic.com>
@JuliaControlBot
Copy link
Copy Markdown

This is an automated message.
Plots were compared to references. 4/11 images have changed, see differences below.
After pulling this PR, please update the reference images by creating a PR to ControlExamplePlots.jl here.

Difference Reference Image New Image
✔️ 0.0 Reference New
✔️ 0.0 Reference New
✔️ 0.0 Reference New
✔️ 0.0 Reference New

@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.61%. Comparing base (0aa6e4c) to head (68a593a).

Files with missing lines Patch % Lines
lib/ControlSystemsBase/src/types/StateSpace.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1057   +/-   ##
=======================================
  Coverage   91.61%   91.61%           
=======================================
  Files          42       42           
  Lines        5653     5653           
=======================================
  Hits         5179     5179           
  Misses        474      474           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@baggepinnen baggepinnen merged commit f3c1dec into master May 16, 2026
5 of 6 checks passed
@baggepinnen baggepinnen deleted the fix/isstable-dual-discrete branch May 16, 2026 03:58
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.

2 participants