|
1 | | -# =================================================== |
2 | | -# ag08bd tests |
| 1 | +"""Verify ag08bd with input parameters according to example in documentation.""" |
3 | 2 |
|
4 | | -import unittest |
5 | | -from slycot import analysis |
6 | 3 | import numpy as np |
7 | | - |
8 | 4 | from numpy.testing import assert_almost_equal, assert_equal |
9 | 5 |
|
| 6 | +from slycot import analysis |
| 7 | + |
10 | 8 | # test1 input parameters |
11 | 9 |
|
12 | 10 | test1_l = 9 |
|
47 | 45 | [ 0, 0, 0]]) |
48 | 46 |
|
49 | 47 |
|
50 | | -class test_ag08bd(unittest.TestCase): |
51 | | - """Verify ag08bd with input parameters according to example in documentation.""" |
52 | | - |
53 | | - def test1_ag08bd(self): |
54 | | - """test [A-lambda*E] |
55 | | -
|
56 | | - B,C,D must have correct dimensions according to l,n,m and p, but cannot |
57 | | - have zero length in any dimenstion. Then the wrapper will complain. |
58 | | - The length is then set to one. |
59 | | - """ |
60 | | - |
61 | | - Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=0,p=0,A=test1_A,E=test1_E,B=np.zeros((test1_l,1)),C=np.zeros((1,test1_n)),D=np.zeros((1,1)),equil=test1_equil, tol=test1_tol) |
62 | | - |
63 | | - assert_equal(Af, np.zeros((0,0))) |
64 | | - assert_equal(Ef, np.zeros((0,0))) |
65 | | - assert_equal(nrank, 9) |
66 | | - assert_equal(niz, 6) |
67 | | - assert_equal(infz, [0,3]) |
68 | | - assert_equal(kronr, []) |
69 | | - assert_equal(infe, [3,3,3]) |
70 | | - assert_equal(kronl, []) |
71 | | - |
72 | | - def test2_ag08bd(self): |
73 | | - """test [A-lambda*E;C] |
74 | | -
|
75 | | - B,D must have correct dimensions as before |
76 | | - """ |
77 | | - |
78 | | - Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=0,p=test1_p,A=test1_A,E=test1_E,B=np.zeros((test1_l,1)),C=test1_C,D=np.zeros((test1_p,1)),equil=test1_equil, tol=test1_tol) |
79 | | - |
80 | | - assert_equal(Af, np.zeros((0,0))) |
81 | | - assert_equal(Ef, np.zeros((0,0))) |
82 | | - assert_equal(nrank, 9) |
83 | | - assert_equal(niz, 4) |
84 | | - assert_equal(infz, [0,2]) |
85 | | - assert_equal(kronr, []) |
86 | | - assert_equal(infe, [1,3,3]) |
87 | | - assert_equal(kronl, [0,1,1]) |
88 | | - |
89 | | - def test3_ag08bd(self): |
90 | | - """test [A-lambda*E,B] |
91 | | -
|
92 | | - C,D must have correct dimensions as before |
93 | | - """ |
94 | | - |
95 | | - Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=test1_m,p=0,A=test1_A,E=test1_E,B=test1_B,C=np.zeros((1,test1_n)),D=np.zeros((1,test1_m)),equil=test1_equil, tol=test1_tol) |
96 | | - |
97 | | - assert_equal(Af, np.zeros((0,0))) |
98 | | - assert_equal(Ef, np.zeros((0,0))) |
99 | | - assert_equal(nrank, 9) |
100 | | - assert_equal(niz, 0) |
101 | | - assert_equal(infz, []) |
102 | | - assert_equal(kronr, [2,2,2]) |
103 | | - assert_equal(infe, [1,1,1]) |
104 | | - assert_equal(kronl, []) |
105 | | - |
106 | | - def test4_ag08bd(self): |
107 | | - """test [A-lambda*E,B;C,D]""" |
108 | | - |
109 | | - Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=test1_m,p=test1_p,A=test1_A,E=test1_E,B=test1_B,C=test1_C,D=test1_D,equil=test1_equil, tol=test1_tol) |
110 | | - |
111 | | - # Af-lambda*Ef==0. => lambda==1. => Finite Smith zero of S(lambda) == 1. |
112 | | - assert Af.shape == (1, 1) |
113 | | - assert_almost_equal(Af, Ef) |
114 | | - assert_equal(nrank, 11) |
115 | | - assert_equal(niz, 2) |
116 | | - assert_equal(infz, [0,1]) |
117 | | - assert_equal(kronr, [2]) |
118 | | - assert_equal(infe, [1,1,1,1,3]) |
119 | | - assert_equal(kronl, [1]) |
120 | | - |
121 | | - |
122 | | -if __name__ == "__main__": |
123 | | - unittest.main() |
| 48 | +def test1_ag08bd(): |
| 49 | + """test [A-lambda*E] |
| 50 | +
|
| 51 | + B,C,D must have correct dimensions according to l,n,m and p, but cannot |
| 52 | + have zero length in any dimenstion. Then the wrapper will complain. |
| 53 | + The length is then set to one. |
| 54 | + """ |
| 55 | + |
| 56 | + Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=0,p=0,A=test1_A,E=test1_E,B=np.zeros((test1_l,1)),C=np.zeros((1,test1_n)),D=np.zeros((1,1)),equil=test1_equil, tol=test1_tol) |
| 57 | + |
| 58 | + assert_equal(Af, np.zeros((0,0))) |
| 59 | + assert_equal(Ef, np.zeros((0,0))) |
| 60 | + assert_equal(nrank, 9) |
| 61 | + assert_equal(niz, 6) |
| 62 | + assert_equal(infz, [0,3]) |
| 63 | + assert_equal(kronr, []) |
| 64 | + assert_equal(infe, [3,3,3]) |
| 65 | + assert_equal(kronl, []) |
| 66 | + |
| 67 | +def test2_ag08bd(): |
| 68 | + """test [A-lambda*E;C] |
| 69 | +
|
| 70 | + B,D must have correct dimensions as before |
| 71 | + """ |
| 72 | + |
| 73 | + Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=0,p=test1_p,A=test1_A,E=test1_E,B=np.zeros((test1_l,1)),C=test1_C,D=np.zeros((test1_p,1)),equil=test1_equil, tol=test1_tol) |
| 74 | + |
| 75 | + assert_equal(Af, np.zeros((0,0))) |
| 76 | + assert_equal(Ef, np.zeros((0,0))) |
| 77 | + assert_equal(nrank, 9) |
| 78 | + assert_equal(niz, 4) |
| 79 | + assert_equal(infz, [0,2]) |
| 80 | + assert_equal(kronr, []) |
| 81 | + assert_equal(infe, [1,3,3]) |
| 82 | + assert_equal(kronl, [0,1,1]) |
| 83 | + |
| 84 | +def test3_ag08bd(): |
| 85 | + """test [A-lambda*E,B] |
| 86 | +
|
| 87 | + C,D must have correct dimensions as before |
| 88 | + """ |
| 89 | + |
| 90 | + Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=test1_m,p=0,A=test1_A,E=test1_E,B=test1_B,C=np.zeros((1,test1_n)),D=np.zeros((1,test1_m)),equil=test1_equil, tol=test1_tol) |
| 91 | + |
| 92 | + assert_equal(Af, np.zeros((0,0))) |
| 93 | + assert_equal(Ef, np.zeros((0,0))) |
| 94 | + assert_equal(nrank, 9) |
| 95 | + assert_equal(niz, 0) |
| 96 | + assert_equal(infz, []) |
| 97 | + assert_equal(kronr, [2,2,2]) |
| 98 | + assert_equal(infe, [1,1,1]) |
| 99 | + assert_equal(kronl, []) |
| 100 | + |
| 101 | +def test4_ag08bd(): |
| 102 | + """test [A-lambda*E,B;C,D]""" |
| 103 | + |
| 104 | + Af,Ef,nrank,niz,infz,kronr,infe,kronl = analysis.ag08bd(l=test1_l,n=test1_n,m=test1_m,p=test1_p,A=test1_A,E=test1_E,B=test1_B,C=test1_C,D=test1_D,equil=test1_equil, tol=test1_tol) |
| 105 | + |
| 106 | + # Af-lambda*Ef==0. => lambda==1. => Finite Smith zero of S(lambda) == 1. |
| 107 | + assert Af.shape == (1, 1) |
| 108 | + assert_almost_equal(Af, Ef) |
| 109 | + assert_equal(nrank, 11) |
| 110 | + assert_equal(niz, 2) |
| 111 | + assert_equal(infz, [0,1]) |
| 112 | + assert_equal(kronr, [2]) |
| 113 | + assert_equal(infe, [1,1,1,1,3]) |
| 114 | + assert_equal(kronl, [1]) |
0 commit comments