-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_rtrgsyl.py
47 lines (32 loc) · 1.28 KB
/
test_rtrgsyl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import unittest
from recursive import rtrgsyl
from utils import solve_bartels_stewart, build_matrices, check_sol
class TestRtrgsyl(unittest.TestCase):
def test_without_recursion(self):
A, B, C = build_matrices(8, 2)
# blks > matrix sizes => no recursion
fun = lambda A, B, C: rtrgsyl(A, B, C, 10)
X = solve_bartels_stewart(A, B, C, fun)[0]
self.assertTrue(check_sol(A, B, C, X))
A, B, C = build_matrices(2, 8)
X = solve_bartels_stewart(A, B, C, fun)[0]
self.assertTrue(check_sol(A, B, C, X))
def test_case_1(self):
# n <= n/2
fun = lambda A, B, C: rtrgsyl(A, B, C, 10)
A, B, C = build_matrices(100, 20)
X = solve_bartels_stewart(A, B, C, fun)[0]
self.assertTrue(check_sol(A, B, C, X))
def test_case_2(self):
# m <= n/2
fun = lambda A, B, C: rtrgsyl(A, B, C, 10)
A, B, C = build_matrices(20, 100)
X = solve_bartels_stewart(A, B, C, fun)[0]
self.assertTrue(check_sol(A, B, C, X))
def test_case_3(self):
fun = lambda A, B, C: rtrgsyl(A, B, C, 10)
A, B, C = build_matrices(100, 100)
X = solve_bartels_stewart(A, B, C, fun)[0]
self.assertTrue(check_sol(A, B, C, X))
if __name__ == '__main__':
unittest.main()