Repository navigation
Expand file tree
/
Copy pathtest_tg01ad.py
More file actions
79 lines (61 loc) · 2.34 KB
/
Copy pathtest_tg01ad.py
File metadata and controls
79 lines (61 loc) · 2.34 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# ===================================================
# tg01ad tests
import numpy as np
from numpy.testing import assert_almost_equal
from slycot import transform
# test1 input parameters
test1_l = 4
test1_n = 4
test1_m = 2
test1_p = 2
test1_job = 'A'
test1_thresh = 0.0
test1_A = \
np.array([[-1.0, 0.0, 0.0, 3e-3 ],
[ 0.0, 0.0, 0.1, 2e-2 ],
[ 1e2, 10.0, 0.0, 0.4 ],
[ 0.0, 0.0, 0.0, 0.0 ]])
test1_E = \
np.array([[ 1.0, 0.2, 0.0, 0.0 ],
[ 0.0, 1.0, 0.0, 1e-2 ],
[ 3e2, 90.0, 6.0, 0.3 ],
[ 0.0, 0.0, 20.0, 0.0 ]])
test1_B = \
np.array([[ 10.0, 0.0 ],
[ 0.0, 0.0 ],
[ 0.0, 1e3 ],
[ 1e4, 1e4 ]])
test1_C = \
np.array([[-0.1, 0.0, 1e-3, 0.0 ],
[ 0.0, 1e-2, -1e-3, 1e-4 ]])
test1_A_desired = \
np.array([[-1.0, 0.0, 0.0, 0.3 ],
[ 0.0, 0.0, 1.0, 2.0 ],
[ 1.0, 0.1, 0.0, 0.4 ],
[ 0.0, 0.0, 0.0, 0.0 ]])
test1_E_desired = \
np.array([[ 1.0, 0.2, 0.0, 0.0 ],
[ 0.0, 1.0, 0.0, 1.0 ],
[ 3.0, 0.9, 0.6, 0.3 ],
[ 0.0, 0.0, 0.2, 0.0 ]])
test1_B_desired = \
np.array([[ 1e2, 0.0 ],
[ 0.0, 0.0 ],
[ 0.0, 1e2 ],
[ 1e2, 1e2 ]])
test1_C_desired = \
np.array([[-1e-2, 0.0, 1e-3, 0.0 ],
[ 0.0, 1e-3, -1e-3, 1e-3 ]])
test1_lscale_desired = \
np.array([ 10.0, 10.0, 0.1, 1e-2 ])
test1_rscale_desired = \
np.array([ 0.1, 0.1, 1.0, 10.0 ])
def test1_tg01ad():
"""Verify tg01ad with input parameters according to example in documentation."""
A,E,B,C,lscale,rscale = transform.tg01ad(l=test1_l,n=test1_n,m=test1_m,p=test1_p,A=test1_A,E=test1_E,B=test1_B,C=test1_C,job=test1_job, thresh=test1_thresh)
assert_almost_equal(A, test1_A_desired)
assert_almost_equal(E, test1_E_desired)
assert_almost_equal(B, test1_B_desired)
assert_almost_equal(C, test1_C_desired)
assert_almost_equal(lscale, test1_lscale_desired)
assert_almost_equal(rscale, test1_rscale_desired)