Skip to content

Commit 81b8a5b

Browse files
committed
Fix h2syn, added simple test
Similar fix to hinfsyn: np -> np_, and identical test.
1 parent 75ffa49 commit 81b8a5b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

control/robust.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def h2syn(P,nmeas,ncon):
9090

9191
n = np.size(P.A,0)
9292
m = np.size(P.B,1)
93-
np = np.size(P.C,0)
94-
out = sb10hd(n,m,np,ncon,nmeas,P.A,P.B,P.C,P.D)
93+
np_ = np.size(P.C,0)
94+
out = sb10hd(n,m,np_,ncon,nmeas,P.A,P.B,P.C,P.D)
9595
Ak = out[0]
9696
Bk = out[1]
9797
Ck = out[2]

control/tests/robust_test.py

+15
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ def testHinfsyn(self):
2626

2727
# TODO: add more interesting examples
2828

29+
class TestH2(unittest.TestCase):
30+
@unittest.skipIf(not slycot_check(), "slycot not installed")
31+
def testH2syn(self):
32+
"Test h2syn"
33+
p = control.ss(-1, [1, 1], [[1], [1]], [[0, 1], [1, 0]])
34+
k = control.robust.h2syn(p, 1, 1)
35+
# from Octave, which also uses SB10HD for H-2 synthesis:
36+
# a= -1; b1= 1; b2= 1; c1= 1; c2= 1; d11= 0; d12= 1; d21= 1; d22= 0;
37+
# g = ss(a,[b1,b2],[c1;c2],[d11,d12;d21,d22]);
38+
# k = h2syn(g,1,1);
39+
# the solution is the same as for the hinfsyn test
40+
np.testing.assert_array_almost_equal(k.A, [[-3]])
41+
np.testing.assert_array_almost_equal(k.B, [[1]])
42+
np.testing.assert_array_almost_equal(k.C, [[-1]])
43+
np.testing.assert_array_almost_equal(k.D, [[0]])
2944

3045
if __name__ == "__main__":
3146
unittest.main()

0 commit comments

Comments
 (0)