codac4matlab 2.0.0.dev14__cp313-cp313-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codac4matlab/__init__.py +4 -0
- codac4matlab/_core.cp313-win32.pyd +0 -0
- codac4matlab/_graphics.cp313-win32.pyd +0 -0
- codac4matlab/_unsupported.cp313-win32.pyd +0 -0
- codac4matlab/core/__init__.py +340 -0
- codac4matlab/graphics/__init__.py +1 -0
- codac4matlab/tests/__init__.py +1 -0
- codac4matlab/tests/test_AnalyticFunction.py +419 -0
- codac4matlab/tests/test_AnalyticTraj.py +63 -0
- codac4matlab/tests/test_Approx.py +27 -0
- codac4matlab/tests/test_BoolInterval.py +40 -0
- codac4matlab/tests/test_Color.py +79 -0
- codac4matlab/tests/test_ConvexPolygon.py +207 -0
- codac4matlab/tests/test_CtcAction.py +30 -0
- codac4matlab/tests/test_CtcCartProd.py +39 -0
- codac4matlab/tests/test_CtcCtcBoundary.py +48 -0
- codac4matlab/tests/test_CtcFixpoint.py +65 -0
- codac4matlab/tests/test_CtcInter.py +39 -0
- codac4matlab/tests/test_CtcInverse.py +157 -0
- codac4matlab/tests/test_CtcInverseNotIn.py +129 -0
- codac4matlab/tests/test_CtcLazy.py +50 -0
- codac4matlab/tests/test_CtcPolygon.py +91 -0
- codac4matlab/tests/test_CtcSegment.py +104 -0
- codac4matlab/tests/test_Ellipsoid.py +20 -0
- codac4matlab/tests/test_IntFullPivLU.py +57 -0
- codac4matlab/tests/test_Interval.py +230 -0
- codac4matlab/tests/test_IntervalMatrix.py +664 -0
- codac4matlab/tests/test_IntervalVector.py +657 -0
- codac4matlab/tests/test_Interval_operations.py +293 -0
- codac4matlab/tests/test_Matrix.py +68 -0
- codac4matlab/tests/test_OctaSym.py +32 -0
- codac4matlab/tests/test_Polygon.py +108 -0
- codac4matlab/tests/test_SampledTraj.py +113 -0
- codac4matlab/tests/test_Segment.py +123 -0
- codac4matlab/tests/test_SepCartProd.py +34 -0
- codac4matlab/tests/test_SepCtcBoundary.py +52 -0
- codac4matlab/tests/test_SepInverse.py +104 -0
- codac4matlab/tests/test_SepPolygon.py +102 -0
- codac4matlab/tests/test_SepProj.py +39 -0
- codac4matlab/tests/test_SepTransform.py +41 -0
- codac4matlab/tests/test_Vector.py +41 -0
- codac4matlab/tests/test_arithmetic_add.py +54 -0
- codac4matlab/tests/test_arithmetic_div.py +46 -0
- codac4matlab/tests/test_arithmetic_mul.py +114 -0
- codac4matlab/tests/test_arithmetic_sub.py +54 -0
- codac4matlab/tests/test_capd.py +19 -0
- codac4matlab/tests/test_cart_prod.py +37 -0
- codac4matlab/tests/test_eigen.py +19 -0
- codac4matlab/tests/test_geometry.py +136 -0
- codac4matlab/tests/test_hull.py +35 -0
- codac4matlab/tests/test_ibex.py +19 -0
- codac4matlab/tests/test_inversion.py +57 -0
- codac4matlab/tests/test_linear_ctc.py +77 -0
- codac4matlab/tests/test_operators.py +348 -0
- codac4matlab/tests/test_transformations.py +61 -0
- codac4matlab/unsupported/__init__.py +1 -0
- codac4matlab/version.py +1 -0
- codac4matlab-2.0.0.dev14.dist-info/METADATA +23 -0
- codac4matlab-2.0.0.dev14.dist-info/RECORD +61 -0
- codac4matlab-2.0.0.dev14.dist-info/WHEEL +5 -0
- codac4matlab-2.0.0.dev14.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Codac tests
|
|
4
|
+
# ----------------------------------------------------------------------------
|
|
5
|
+
# \date 2024
|
|
6
|
+
# \author Simon Rohou
|
|
7
|
+
# \copyright Copyright 2024 Codac Team
|
|
8
|
+
# \license GNU Lesser General Public License (LGPL)
|
|
9
|
+
|
|
10
|
+
import unittest
|
|
11
|
+
from codac import *
|
|
12
|
+
|
|
13
|
+
def hull(x):
|
|
14
|
+
if x == -oo:
|
|
15
|
+
return Interval(-oo, next_float(-oo))
|
|
16
|
+
if x == oo:
|
|
17
|
+
return Interval(previous_float(oo), oo)
|
|
18
|
+
else:
|
|
19
|
+
return INterval(x)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TestSegment(unittest.TestCase):
|
|
23
|
+
|
|
24
|
+
def tests_intersects(self):
|
|
25
|
+
|
|
26
|
+
self.assertTrue(Segment([[0,0],[10,0]]).intersects(Segment([[4,0],[6,0]])) == BoolInterval.TRUE)
|
|
27
|
+
self.assertTrue(Segment([[0,0],[10,0]]).intersects(Segment([[5,0],[15,0]])) == BoolInterval.TRUE)
|
|
28
|
+
self.assertTrue(Segment([[0,0],[10,0]]).intersects(Segment([[5,-5],[5,10]])) == BoolInterval.TRUE)
|
|
29
|
+
self.assertTrue(Segment([[0,0],[10,0]]).intersects(Segment([[15,-5],[15,10]])) == BoolInterval.FALSE)
|
|
30
|
+
self.assertTrue(Segment([[0,0],[10,10]]).intersects(Segment([[1,1],[9,9]])) == BoolInterval.TRUE)
|
|
31
|
+
self.assertTrue(Segment([[1,1],[9,9]]).intersects(Segment([[0,0],[10,10]])) == BoolInterval.TRUE)
|
|
32
|
+
|
|
33
|
+
self.assertTrue(Segment(IntervalVector([hull(-oo),2]),Vector([0,2])).intersects(Segment(Vector([0,0]),Vector([0,1]))) == BoolInterval.FALSE)
|
|
34
|
+
self.assertTrue(Segment(IntervalVector([hull(-oo),2]),Vector([0,2])).intersects(Segment(Vector([0,0]),Vector([0,2]))) == BoolInterval.TRUE)
|
|
35
|
+
|
|
36
|
+
def tests_contains(self):
|
|
37
|
+
|
|
38
|
+
p1,p2,p3 = Vector([0.,0.]), Vector([1.5,3.]), Vector([0.,2.])
|
|
39
|
+
e1 = Segment(Vector([-10.,-10.]), Vector([10.,10.]))
|
|
40
|
+
e2 = Segment(Vector([1.,1.]), Vector([10.,10.]))
|
|
41
|
+
e3 = Segment(Vector([0.,0.]), Vector([2.,4.]))
|
|
42
|
+
|
|
43
|
+
self.assertTrue(e1.contains(p1) != BoolInterval.FALSE)
|
|
44
|
+
self.assertTrue(e2.contains(p1) == BoolInterval.FALSE)
|
|
45
|
+
self.assertTrue(e3.contains(p2) != BoolInterval.FALSE)
|
|
46
|
+
self.assertTrue(e3.contains(p3) == BoolInterval.FALSE)
|
|
47
|
+
|
|
48
|
+
def tests_proj_intersection(self):
|
|
49
|
+
|
|
50
|
+
self.assertTrue(proj_intersection([[0,0],[1,1]], [[3,3],[4,4]])
|
|
51
|
+
== IntervalVector(2))
|
|
52
|
+
|
|
53
|
+
self.assertTrue(proj_intersection([[0,0],[1,0]], [[0,2],[1,2]])
|
|
54
|
+
== IntervalVector.empty(2))
|
|
55
|
+
|
|
56
|
+
self.assertTrue(proj_intersection([[2,0],[6,4]],[[6,5],[5,6]])
|
|
57
|
+
== Approx(IntervalVector([6.5,4.5])))
|
|
58
|
+
|
|
59
|
+
self.assertTrue(proj_intersection([[-0.7,0.7],[0,1]], [[-1,0],[-0.7,-0.7]])
|
|
60
|
+
== Approx(IntervalVector([-1.2069,0.4828]), 1e-4))
|
|
61
|
+
|
|
62
|
+
self.assertTrue(proj_intersection([[1,2],[2,3]], [[8,4],[7,4]])
|
|
63
|
+
== IntervalVector([3,4]))
|
|
64
|
+
|
|
65
|
+
self.assertTrue(proj_intersection([[4,11],[8,11]], [[12,12],[12,16]])
|
|
66
|
+
== IntervalVector([12,11]))
|
|
67
|
+
|
|
68
|
+
self.assertTrue(proj_intersection([[1,2],[1,2]], [[8,4],[7,4]])
|
|
69
|
+
== IntervalVector(2))
|
|
70
|
+
|
|
71
|
+
self.assertTrue(proj_intersection([[0,1],[0,2]], [[2,1],[2,2]])
|
|
72
|
+
== IntervalVector.empty(2))
|
|
73
|
+
|
|
74
|
+
self.assertTrue(proj_intersection([[-4,4],[0,0]], [[0,0],[4,4]])
|
|
75
|
+
== IntervalVector([0,0]))
|
|
76
|
+
|
|
77
|
+
self.assertTrue(proj_intersection([[-4,4],[0,0]], [[4,4],[0,0]])
|
|
78
|
+
== IntervalVector([0,0]))
|
|
79
|
+
|
|
80
|
+
self.assertTrue(proj_intersection([[0,4],[4,0]], [[4,4],[0,0]])
|
|
81
|
+
== IntervalVector([2,2]))
|
|
82
|
+
|
|
83
|
+
def tests_intersection(self):
|
|
84
|
+
|
|
85
|
+
self.assertTrue((Segment([0,0],[0,0]) & Segment([0,0],[5,0])) == IntervalVector([0,0])) # degenerate line, horizontal edge line
|
|
86
|
+
self.assertTrue((Segment([0,0],[0,0]) & Segment([0,0],[0,5])) == IntervalVector([0,0])) # degenerate line, vertical edge line
|
|
87
|
+
|
|
88
|
+
self.assertTrue((Segment([0,0],[0,1]) & Segment([0,0],[0,5.0])) == IntervalVector([0,[0,1.]])) # vertical edge line (colinear)
|
|
89
|
+
self.assertTrue((Segment([0,0],[0,1]) & Segment([0,0],[0,0.5])) == IntervalVector([0,[0,0.5]])) # vertical edge line (colinear)
|
|
90
|
+
self.assertTrue((Segment([0,0],[1,0]) & Segment([0,0],[5.0,0])) == IntervalVector([[0,1.],0])) # horizontal edge line (colinear)
|
|
91
|
+
self.assertTrue((Segment([0,0],[1,0]) & Segment([0,0],[0.5,0])) == IntervalVector([[0,0.5],0])) # horizontal edge line (colinear)
|
|
92
|
+
|
|
93
|
+
self.assertTrue((Segment([7,4],[7,5]) & Segment([7,6],[7,8])) == IntervalVector.empty(2)) # vertical edge line (colinear), no intersection
|
|
94
|
+
self.assertTrue((Segment([4,7],[5,7]) & Segment([6,7],[8,7])) == IntervalVector.empty(2)) # horizontal edge line (colinear), no intersection
|
|
95
|
+
|
|
96
|
+
self.assertTrue((Segment([0,0],[3,0]) & Segment([1,2],[1,-999])) == IntervalVector([1,0])) # perpendicular intersection
|
|
97
|
+
self.assertTrue((Segment([0.5,-1],[0.5,5]) & Segment([-3,2],[5,2])) == IntervalVector([0.5,2])) # perpendicular intersection
|
|
98
|
+
|
|
99
|
+
self.assertTrue((Segment([0,0],[3,0]) & Segment([1,-10],[1,-999])) == IntervalVector.empty(2)) # perpendicular lines, no intersection
|
|
100
|
+
self.assertTrue((Segment([0.5,-1],[0.5,5]) & Segment([-3,-2],[5,-2])) == IntervalVector.empty(2)) # perpendicular lines, no intersection
|
|
101
|
+
|
|
102
|
+
self.assertTrue((Segment([8,4],[9,2]) & Segment([7,3],[9,3])) == IntervalVector([8.5,3])) # perpendicular oblique lines
|
|
103
|
+
self.assertTrue((Segment([8,4],[9,2]) & Segment([8.5,8],[8.5,0])) == IntervalVector([8.5,3])) # perpendicular oblique lines
|
|
104
|
+
|
|
105
|
+
self.assertTrue((Segment([8,4],[9,2]) & Segment([7.,3],[7.5,3])) == IntervalVector.empty(2)) # secant oblique lines, no intersection
|
|
106
|
+
self.assertTrue((Segment([8,4],[9,2]) & Segment([8.5,8],[8.5,7])) == IntervalVector.empty(2)) # secant oblique lines, no intersection
|
|
107
|
+
self.assertTrue((Segment([6,-1],[8,1]) & Segment([7.5,0],[9,0])) == IntervalVector.empty(2)) # secant oblique lines, no intersection
|
|
108
|
+
self.assertTrue((Segment([6,-1],[8,1]) & Segment([6.5,0.5],[6.5,2])) == IntervalVector.empty(2)) # secant oblique lines, no intersection
|
|
109
|
+
|
|
110
|
+
# Other tests
|
|
111
|
+
self.assertTrue((Segment([8,14],[6,13]) & Segment([1,1],[1,14])) == IntervalVector.empty(2))
|
|
112
|
+
self.assertTrue((Segment([hull(-oo),0],[1,0]) & Segment([0,1],[0,-1])) == IntervalVector.zero(2))
|
|
113
|
+
self.assertTrue((Segment([0,0],[1,2]) & Segment([0.5,0],[0.5,2])) == IntervalVector([0.5,1]))
|
|
114
|
+
self.assertTrue((Segment([-1,-1],[0,0]) & Segment([9,3],[0,0])) == IntervalVector([0,0]))
|
|
115
|
+
self.assertTrue((Segment([0,0],[10,0]) & Segment([2,0],[8,0])) == IntervalVector([[2,8],[0]])) # colinear case
|
|
116
|
+
self.assertTrue((Segment([0,0],[10,10]) & Segment([2,2],[8,8])) == IntervalVector([[2,8],[2,8]])) # colinear case
|
|
117
|
+
self.assertTrue((Segment([0,0],[10,0]) & Segment([2,1],[8,1])) == IntervalVector.empty(2)) # parallel case
|
|
118
|
+
|
|
119
|
+
self.assertTrue((Segment([2,0],[6,4]) & Segment([6,5],[5,6])) == IntervalVector.empty(2))
|
|
120
|
+
self.assertTrue(proj_intersection(Segment([2,0],[6,4]), Segment([6,5],[5,6])) == IntervalVector([6.5,4.5]))
|
|
121
|
+
|
|
122
|
+
if __name__ == '__main__':
|
|
123
|
+
unittest.main()
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Codac tests
|
|
4
|
+
# ----------------------------------------------------------------------------
|
|
5
|
+
# \date 2024
|
|
6
|
+
# \author Simon Rohou
|
|
7
|
+
# \copyright Copyright 2024 Codac Team
|
|
8
|
+
# \license GNU Lesser General Public License (LGPL)
|
|
9
|
+
|
|
10
|
+
import unittest
|
|
11
|
+
from codac import *
|
|
12
|
+
|
|
13
|
+
class TestSepCartProd(unittest.TestCase):
|
|
14
|
+
|
|
15
|
+
def tests_SepCartProd(self):
|
|
16
|
+
|
|
17
|
+
v = VectorVar(1)
|
|
18
|
+
s1 = SepInverse(AnalyticFunction([v], v), IntervalVector([[-1,1]]))
|
|
19
|
+
s2 = SepInverse(AnalyticFunction([v], v), IntervalVector([[5,6]]))
|
|
20
|
+
|
|
21
|
+
x = IntervalVector([[0,8],[5.5,oo]])
|
|
22
|
+
s3 = SepCartProd(s1,s2)
|
|
23
|
+
inner,outer = s3.separate(x)
|
|
24
|
+
self.assertTrue(inner == IntervalVector([[1,8],[6,oo]]))
|
|
25
|
+
self.assertTrue(outer == IntervalVector([[0,1],[5.5,6]]))
|
|
26
|
+
|
|
27
|
+
x = IntervalVector([[0,8],[5.5,oo]])
|
|
28
|
+
s4 = cart_prod(s1,s2)
|
|
29
|
+
inner,outer = s4.separate(x)
|
|
30
|
+
self.assertTrue(inner == IntervalVector([[1,8],[6,oo]]))
|
|
31
|
+
self.assertTrue(outer == IntervalVector([[0,1],[5.5,6]]))
|
|
32
|
+
|
|
33
|
+
if __name__ == '__main__':
|
|
34
|
+
unittest.main()
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Codac tests
|
|
4
|
+
# ----------------------------------------------------------------------------
|
|
5
|
+
# \date 2024
|
|
6
|
+
# \author Simon Rohou
|
|
7
|
+
# \copyright Copyright 2024 Codac Team
|
|
8
|
+
# \license GNU Lesser General Public License (LGPL)
|
|
9
|
+
|
|
10
|
+
import unittest
|
|
11
|
+
from codac import *
|
|
12
|
+
|
|
13
|
+
def test_inside_diamond(x):
|
|
14
|
+
if (x[1] < x[0]+1) and (x[1] > x[0]-1) and (x[1] < -x[0]+1) and (x[1] > -x[0]-1):
|
|
15
|
+
return BoolInterval.TRUE
|
|
16
|
+
elif not(x[1] < x[0]+1) or not(x[1] > x[0]-1) or not(x[1] < -x[0]+1) or not(x[1] > -x[0]-1):
|
|
17
|
+
return BoolInterval.FALSE
|
|
18
|
+
else:
|
|
19
|
+
return BoolInterval.UNKNOWN
|
|
20
|
+
|
|
21
|
+
class TestSepCtcBoundary(unittest.TestCase):
|
|
22
|
+
|
|
23
|
+
def tests_SepCtcBoundary(self):
|
|
24
|
+
|
|
25
|
+
ctc_bound_diamond = CtcSegment([[-1],[0]], [[0],[-1]]) | CtcSegment([[0],[-1]], [[1],[0]]) \
|
|
26
|
+
| CtcSegment([[1],[0]], [[0],[1]]) | CtcSegment([[0],[1]], [[-1],[0]])
|
|
27
|
+
|
|
28
|
+
sep_diamond = SepCtcBoundary(ctc_bound_diamond,test_inside_diamond)
|
|
29
|
+
#draw_while_paving(IntervalVector([[-2,2],[-2,2]]), sep_diamond, 0.1)
|
|
30
|
+
|
|
31
|
+
x = IntervalVector(2)
|
|
32
|
+
inner,outer = sep_diamond.separate(IntervalVector(2))
|
|
33
|
+
self.assertTrue(inner == IntervalVector(2))
|
|
34
|
+
self.assertTrue(outer == IntervalVector([[-1,1],[-1,1]]))
|
|
35
|
+
|
|
36
|
+
x = IntervalVector([[0,10],[0,10]])
|
|
37
|
+
inner,outer = sep_diamond.separate(x)
|
|
38
|
+
self.assertTrue(inner == x)
|
|
39
|
+
self.assertTrue(outer == IntervalVector([[0,1],[0,1]]))
|
|
40
|
+
|
|
41
|
+
x = IntervalVector([[0.2,10],[0.2,10]])
|
|
42
|
+
inner,outer = sep_diamond.separate(x)
|
|
43
|
+
self.assertTrue(inner == x)
|
|
44
|
+
self.assertTrue(outer == IntervalVector([[0.2,0.8],[0.2,0.8]]))
|
|
45
|
+
|
|
46
|
+
x = IntervalVector([[0.5,10],[0.5,10]])
|
|
47
|
+
inner,outer = sep_diamond.separate(x)
|
|
48
|
+
self.assertTrue(inner == x)
|
|
49
|
+
self.assertTrue(outer == IntervalVector([[0.5],[0.5]]))
|
|
50
|
+
|
|
51
|
+
if __name__ == '__main__':
|
|
52
|
+
unittest.main()
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Codac tests
|
|
4
|
+
# ----------------------------------------------------------------------------
|
|
5
|
+
# \date 2024
|
|
6
|
+
# \author Simon Rohou
|
|
7
|
+
# \copyright Copyright 2024 Codac Team
|
|
8
|
+
# \license GNU Lesser General Public License (LGPL)
|
|
9
|
+
|
|
10
|
+
import unittest
|
|
11
|
+
from codac import *
|
|
12
|
+
|
|
13
|
+
class TestSepInverse(unittest.TestCase):
|
|
14
|
+
|
|
15
|
+
def tests_SepInverse_box(self):
|
|
16
|
+
|
|
17
|
+
x = VectorVar(2)
|
|
18
|
+
f = AnalyticFunction([x], [
|
|
19
|
+
x[0],
|
|
20
|
+
sqr(x[0]/7.)+sqr(x[1]/3.)
|
|
21
|
+
])
|
|
22
|
+
s = SepInverse(f, [[0,oo],[-oo,1]])
|
|
23
|
+
|
|
24
|
+
b = IntervalVector([[0,0.8],[-2.28,-1.56]])
|
|
25
|
+
inner,outer = s.separate(b)
|
|
26
|
+
self.assertTrue(inner == IntervalVector([[0],[-2.28,-1.56]]))
|
|
27
|
+
self.assertTrue(outer == b)
|
|
28
|
+
|
|
29
|
+
b = IntervalVector([[4,5.4],[-0.05,2.45]])
|
|
30
|
+
inner,outer = s.separate(b)
|
|
31
|
+
self.assertTrue(Approx(inner,1e-2) == IntervalVector([[4.039,5.40],[1.908,2.45]]))
|
|
32
|
+
self.assertTrue(outer == b)
|
|
33
|
+
|
|
34
|
+
b = IntervalVector([[6.25,6.7],[0.9,1.85]])
|
|
35
|
+
inner,outer = s.separate(b)
|
|
36
|
+
self.assertTrue(Approx(inner,1e-2) == IntervalVector([[6.25,6.70],[0.9, 1.85]]))
|
|
37
|
+
self.assertTrue(Approx(inner,1e-2) == IntervalVector([[6.25,6.70],[0.9, 1.85]]))
|
|
38
|
+
|
|
39
|
+
b = IntervalVector([[-6,-5],[0,2]])
|
|
40
|
+
inner,outer = s.separate(b)
|
|
41
|
+
self.assertTrue(inner == b)
|
|
42
|
+
self.assertTrue(outer == IntervalVector.empty(2))
|
|
43
|
+
|
|
44
|
+
b = IntervalVector([[2,3],[-1,1]])
|
|
45
|
+
inner,outer = s.separate(b)
|
|
46
|
+
self.assertTrue(inner == IntervalVector.empty(2))
|
|
47
|
+
self.assertTrue(outer == b)
|
|
48
|
+
|
|
49
|
+
def tests_SepInverse_sep(self):
|
|
50
|
+
|
|
51
|
+
x = VectorVar(2)
|
|
52
|
+
f = AnalyticFunction([x], [
|
|
53
|
+
x[0],
|
|
54
|
+
sqr(x[0]/7.)+sqr(x[1]/3.)
|
|
55
|
+
])
|
|
56
|
+
s = SepInverse(f, SepWrapper_IntervalVector([[0,oo],[-oo,1]]))
|
|
57
|
+
|
|
58
|
+
b = IntervalVector([[0,0.8],[-2.28,-1.56]])
|
|
59
|
+
inner,outer = s.separate(b)
|
|
60
|
+
self.assertTrue(inner == IntervalVector([[0],[-2.28,-1.56]]))
|
|
61
|
+
self.assertTrue(outer == b)
|
|
62
|
+
|
|
63
|
+
b = IntervalVector([[4,5.4],[-0.05,2.45]])
|
|
64
|
+
inner,outer = s.separate(b)
|
|
65
|
+
self.assertTrue(Approx(inner,1e-2) == IntervalVector([[4.039,5.40],[1.908,2.45]]))
|
|
66
|
+
self.assertTrue(outer == b)
|
|
67
|
+
|
|
68
|
+
b = IntervalVector([[6.25,6.7],[0.9,1.85]])
|
|
69
|
+
inner,outer = s.separate(b)
|
|
70
|
+
self.assertTrue(Approx(inner,1e-2) == IntervalVector([[6.25,6.70],[0.9, 1.85]]))
|
|
71
|
+
self.assertTrue(Approx(inner,1e-2) == IntervalVector([[6.25,6.70],[0.9, 1.85]]))
|
|
72
|
+
|
|
73
|
+
b = IntervalVector([[-6,-5],[0,2]])
|
|
74
|
+
inner,outer = s.separate(b)
|
|
75
|
+
self.assertTrue(inner == b)
|
|
76
|
+
self.assertTrue(outer == IntervalVector.empty(2))
|
|
77
|
+
|
|
78
|
+
b = IntervalVector([[2,3],[-1,1]])
|
|
79
|
+
inner,outer = s.separate(b)
|
|
80
|
+
self.assertTrue(inner == IntervalVector.empty(2))
|
|
81
|
+
self.assertTrue(outer == b)
|
|
82
|
+
|
|
83
|
+
def tests_SepInverse_other_test(self):
|
|
84
|
+
|
|
85
|
+
x = VectorVar(2)
|
|
86
|
+
f = AnalyticFunction([x], vec(sqr(x[0])+sqr(x[1])))
|
|
87
|
+
s = SepInverse(f, [[0,1]])
|
|
88
|
+
|
|
89
|
+
#pave([[-5,5],[-5,5]], s, 0.01);
|
|
90
|
+
|
|
91
|
+
inner,outer = s.separate(IntervalVector([[0.1,0.2],[0.1,0.2]])) # fully inside
|
|
92
|
+
self.assertTrue(inner.is_empty())
|
|
93
|
+
self.assertTrue(outer == IntervalVector([[0.1,0.2],[0.1,0.2]]))
|
|
94
|
+
|
|
95
|
+
inner,outer = s.separate(IntervalVector([[-0.2,0.2],[-0.2,0.2]])) # fully inside
|
|
96
|
+
self.assertTrue(inner.is_empty())
|
|
97
|
+
self.assertTrue(outer == IntervalVector([[-0.2,0.2],[-0.2,0.2]]))
|
|
98
|
+
|
|
99
|
+
inner,outer = s.separate(IntervalVector(2))
|
|
100
|
+
self.assertTrue(inner == IntervalVector(2))
|
|
101
|
+
self.assertTrue(outer == IntervalVector([[-1,1],[-1,1]]))
|
|
102
|
+
|
|
103
|
+
if __name__ == '__main__':
|
|
104
|
+
unittest.main()
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Codac tests
|
|
4
|
+
# ----------------------------------------------------------------------------
|
|
5
|
+
# \date 2024
|
|
6
|
+
# \author Simon Rohou
|
|
7
|
+
# \copyright Copyright 2024 Codac Team
|
|
8
|
+
# \license GNU Lesser General Public License (LGPL)
|
|
9
|
+
|
|
10
|
+
import unittest
|
|
11
|
+
from codac import *
|
|
12
|
+
|
|
13
|
+
class TestSepPolygon(unittest.TestCase):
|
|
14
|
+
|
|
15
|
+
def tests_SepPolygon(self):
|
|
16
|
+
|
|
17
|
+
# Polygon, defined as a list of vertices
|
|
18
|
+
p = Polygon([[3,-1],[3,4],[5,6],[-1,1]])
|
|
19
|
+
s = SepPolygon(p)
|
|
20
|
+
c = CtcPolygon(p)
|
|
21
|
+
|
|
22
|
+
x = IntervalVector(2)
|
|
23
|
+
inner,outer = s.separate(IntervalVector(2))
|
|
24
|
+
self.assertTrue(inner == IntervalVector(2))
|
|
25
|
+
self.assertTrue(outer == IntervalVector([[-1,5],[-1,6]]))
|
|
26
|
+
|
|
27
|
+
y = IntervalVector(2)
|
|
28
|
+
c.contract(y)
|
|
29
|
+
self.assertTrue(y == IntervalVector([[-1,5],[-1,6]]))
|
|
30
|
+
|
|
31
|
+
x = IntervalVector([[3.02,3.16],[2.5,3.2]]) # possible bug
|
|
32
|
+
inner,outer = s.separate(x)
|
|
33
|
+
self.assertTrue(inner == x)
|
|
34
|
+
self.assertTrue(outer.is_empty())
|
|
35
|
+
|
|
36
|
+
def tests_SepPolygon_fromCodac1(self):
|
|
37
|
+
|
|
38
|
+
# Polygone with hole, defined as a list of edges
|
|
39
|
+
|
|
40
|
+
s = SepPolygon([
|
|
41
|
+
# external border
|
|
42
|
+
[[6,-6], [7,9]],
|
|
43
|
+
[[7,9], [0,5]],
|
|
44
|
+
[[0,5], [-9,8]],
|
|
45
|
+
[[-9,8], [-8,-9]],
|
|
46
|
+
[[-8,-9], [6,-6]],
|
|
47
|
+
# hole
|
|
48
|
+
[[-2,3], [3.5,2]],
|
|
49
|
+
[[3.5,2], [1.5,0.5]],
|
|
50
|
+
[[1.5,0.5], [3,-4]],
|
|
51
|
+
[[3,-4], [-3,-3]],
|
|
52
|
+
[[-3,-3], [-2,3]]
|
|
53
|
+
])
|
|
54
|
+
|
|
55
|
+
#draw_while_paving(IntervalVector([[-10,10],[-10,10]]), s, 0.1)
|
|
56
|
+
|
|
57
|
+
# Check a box inside the hole
|
|
58
|
+
|
|
59
|
+
x = IntervalVector([[0],[0]]).inflate(0.5)
|
|
60
|
+
#DefaultFigure.draw_box(x,Color::purple())
|
|
61
|
+
inner,outer = s.separate(x)
|
|
62
|
+
self.assertTrue(inner == x)
|
|
63
|
+
self.assertTrue(outer.is_empty())
|
|
64
|
+
|
|
65
|
+
# Check a box inside the polygon
|
|
66
|
+
|
|
67
|
+
x = IntervalVector([[5],[-5]]).inflate(0.5)
|
|
68
|
+
#DefaultFigure.draw_box(x,Color::purple())
|
|
69
|
+
inner,outer = s.separate(x)
|
|
70
|
+
self.assertTrue(inner.is_empty())
|
|
71
|
+
self.assertTrue(outer == x)
|
|
72
|
+
|
|
73
|
+
# Check a box outside the polygon
|
|
74
|
+
|
|
75
|
+
x = IntervalVector([[-1],[8]]).inflate(0.5)
|
|
76
|
+
#DefaultFigure.draw_box(x,Color::purple())
|
|
77
|
+
inner,outer = s.separate(x)
|
|
78
|
+
self.assertTrue(inner == x)
|
|
79
|
+
self.assertTrue(outer.is_empty())
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# Other polygon, defined as a list of vertices
|
|
83
|
+
|
|
84
|
+
s = SepPolygon([[6,-6],[7,9],[0,5],[-9,8],[-8,-9]])
|
|
85
|
+
|
|
86
|
+
# Check a box inside the polygon
|
|
87
|
+
|
|
88
|
+
x = IntervalVector([[5],[-5]]).inflate(0.5)
|
|
89
|
+
inner,outer = s.separate(x)
|
|
90
|
+
self.assertTrue(inner.is_empty())
|
|
91
|
+
self.assertTrue(outer == x)
|
|
92
|
+
|
|
93
|
+
# Check a box outside the polygon
|
|
94
|
+
|
|
95
|
+
x = IntervalVector([[-1],[8]]).inflate(0.5)
|
|
96
|
+
inner,outer = s.separate(x)
|
|
97
|
+
self.assertTrue(inner == x)
|
|
98
|
+
self.assertTrue(outer.is_empty())
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
if __name__ == '__main__':
|
|
102
|
+
unittest.main()
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Codac tests
|
|
4
|
+
# ----------------------------------------------------------------------------
|
|
5
|
+
# \date 2024
|
|
6
|
+
# \author Simon Rohou
|
|
7
|
+
# \copyright Copyright 2024 Codac Team
|
|
8
|
+
# \license GNU Lesser General Public License (LGPL)
|
|
9
|
+
|
|
10
|
+
import unittest
|
|
11
|
+
from codac import *
|
|
12
|
+
|
|
13
|
+
class TestSepProj(unittest.TestCase):
|
|
14
|
+
|
|
15
|
+
def tests_SepProj(self):
|
|
16
|
+
|
|
17
|
+
x = VectorVar(3)
|
|
18
|
+
f_ellipsoid = AnalyticFunction([x], 2*sqr(x[0])+x[0]*x[1]+x[0]*x[2]+sqr(x[1])+sqr(x[2]))
|
|
19
|
+
sep_ellipsoid = SepInverse(f_ellipsoid, [0.7,1])
|
|
20
|
+
sep_proj = SepProj(sep_ellipsoid, [0,1], [[0.1,0.2]])
|
|
21
|
+
|
|
22
|
+
# todo: test with SepProj sep_proj(sep_ellipsoid, {0,1}, [[-oo,oo]])
|
|
23
|
+
|
|
24
|
+
#pave(IntervalVector([[-2,2],[-2,2]]), sep_proj, 0.1)
|
|
25
|
+
|
|
26
|
+
b = IntervalVector([[0.2,0.4],[0.0,1]])
|
|
27
|
+
inner,outer = sep_proj.separate(b,1e-3)
|
|
28
|
+
self.assertTrue(Approx(outer,1e-2) == IntervalVector([[0.2,0.4],[0,0.94]]))
|
|
29
|
+
|
|
30
|
+
b = IntervalVector([[-0.4,-0.2],[0.95,1.5]])
|
|
31
|
+
inner,outer = sep_proj.separate(b,1e-3)
|
|
32
|
+
self.assertTrue(Approx(outer,1e-2) == IntervalVector([[-0.4,-0.2],[0.95,1.15]]))
|
|
33
|
+
|
|
34
|
+
b = IntervalVector([[0.65],[-0.5,-0.4]])
|
|
35
|
+
inner,outer = sep_proj.separate(b,1e-3)
|
|
36
|
+
self.assertTrue(inner.is_empty())
|
|
37
|
+
|
|
38
|
+
if __name__ == '__main__':
|
|
39
|
+
unittest.main()
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Codac tests
|
|
4
|
+
# ----------------------------------------------------------------------------
|
|
5
|
+
# \date 2024
|
|
6
|
+
# \author Simon Rohou
|
|
7
|
+
# \copyright Copyright 2024 Codac Team
|
|
8
|
+
# \license GNU Lesser General Public License (LGPL)
|
|
9
|
+
|
|
10
|
+
import unittest
|
|
11
|
+
from codac import *
|
|
12
|
+
|
|
13
|
+
class TestSepTransform(unittest.TestCase):
|
|
14
|
+
|
|
15
|
+
def tests_SepTransform(self):
|
|
16
|
+
|
|
17
|
+
x = VectorVar(2)
|
|
18
|
+
s1 = SepInverse(AnalyticFunction([x], sqr(x[0])+sqr(x[1])), [0,1])
|
|
19
|
+
s2 = SepTransform(s1,
|
|
20
|
+
AnalyticFunction([x], vec(x[0]+2,x[1]+2)),
|
|
21
|
+
AnalyticFunction([x], vec(x[0]-2,x[1]-2)))
|
|
22
|
+
|
|
23
|
+
#pave([[-5,5],[-5,5]], s2, 0.01)
|
|
24
|
+
|
|
25
|
+
inner,outer = s2.separate(IntervalVector(2))
|
|
26
|
+
self.assertTrue(inner == IntervalVector(2))
|
|
27
|
+
self.assertTrue(Approx(outer,1e-1) == IntervalVector([[-3,-1],[-3,-1]]))
|
|
28
|
+
|
|
29
|
+
inner,outer = s2.separate(IntervalVector([[-2.2,-1.8],[-2.2,-1.8]]))
|
|
30
|
+
self.assertTrue(inner.is_empty())
|
|
31
|
+
self.assertTrue(outer == IntervalVector([[-2.2,-1.8],[-2.2,-1.8]]))
|
|
32
|
+
|
|
33
|
+
b = IntervalVector([[-2.5,-1.5],[-2,10]])
|
|
34
|
+
#DefaultFigure.draw_box(b,Color.purple())
|
|
35
|
+
inner,outer = s2.separate(b)
|
|
36
|
+
#DefaultFigure.draw_box(xs.inner,Color.green())
|
|
37
|
+
self.assertTrue(Approx(inner,1e-1) == IntervalVector([[-2.5,-1.5],[-1.134,10]]))
|
|
38
|
+
self.assertTrue(Approx(outer,1e-1) == IntervalVector([[-2.5,-1.5],[-2,-1]]))
|
|
39
|
+
|
|
40
|
+
if __name__ == '__main__':
|
|
41
|
+
unittest.main()
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Codac tests
|
|
4
|
+
# ----------------------------------------------------------------------------
|
|
5
|
+
# \date 2024
|
|
6
|
+
# \author Simon Rohou
|
|
7
|
+
# \copyright Copyright 2024 Codac Team
|
|
8
|
+
# \license GNU Lesser General Public License (LGPL)
|
|
9
|
+
|
|
10
|
+
import unittest
|
|
11
|
+
from codac import *
|
|
12
|
+
|
|
13
|
+
class TestVector(unittest.TestCase):
|
|
14
|
+
|
|
15
|
+
def tests_Vector(self):
|
|
16
|
+
|
|
17
|
+
self.assertTrue(Vector([1,2])+Vector([3,4]) == Vector([4,6]))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def tests_vector_specific_to_python(self):
|
|
21
|
+
|
|
22
|
+
x = Vector([1,2,3])
|
|
23
|
+
y = Vector.zero(3)
|
|
24
|
+
|
|
25
|
+
i = 0
|
|
26
|
+
for xi in x: # using __iter__
|
|
27
|
+
y[i] = xi
|
|
28
|
+
i = i+1
|
|
29
|
+
|
|
30
|
+
self.assertTrue(x == y)
|
|
31
|
+
|
|
32
|
+
a,b,c = x # using __iter__
|
|
33
|
+
self.assertTrue(a == x[0])
|
|
34
|
+
self.assertTrue(b == x[1])
|
|
35
|
+
self.assertTrue(c == x[2])
|
|
36
|
+
|
|
37
|
+
v = Vector([*x, 42]) # using __iter__
|
|
38
|
+
self.assertTrue(v == [1,2,3,42])
|
|
39
|
+
|
|
40
|
+
if __name__ == '__main__':
|
|
41
|
+
unittest.main()
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Codac tests
|
|
4
|
+
# ----------------------------------------------------------------------------
|
|
5
|
+
# \date 2024
|
|
6
|
+
# \author Simon Rohou
|
|
7
|
+
# \copyright Copyright 2024 Codac Team
|
|
8
|
+
# \license GNU Lesser General Public License (LGPL)
|
|
9
|
+
|
|
10
|
+
import unittest
|
|
11
|
+
from codac import *
|
|
12
|
+
|
|
13
|
+
class TestArithmeticAdd(unittest.TestCase):
|
|
14
|
+
|
|
15
|
+
def tests_ArithmeticAdd(self):
|
|
16
|
+
|
|
17
|
+
# inline Vector operator+(const Vector& x1, const Vector& x2)
|
|
18
|
+
self.assertTrue(Vector([1,2,3])+Vector([5,6,7]) == Vector([6,8,10]))
|
|
19
|
+
|
|
20
|
+
# inline IntervalVector operator+(const Vector& x1, const IntervalVector& x2)
|
|
21
|
+
self.assertTrue(Vector([1,2,3])+IntervalVector([[-1,1],[-2,2],[-3,3]]) == IntervalVector([[0,2],[0,4],[0,6]]))
|
|
22
|
+
|
|
23
|
+
# Matrix operator+(const M& x1, const M_& x2)
|
|
24
|
+
self.assertTrue(Matrix([[1,2],[3,4]])+Matrix([[3,4],[5,6]]) == Matrix([[4,6],[8,10]]))
|
|
25
|
+
self.assertTrue(Matrix([[1,2],[3,4]]).block(0,0,2,2)+Matrix([[3,4],[5,6]]) == Matrix([[4,6],[8,10]]))
|
|
26
|
+
self.assertTrue(Matrix([[1,2],[3,4]])+Matrix([[3,4],[5,6]]).block(0,0,2,2) == Matrix([[4,6],[8,10]]))
|
|
27
|
+
self.assertTrue(Matrix([[1,2],[3,4]]).block(0,0,2,2)+Matrix([[3,4],[5,6]]).block(0,0,2,2) == Matrix([[4,6],[8,10]]))
|
|
28
|
+
|
|
29
|
+
# IntervalMatrix operator+(const M& x1, const IM& x2)
|
|
30
|
+
self.assertTrue(Matrix([[1,2],[3,4]])+IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]) == IntervalMatrix([[[0,2],[0,4]],[[0,6],[0,8]]]))
|
|
31
|
+
self.assertTrue(Matrix([[1,2],[3,4]]).block(0,0,2,2)+IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]) == IntervalMatrix([[[0,2],[0,4]],[[0,6],[0,8]]]))
|
|
32
|
+
self.assertTrue(Matrix([[1,2],[3,4]])+IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]).block(0,0,2,2) == IntervalMatrix([[[0,2],[0,4]],[[0,6],[0,8]]]))
|
|
33
|
+
self.assertTrue(Matrix([[1,2],[3,4]]).block(0,0,2,2)+IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]).block(0,0,2,2) == IntervalMatrix([[[0,2],[0,4]],[[0,6],[0,8]]]))
|
|
34
|
+
|
|
35
|
+
# inline IntervalVector operator+(const IntervalVector& x1, const Vector& x2)
|
|
36
|
+
self.assertTrue(IntervalVector([[-1,1],[-2,2],[-3,3]])+Vector([1,2,3]) == IntervalVector([[0,2],[0,4],[0,6]]))
|
|
37
|
+
|
|
38
|
+
# inline IntervalVector operator+(const IntervalVector& x1, const IntervalVector& x2)
|
|
39
|
+
self.assertTrue(IntervalVector([[-1,1],[-2,2],[-3,3]])+IntervalVector([[1],[2],[3]]) == IntervalVector([[0,2],[0,4],[0,6]]))
|
|
40
|
+
|
|
41
|
+
# IntervalMatrix operator+(const IM& x1, const M& x2)
|
|
42
|
+
self.assertTrue(IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]])+Matrix([[1,2],[3,4]]) == IntervalMatrix([[[0,2],[0,4]],[[0,6],[0,8]]]))
|
|
43
|
+
self.assertTrue(IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]).block(0,0,2,2)+Matrix([[1,2],[3,4]]) == IntervalMatrix([[[0,2],[0,4]],[[0,6],[0,8]]]))
|
|
44
|
+
self.assertTrue(IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]])+Matrix([[1,2],[3,4]]).block(0,0,2,2) == IntervalMatrix([[[0,2],[0,4]],[[0,6],[0,8]]]))
|
|
45
|
+
self.assertTrue(IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]).block(0,0,2,2)+Matrix([[1,2],[3,4]]).block(0,0,2,2) == IntervalMatrix([[[0,2],[0,4]],[[0,6],[0,8]]]))
|
|
46
|
+
|
|
47
|
+
# IntervalMatrix operator+(const IM& x1, const IM_& x2)
|
|
48
|
+
self.assertTrue(IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]])+IntervalMatrix([[[1],[2]],[[3],[4]]]) == IntervalMatrix([[[0,2],[0,4]],[[0,6],[0,8]]]))
|
|
49
|
+
self.assertTrue(IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]).block(0,0,2,2)+IntervalMatrix([[[1],[2]],[[3],[4]]]) == IntervalMatrix([[[0,2],[0,4]],[[0,6],[0,8]]]))
|
|
50
|
+
self.assertTrue(IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]])+IntervalMatrix([[[1],[2]],[[3],[4]]]).block(0,0,2,2) == IntervalMatrix([[[0,2],[0,4]],[[0,6],[0,8]]]))
|
|
51
|
+
self.assertTrue(IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]).block(0,0,2,2)+IntervalMatrix([[[1],[2]],[[3],[4]]]).block(0,0,2,2) == IntervalMatrix([[[0,2],[0,4]],[[0,6],[0,8]]]))
|
|
52
|
+
|
|
53
|
+
if __name__ == '__main__':
|
|
54
|
+
unittest.main()
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
# Codac tests
|
|
4
|
+
# ----------------------------------------------------------------------------
|
|
5
|
+
# \date 2024
|
|
6
|
+
# \author Simon Rohou
|
|
7
|
+
# \copyright Copyright 2024 Codac Team
|
|
8
|
+
# \license GNU Lesser General Public License (LGPL)
|
|
9
|
+
|
|
10
|
+
import unittest
|
|
11
|
+
from codac import *
|
|
12
|
+
|
|
13
|
+
class TestArithmeticDiv(unittest.TestCase):
|
|
14
|
+
|
|
15
|
+
def tests_ArithmeticDiv(self):
|
|
16
|
+
|
|
17
|
+
#inline Vector operator/(const Vector& x1, double x2)
|
|
18
|
+
self.assertTrue(Approx(Vector([1,2,3])/10.) == Vector([.1,.2,.3]))
|
|
19
|
+
|
|
20
|
+
#inline IntervalVector operator/(const Vector& x1, const Interval& x2)
|
|
21
|
+
self.assertTrue(Approx(Vector([1,2,3])/Interval(10.,oo)) == IntervalVector([[0,.1],[0,.2],[0,.3]]))
|
|
22
|
+
|
|
23
|
+
#Matrix operator/(const M& x1, double x2)
|
|
24
|
+
self.assertTrue(Approx(Matrix([[1,2],[3,4]])/10.) == Matrix([[.1,.2],[.3,.4]]))
|
|
25
|
+
self.assertTrue(Approx(Matrix([[1,2],[3,4]]).block(0,0,2,2)/10.) == Matrix([[.1,.2],[.3,.4]]))
|
|
26
|
+
|
|
27
|
+
#IntervalMatrix operator/(const M& x1, const Interval& x2)
|
|
28
|
+
self.assertTrue(Approx(Matrix([[1,2],[3,4]])/Interval(10.,oo)) == IntervalMatrix([[[0,.1],[0,.2]],[[0,.3],[0,.4]]]))
|
|
29
|
+
self.assertTrue(Approx(Matrix([[1,2],[3,4]]).block(0,0,2,2)/Interval(10.,oo)) == IntervalMatrix([[[0,.1],[0,.2]],[[0,.3],[0,.4]]]))
|
|
30
|
+
|
|
31
|
+
#inline IntervalVector operator/(const IntervalVector& x1, double x2)
|
|
32
|
+
self.assertTrue(Approx(IntervalVector([[1],[2],[3]])/10.) == IntervalVector([[.1],[.2],[.3]]))
|
|
33
|
+
|
|
34
|
+
#inline IntervalVector operator/(const IntervalVector& x1, const Interval& x2)
|
|
35
|
+
self.assertTrue(Approx(IntervalVector([[1],[2],[3]])/Interval(10.,oo)) == IntervalVector([[0,.1],[0,.2],[0,.3]]))
|
|
36
|
+
|
|
37
|
+
#IntervalMatrix operator/(const IM& x1, double x2)
|
|
38
|
+
self.assertTrue(Approx(IntervalMatrix([[[1],[2]],[[3],[4]]])/10.) == IntervalMatrix([[[.1],[.2]],[[.3],[.4]]]))
|
|
39
|
+
self.assertTrue(Approx(IntervalMatrix([[[1],[2]],[[3],[4]]]).block(0,0,2,2)/10.) == IntervalMatrix([[[.1],[.2]],[[.3],[.4]]]))
|
|
40
|
+
|
|
41
|
+
#IntervalMatrix operator/(const IM& x1, const Interval& x2)
|
|
42
|
+
self.assertTrue(Approx(IntervalMatrix([[[1],[2]],[[3],[4]]])/Interval(10.,oo)) == IntervalMatrix([[[0,.1],[0,.2]],[[0,.3],[0,.4]]]))
|
|
43
|
+
self.assertTrue(Approx(IntervalMatrix([[[1],[2]],[[3],[4]]]).block(0,0,2,2)/Interval(10.,oo)) == IntervalMatrix([[[0,.1],[0,.2]],[[0,.3],[0,.4]]]))
|
|
44
|
+
|
|
45
|
+
if __name__ == '__main__':
|
|
46
|
+
unittest.main()
|