1
- # ===================================================
2
- # ab08n* tests
3
-
4
- import unittest
5
1
from slycot import analysis
6
2
import numpy as np
7
3
8
- from scipy .linalg import eig
9
- from numpy .testing import assert_equal , assert_allclose
4
+ from numpy .testing import assert_allclose
10
5
11
6
12
- class test_ab04md ( unittest . TestCase ) :
7
+ class test_ab04md :
13
8
"""Test ab04md.
14
-
9
+
15
10
Example data taken from
16
- https://www.slicot.org/objects/software/shared/doc/AB04MD.html.
11
+ https://www.slicot.org/objects/software/shared/doc/AB04MD.html
17
12
"""
18
13
19
14
Ac = np .array ([[1.0 , 0.5 ],
20
- [0.5 , 1.0 ]])
15
+ [0.5 , 1.0 ]])
21
16
Bc = np .array ([[0.0 , - 1.0 ],
22
- [1.0 , 0.0 ]])
17
+ [1.0 , 0.0 ]])
23
18
Cc = np .array ([[- 1.0 , 0.0 ],
24
- [0.0 , 1.0 ]])
19
+ [0.0 , 1.0 ]])
25
20
Dc = np .array ([[1.0 , 0.0 ],
26
- [0.0 , - 1.0 ]])
21
+ [0.0 , - 1.0 ]])
27
22
28
23
Ad = np .array ([[- 1.0 , - 4.0 ],
29
- [- 4.0 , - 1.0 ]])
24
+ [- 4.0 , - 1.0 ]])
30
25
Bd = np .array ([[2.8284 , 0.0 ],
31
- [0.0 , - 2.8284 ]])
26
+ [0.0 , - 2.8284 ]])
32
27
Cd = np .array ([[0.0 , 2.8284 ],
33
- [- 2.8284 , 0.0 ]])
28
+ [- 2.8284 , 0.0 ]])
34
29
Dd = np .array ([[- 1.0 , 0.0 ],
35
- [0.0 , - 3.0 ]])
30
+ [0.0 , - 3.0 ]])
36
31
37
32
def test_ab04md_cont_disc_cont (self ):
38
33
"""Test transformation from continuous - to discrete - to continuous time.
@@ -41,31 +36,31 @@ def test_ab04md_cont_disc_cont(self):
41
36
n , m = self .Bc .shape
42
37
p = self .Cc .shape [0 ]
43
38
44
- Ad_t , Bd_t , Cd_t , Dd_t = analysis .ab04md ('C' ,n ,m ,p ,self .Ac ,self .Bc ,self .Cc ,self .Dc )
39
+ Ad_t , Bd_t , Cd_t , Dd_t = analysis .ab04md (
40
+ 'C' , n , m , p , self .Ac , self .Bc , self .Cc , self .Dc )
45
41
46
- Ac_t , Bc_t , Cc_t , Dc_t = analysis .ab04md ('D' ,n ,m ,p ,Ad_t ,Bd_t ,Cd_t ,Dd_t )
42
+ Ac_t , Bc_t , Cc_t , Dc_t = analysis .ab04md (
43
+ 'D' , n , m , p , Ad_t , Bd_t , Cd_t , Dd_t )
47
44
48
45
assert_allclose (self .Ac , Ac_t )
49
46
assert_allclose (self .Bc , Bc_t )
50
47
assert_allclose (self .Cc , Cc_t )
51
48
assert_allclose (self .Dc , Dc_t )
52
-
49
+
53
50
def test_ab04md_disc_cont_disc (self ):
54
51
"""Test transformation from discrete - to continuous - to discrete time.
55
52
"""
56
53
57
54
n , m = self .Bc .shape
58
55
p = self .Cc .shape [0 ]
59
56
60
- Ac_t , Bc_t , Cc_t , Dc_t = analysis .ab04md ('D' ,n ,m ,p ,self .Ad ,self .Bd ,self .Cd ,self .Dd )
57
+ Ac_t , Bc_t , Cc_t , Dc_t = analysis .ab04md (
58
+ 'D' , n , m , p , self .Ad , self .Bd , self .Cd , self .Dd )
61
59
62
- Ad_t , Bd_t , Cd_t , Dd_t = analysis .ab04md ('C' ,n ,m ,p ,Ac_t ,Bc_t ,Cc_t ,Dc_t )
60
+ Ad_t , Bd_t , Cd_t , Dd_t = analysis .ab04md (
61
+ 'C' , n , m , p , Ac_t , Bc_t , Cc_t , Dc_t )
63
62
64
63
assert_allclose (self .Ad , Ad_t )
65
64
assert_allclose (self .Bd , Bd_t )
66
65
assert_allclose (self .Cd , Cd_t )
67
66
assert_allclose (self .Dd , Dd_t )
68
-
69
-
70
- if __name__ == "__main__" :
71
- unittest .main ()
0 commit comments