@@ -449,7 +449,7 @@ def empty(shape):
449449 np .testing .assert_array_equal (D , g .D )
450450
451451 def test_lft (self ):
452- """ compare lft function with matlab implementation"""
452+ """ test lft function with result obtained from matlab implementation"""
453453 # test case
454454 A = [[1 , 2 , 3 ],
455455 [1 , 4 , 5 ],
@@ -473,17 +473,28 @@ def test_lft(self):
473473 Dk = [[0 , 2 ],
474474 [0 , 0 ]]
475475 K = StateSpace (Ak , Bk , Ck , Dk )
476- pk = P .lft (K , 2 , 1 )
477476
478- # correct result (from matlab)
479- Ak = [1 , 2 , 3 , 4 , 6 , 12 , 1 , 4 , 5 , 17 , 38 , 61 , 2 , 3 , 4 , 9 , 26 , 37 , 2 , 3 , 0 , 3 , 14 , 18 , 4 , 6 , 0 , 8 , 27 , 35 , 18 , 27 , 0 , 29 , 109 , 144 ]
480- Bk = [0 , 10 , 10 , 7 , 15 , 58 ]
481- Ck = [1 , 4 , 5 , 0 , 0 , 0 ]
482- Dk = [0 ]
483- np .testing .assert_allclose (np .flatten (pk .A ), Ak )
484- np .testing .assert_allclose (np .flatten (pk .B ), Bk )
485- np .testing .assert_allclose (np .flatten (pk .C ), Ck )
486- np .testing .assert_allclose (np .flatten (pk .D ), Dk )
477+ # case 1
478+ pk = P .lft (K , 2 , 1 )
479+ Amatlab = [1 , 2 , 3 , 4 , 6 , 12 , 1 , 4 , 5 , 17 , 38 , 61 , 2 , 3 , 4 , 9 , 26 , 37 , 2 , 3 , 0 , 3 , 14 , 18 , 4 , 6 , 0 , 8 , 27 , 35 , 18 , 27 , 0 , 29 , 109 , 144 ]
480+ Bmatlab = [0 , 10 , 10 , 7 , 15 , 58 ]
481+ Cmatlab = [1 , 4 , 5 , 0 , 0 , 0 ]
482+ Dmatlab = [0 ]
483+ np .testing .assert_allclose (np .array (pk .A ).reshape (- 1 ), Amatlab )
484+ np .testing .assert_allclose (np .array (pk .B ).reshape (- 1 ), Bmatlab )
485+ np .testing .assert_allclose (np .array (pk .C ).reshape (- 1 ), Cmatlab )
486+ np .testing .assert_allclose (np .array (pk .D ).reshape (- 1 ), Dmatlab )
487+
488+ # case 2
489+ pk = P .lft (K )
490+ Amatlab = [1 , 2 , 3 , 4 , 6 , 12 , - 3 , - 2 , 5 , 11 , 14 , 31 , - 2 , - 3 , 4 , 3 , 2 , 7 , 0.6 , 3.4 , 5 , - 0.6 , - 0.4 , 0 , 0.8 , 6.2 , 10 , 0.2 , - 4.2 , - 4 , 7.4 , 33.6 , 45 , - 0.4 , - 8.6 , - 3 ]
491+ Bmatlab = []
492+ Cmatlab = []
493+ Dmatlab = []
494+ np .testing .assert_allclose (np .array (pk .A ).reshape (- 1 ), Amatlab )
495+ np .testing .assert_allclose (np .array (pk .B ).reshape (- 1 ), Bmatlab )
496+ np .testing .assert_allclose (np .array (pk .C ).reshape (- 1 ), Cmatlab )
497+ np .testing .assert_allclose (np .array (pk .D ).reshape (- 1 ), Dmatlab )
487498
488499class TestRss (unittest .TestCase ):
489500 """These are tests for the proper functionality of statesp.rss."""
0 commit comments