Skip to content

Commit 2443fb9

Browse files
jamestjspclaude
andcommitted
Fix tb01pd wrapper for pre-padded arrays
Extract actual-sized submatrices using n,m,p params before calling slicot tb01pd, which infers dimensions from array shapes. Fixes jamestjsp/ctrlsys#12 Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 674f2e8 commit 2443fb9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

control/slicot_compat.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,9 +811,10 @@ def tb01pd(n, m, p, A, B, C, job='M', equil='S', tol=0.0, ldwork=None):
811811
"""
812812
from slicot import tb01pd as _tb01pd
813813

814-
A_copy = np.asfortranarray(A.copy())
815-
B_copy = np.asfortranarray(B.copy())
816-
C_copy = np.asfortranarray(C.copy())
814+
# Extract actual-sized arrays (caller may pass pre-padded arrays)
815+
A_copy = np.asfortranarray(A[:n, :n].copy())
816+
B_copy = np.asfortranarray(B[:n, :m].copy())
817+
C_copy = np.asfortranarray(C[:p, :n].copy())
817818

818819
if tol is None:
819820
tol = 0.0

control/tests/minreal_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ def testMinrealBrute(self):
7979
# Find the closest zero
8080
assert min(abs(z1 - z)) <= 1e-7
8181

82-
# Verify expected reductions occur (seed=5 yields 2 reducible systems)
82+
# Make sure that the number of systems reduced is as expected
83+
# (Need to update this number if you change the seed at top of file)
8384
assert nreductions == 2
8485

8586
def testMinrealSS(self):

0 commit comments

Comments
 (0)