codac4matlab 2.0.0.dev25__cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.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.
Files changed (76) hide show
  1. codac4matlab/__init__.py +4 -0
  2. codac4matlab/_core.cpython-314-aarch64-linux-gnu.so +0 -0
  3. codac4matlab/_graphics.cpython-314-aarch64-linux-gnu.so +0 -0
  4. codac4matlab/_unsupported.cpython-314-aarch64-linux-gnu.so +0 -0
  5. codac4matlab/core/__init__.py +588 -0
  6. codac4matlab/empty.cpython-314-aarch64-linux-gnu.so +0 -0
  7. codac4matlab/graphics/__init__.py +1 -0
  8. codac4matlab/tests/__init__.py +1 -0
  9. codac4matlab/tests/test_AnalyticFunction.py +442 -0
  10. codac4matlab/tests/test_AnalyticTraj.py +62 -0
  11. codac4matlab/tests/test_Approx.py +27 -0
  12. codac4matlab/tests/test_BoolInterval.py +96 -0
  13. codac4matlab/tests/test_Color.py +77 -0
  14. codac4matlab/tests/test_ConvexPolygon.py +300 -0
  15. codac4matlab/tests/test_CtcAction.py +30 -0
  16. codac4matlab/tests/test_CtcCartProd.py +39 -0
  17. codac4matlab/tests/test_CtcCtcBoundary.py +48 -0
  18. codac4matlab/tests/test_CtcDeriv.py +434 -0
  19. codac4matlab/tests/test_CtcEval.py +214 -0
  20. codac4matlab/tests/test_CtcFixpoint.py +65 -0
  21. codac4matlab/tests/test_CtcInter.py +39 -0
  22. codac4matlab/tests/test_CtcInverse.py +213 -0
  23. codac4matlab/tests/test_CtcInverseNotIn.py +129 -0
  24. codac4matlab/tests/test_CtcLazy.py +50 -0
  25. codac4matlab/tests/test_CtcPolygon.py +91 -0
  26. codac4matlab/tests/test_CtcSegment.py +104 -0
  27. codac4matlab/tests/test_Ellipsoid.py +20 -0
  28. codac4matlab/tests/test_GaussJordan.py +34 -0
  29. codac4matlab/tests/test_IntFullPivLU.py +84 -0
  30. codac4matlab/tests/test_Interval.py +254 -0
  31. codac4matlab/tests/test_IntervalMatrix.py +664 -0
  32. codac4matlab/tests/test_IntervalVector.py +657 -0
  33. codac4matlab/tests/test_Interval_operations.py +293 -0
  34. codac4matlab/tests/test_Matrix.py +81 -0
  35. codac4matlab/tests/test_OctaSym.py +41 -0
  36. codac4matlab/tests/test_Parallelepiped.py +35 -0
  37. codac4matlab/tests/test_Parallelepiped_eval.py +62 -0
  38. codac4matlab/tests/test_Polygon.py +120 -0
  39. codac4matlab/tests/test_SampledTraj.py +135 -0
  40. codac4matlab/tests/test_Segment.py +138 -0
  41. codac4matlab/tests/test_SepCartProd.py +34 -0
  42. codac4matlab/tests/test_SepCtcBoundary.py +52 -0
  43. codac4matlab/tests/test_SepInverse.py +104 -0
  44. codac4matlab/tests/test_SepPolygon.py +102 -0
  45. codac4matlab/tests/test_SepProj.py +39 -0
  46. codac4matlab/tests/test_SepTransform.py +41 -0
  47. codac4matlab/tests/test_Slice.py +78 -0
  48. codac4matlab/tests/test_Slice_polygon.py +208 -0
  49. codac4matlab/tests/test_SlicedTube.py +562 -0
  50. codac4matlab/tests/test_SlicedTube_integral.py +380 -0
  51. codac4matlab/tests/test_TDomain.py +115 -0
  52. codac4matlab/tests/test_Vector.py +41 -0
  53. codac4matlab/tests/test_arithmetic_add.py +54 -0
  54. codac4matlab/tests/test_arithmetic_div.py +46 -0
  55. codac4matlab/tests/test_arithmetic_mul.py +114 -0
  56. codac4matlab/tests/test_arithmetic_sub.py +54 -0
  57. codac4matlab/tests/test_capd.py +19 -0
  58. codac4matlab/tests/test_cart_prod.py +38 -0
  59. codac4matlab/tests/test_eigen.py +19 -0
  60. codac4matlab/tests/test_geometry.py +136 -0
  61. codac4matlab/tests/test_hull.py +35 -0
  62. codac4matlab/tests/test_ibex.py +19 -0
  63. codac4matlab/tests/test_inversion.py +57 -0
  64. codac4matlab/tests/test_linear_ctc.py +77 -0
  65. codac4matlab/tests/test_operators.py +377 -0
  66. codac4matlab/tests/test_peibos.py +83 -0
  67. codac4matlab/tests/test_predefined_tubes.py +193 -0
  68. codac4matlab/tests/test_serialization.py +30 -0
  69. codac4matlab/tests/test_transformations.py +61 -0
  70. codac4matlab/tests/test_trunc.py +95 -0
  71. codac4matlab/unsupported/__init__.py +1 -0
  72. codac4matlab/version.py +1 -0
  73. codac4matlab-2.0.0.dev25.dist-info/METADATA +23 -0
  74. codac4matlab-2.0.0.dev25.dist-info/RECORD +76 -0
  75. codac4matlab-2.0.0.dev25.dist-info/WHEEL +6 -0
  76. codac4matlab-2.0.0.dev25.dist-info/top_level.txt +1 -0
@@ -0,0 +1,114 @@
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 TestArithmeticMul(unittest.TestCase):
14
+
15
+ def test_ArithmeticMul(self):
16
+
17
+ # inline Vector operator*(double x1, const Vector& x2)
18
+ self.assertTrue(2.*Vector([1,2]) == Vector([2,4]))
19
+
20
+ # Matrix operator*(double x1, const M& x2)
21
+ self.assertTrue(2.*Matrix([[1,2],[3,4]]) == Matrix([[2,4],[6,8]]))
22
+ self.assertTrue(2.*Matrix([[1,2],[3,4]]).block(0,0,2,2) == Matrix([[2,4],[6,8]]))
23
+
24
+ # inline IntervalVector operator*(double x1, const IntervalVector& x2)
25
+ self.assertTrue(2.*IntervalVector([[-1,1],[-2,2]]) == IntervalVector([[-2,2],[-4,4]]))
26
+
27
+ # IntervalMatrix operator*(double x1, const IM& x2)
28
+ self.assertTrue(2.*IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]) == IntervalMatrix([[[-2,2],[-4,4]],[[-6,6],[-8,8]]]))
29
+ self.assertTrue(2.*IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]).block(0,0,2,2) == IntervalMatrix([[[-2,2],[-4,4]],[[-6,6],[-8,8]]]))
30
+
31
+ # inline IntervalVector operator*(const Interval& x1, const Vector& x2)
32
+ self.assertTrue(Interval(-1,1)*Vector([1,2]) == IntervalVector([[-1,1],[-2,2]]))
33
+
34
+ # IntervalMatrix operator*(const Interval& x1, const M& x2)
35
+ self.assertTrue(Interval(-1,1)*Matrix([[1,2],[3,4]]) == IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]))
36
+ self.assertTrue(Interval(-1,1)*Matrix([[1,2],[3,4]]).block(0,0,2,2) == IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]))
37
+
38
+ # inline IntervalVector operator*(const Interval& x1, const IntervalVector& x2)
39
+ self.assertTrue(Interval(2,oo)*IntervalVector([[1,2],[4,8]]) == IntervalVector([[2,oo],[8,oo]]))
40
+
41
+ # IntervalMatrix operator*(const Interval& x1, const IM& x2)
42
+ self.assertTrue(Interval(-1,1)*IntervalMatrix([[[1,2],[2,3]],[[3,4],[4,5]]]) == IntervalMatrix([[[-2,2],[-3,3]],[[-4,4],[-5,5]]]))
43
+ self.assertTrue(Interval(-1,1)*IntervalMatrix([[[1,2],[2,3]],[[3,4],[4,5]]]).block(0,0,2,2) == IntervalMatrix([[[-2,2],[-3,3]],[[-4,4],[-5,5]]]))
44
+
45
+ # inline Vector operator*(const Vector& x1, double x2)
46
+ self.assertTrue(Vector([1,2])*2. == Vector([2,4]))
47
+
48
+ # inline IntervalVector operator*(const Vector& x1, const Interval& x2)
49
+ self.assertTrue(Vector([1,2])*Interval(-1,1) == IntervalVector([[-1,1],[-2,2]]))
50
+
51
+ # Matrix operator*(const M& x1, double x2)
52
+ self.assertTrue(Matrix([[1,2],[3,4]])*2. == Matrix([[2,4],[6,8]]))
53
+ self.assertTrue(Matrix([[1,2],[3,4]]).block(0,0,2,2)*2. == Matrix([[2,4],[6,8]]))
54
+
55
+ # IntervalMatrix operator*(const M& x1, const Interval& x2)
56
+ self.assertTrue(Matrix([[1,2],[3,4]])*Interval(-1,1) == IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]))
57
+ self.assertTrue(Matrix([[1,2],[3,4]]).block(0,0,2,2)*Interval(-1,1) == IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]))
58
+
59
+ # Vector operator*(const M& x1, const Vector& x2)
60
+ self.assertTrue(Matrix([[1,2],[3,4]])*Vector([5,6]) == Vector([17,39]))
61
+ self.assertTrue(Matrix([[1,2],[3,4]]).block(0,0,2,2)*Vector([5,6]) == Vector([17,39]))
62
+
63
+ # Matrix operator*(const M& x1, const M_& x2)
64
+ self.assertTrue(Matrix([[1,2],[3,4]])*Matrix([[5,6],[7,8]]) == Matrix([[19,22],[43,50]]))
65
+ self.assertTrue(Matrix([[1,2],[3,4]]).block(0,0,2,2)*Matrix([[5,6],[7,8]]) == Matrix([[19,22],[43,50]]))
66
+ self.assertTrue(Matrix([[1,2],[3,4]])*Matrix([[5,6],[7,8]]).block(0,0,2,2) == Matrix([[19,22],[43,50]]))
67
+ self.assertTrue(Matrix([[1,2],[3,4]]).block(0,0,2,2)*Matrix([[5,6],[7,8]]).block(0,0,2,2) == Matrix([[19,22],[43,50]]))
68
+
69
+ # IntervalVector operator*(const M& x1, const IntervalVector& x2)
70
+ self.assertTrue(Matrix([[1,2],[3,4]])*IntervalVector([5,6]) == IntervalVector([17,39]))
71
+ self.assertTrue(Matrix([[1,2],[3,4]]).block(0,0,2,2)*IntervalVector([5,6]) == IntervalVector([17,39]))
72
+
73
+ # IntervalMatrix operator*(const M& x1, const IM& x2)
74
+ self.assertTrue(Matrix([[1,2],[3,4]])*IntervalMatrix([[[5,6],[6,7]],[[7,8],[8,9]]]) == IntervalMatrix([[[19,22],[22,25]],[[43,50],[50,57]]]))
75
+ self.assertTrue(Matrix([[1,2],[3,4]]).block(0,0,2,2)*IntervalMatrix([[[5,6],[6,7]],[[7,8],[8,9]]]) == IntervalMatrix([[[19,22],[22,25]],[[43,50],[50,57]]]))
76
+ self.assertTrue(Matrix([[1,2],[3,4]])*IntervalMatrix([[[5,6],[6,7]],[[7,8],[8,9]]]).block(0,0,2,2) == IntervalMatrix([[[19,22],[22,25]],[[43,50],[50,57]]]))
77
+ self.assertTrue(Matrix([[1,2],[3,4]]).block(0,0,2,2)*IntervalMatrix([[[5,6],[6,7]],[[7,8],[8,9]]]).block(0,0,2,2) == IntervalMatrix([[[19,22],[22,25]],[[43,50],[50,57]]]))
78
+
79
+ # inline IntervalVector operator*(const IntervalVector& x1, double x2)
80
+ self.assertTrue(IntervalVector([[-1,1],[-2,2]])*2. == IntervalVector([[-2,2],[-4,4]]))
81
+
82
+ # inline IntervalVector operator*(const IntervalVector& x1, const Interval& x2)
83
+ self.assertTrue(IntervalVector([[1,2],[4,8]])*Interval(2,oo) == IntervalVector([[2,oo],[8,oo]]))
84
+
85
+ # IntervalMatrix operator*(const IM& x1, double x2)
86
+ self.assertTrue(IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]])*2. == IntervalMatrix([[[-2,2],[-4,4]],[[-6,6],[-8,8]]]))
87
+ self.assertTrue(IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]).block(0,0,2,2)*2. == IntervalMatrix([[[-2,2],[-4,4]],[[-6,6],[-8,8]]]))
88
+
89
+ # IntervalMatrix operator*(const IM& x1, const Interval& x2)
90
+ self.assertTrue(IntervalMatrix([[[1,2],[2,3]],[[3,4],[4,5]]])*Interval(-1,1) == IntervalMatrix([[[-2,2],[-3,3]],[[-4,4],[-5,5]]]))
91
+ self.assertTrue(IntervalMatrix([[[1,2],[2,3]],[[3,4],[4,5]]]).block(0,0,2,2)*Interval(-1,1) == IntervalMatrix([[[-2,2],[-3,3]],[[-4,4],[-5,5]]]))
92
+
93
+ # IntervalVector operator*(const IM& x1, const Vector& x2)
94
+ self.assertTrue(IntervalMatrix([[[1,2],[2,3]],[[3,4],[4,5]]])*Vector([5,6]) == IntervalVector([[17,28],[39,50]]))
95
+ self.assertTrue(IntervalMatrix([[[1,2],[2,3]],[[3,4],[4,5]]]).block(0,0,2,2)*Vector([5,6]) == IntervalVector([[17,28],[39,50]]))
96
+
97
+ # IntervalMatrix operator*(const IM& x1, const M& x2)
98
+ self.assertTrue(IntervalMatrix([[[5,6],[6,7]],[[7,8],[8,9]]])*Matrix([[1,2],[3,4]]) == IntervalMatrix([[[23,27],[34,40]],[[31,35],[46,52]]]))
99
+ self.assertTrue(IntervalMatrix([[[5,6],[6,7]],[[7,8],[8,9]]]).block(0,0,2,2)*Matrix([[1,2],[3,4]]) == IntervalMatrix([[[23,27],[34,40]],[[31,35],[46,52]]]))
100
+ self.assertTrue(IntervalMatrix([[[5,6],[6,7]],[[7,8],[8,9]]])*Matrix([[1,2],[3,4]]).block(0,0,2,2) == IntervalMatrix([[[23,27],[34,40]],[[31,35],[46,52]]]))
101
+ self.assertTrue(IntervalMatrix([[[5,6],[6,7]],[[7,8],[8,9]]]).block(0,0,2,2)*Matrix([[1,2],[3,4]]).block(0,0,2,2) == IntervalMatrix([[[23,27],[34,40]],[[31,35],[46,52]]]))
102
+
103
+ # IntervalVector operator*(const IM& x1, const IntervalVector& x2)
104
+ self.assertTrue(IntervalMatrix([[[1,2],[2,3]],[[3,4],[4,5]]])*IntervalVector([[5,6],[7,8]]) == IntervalVector([[19,36],[43,64]]))
105
+ self.assertTrue(IntervalMatrix([[[1,2],[2,3]],[[3,4],[4,5]]]).block(0,0,2,2)*IntervalVector([[5,6],[7,8]]) == IntervalVector([[19,36],[43,64]]))
106
+
107
+ # IntervalMatrix operator*(const IM& x1, const IM_& x2)
108
+ self.assertTrue(IntervalMatrix([[[5,6],[6,7]],[[7,8],[8,9]]])*IntervalMatrix([[[1,2],[2,3]],[[3,4],[4,5]]]) == IntervalMatrix([[[23,40],[34,53]],[[31,52],[46,69]]]))
109
+ self.assertTrue(IntervalMatrix([[[5,6],[6,7]],[[7,8],[8,9]]]).block(0,0,2,2)*IntervalMatrix([[[1,2],[2,3]],[[3,4],[4,5]]]) == IntervalMatrix([[[23,40],[34,53]],[[31,52],[46,69]]]))
110
+ self.assertTrue(IntervalMatrix([[[5,6],[6,7]],[[7,8],[8,9]]])*IntervalMatrix([[[1,2],[2,3]],[[3,4],[4,5]]]).block(0,0,2,2) == IntervalMatrix([[[23,40],[34,53]],[[31,52],[46,69]]]))
111
+ self.assertTrue(IntervalMatrix([[[5,6],[6,7]],[[7,8],[8,9]]]).block(0,0,2,2)*IntervalMatrix([[[1,2],[2,3]],[[3,4],[4,5]]]).block(0,0,2,2) == IntervalMatrix([[[23,40],[34,53]],[[31,52],[46,69]]]))
112
+
113
+ if __name__ == '__main__':
114
+ 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 test_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([-4,-4,-4]))
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([[-2,-2],[-2,-2]]))
25
+ self.assertTrue(Matrix([[1,2],[3,4]]).block(0,0,2,2)-Matrix([[3,4],[5,6]]) == Matrix([[-2,-2],[-2,-2]]))
26
+ self.assertTrue(Matrix([[1,2],[3,4]])-Matrix([[3,4],[5,6]]).block(0,0,2,2) == Matrix([[-2,-2],[-2,-2]]))
27
+ self.assertTrue(Matrix([[1,2],[3,4]]).block(0,0,2,2)-Matrix([[3,4],[5,6]]).block(0,0,2,2) == Matrix([[-2,-2],[-2,-2]]))
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([[-2,0],[-4,0],[-6,0]]))
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([[-2,0],[-4,0],[-6,0]]))
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([[[-2,0],[-4,0]],[[-6,0],[-8,0]]]))
43
+ self.assertTrue(IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]).block(0,0,2,2)-Matrix([[1,2],[3,4]]) == IntervalMatrix([[[-2,0],[-4,0]],[[-6,0],[-8,0]]]))
44
+ self.assertTrue(IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]])-Matrix([[1,2],[3,4]]).block(0,0,2,2) == IntervalMatrix([[[-2,0],[-4,0]],[[-6,0],[-8,0]]]))
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([[[-2,0],[-4,0]],[[-6,0],[-8,0]]]))
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([[[-2,0],[-4,0]],[[-6,0],[-8,0]]]))
49
+ self.assertTrue(IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]]).block(0,0,2,2)-IntervalMatrix([[[1],[2]],[[3],[4]]]) == IntervalMatrix([[[-2,0],[-4,0]],[[-6,0],[-8,0]]]))
50
+ self.assertTrue(IntervalMatrix([[[-1,1],[-2,2]],[[-3,3],[-4,4]]])-IntervalMatrix([[[1],[2]],[[3],[4]]]).block(0,0,2,2) == IntervalMatrix([[[-2,0],[-4,0]],[[-6,0],[-8,0]]]))
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([[[-2,0],[-4,0]],[[-6,0],[-8,0]]]))
52
+
53
+ if __name__ == '__main__':
54
+ unittest.main()
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Codac tests
4
+ # ----------------------------------------------------------------------------
5
+ # \date 2024
6
+ # \author Maël Godard
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 TestCAPD(unittest.TestCase):
14
+
15
+ def test_capd(self):
16
+ self.assertTrue(True)
17
+
18
+ if __name__ == '__main__':
19
+ unittest.main()
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Codac tests
4
+ # ----------------------------------------------------------------------------
5
+ # \date 2024
6
+ # \author Gilles Chabert, 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
+ import sys
13
+ import math
14
+
15
+ class TestIntervalVector(unittest.TestCase):
16
+
17
+ def test_cart_prod_vector(self):
18
+
19
+ self.assertTrue(cart_prod(Vector([3])) == Vector([3]))
20
+ self.assertTrue(cart_prod(1,2,3.5) == Vector([1,2,3.5]))
21
+ self.assertTrue(cart_prod(1,2,3.5,Vector.ones(2)) == Vector([1,2,3.5,1,1]))
22
+ self.assertTrue(cart_prod(Vector.ones(2),1,2,3.5) == Vector([1,1,1,2,3.5]))
23
+ self.assertTrue(cart_prod(Vector.zero(3)) == Vector.zero(3))
24
+ self.assertTrue(cart_prod(Vector.zero(3),Vector.ones(4)) == Vector([0,0,0,1,1,1,1]))
25
+
26
+ def test_cart_prod_intervalvector(self):
27
+
28
+ self.assertTrue(cart_prod(IntervalVector([[0,1]])) == IntervalVector([[0,1]]))
29
+ self.assertTrue(cart_prod(IntervalVector([[0,1],[2,3],[4,5]]),IntervalVector.empty(3)).is_empty())
30
+ self.assertTrue(cart_prod(IntervalVector.empty(3),IntervalVector([[0,1],[2,3],[4,5]])).is_empty())
31
+ self.assertTrue(cart_prod([[0,1],[2,3],[4,5]]) == IntervalVector([[0,1],[2,3],[4,5]]))
32
+ self.assertTrue(cart_prod(IntervalVector.empty(3)) == IntervalVector.empty(3))
33
+ self.assertTrue(cart_prod([[0,1],[2,3],[4,5]],[[8,9]]) == IntervalVector([[0,1],[2,3],[4,5],[8,9]]))
34
+ self.assertTrue(cart_prod(25.,[[0,1],[2,3],[4,5]],[[8,9]],Vector.ones(3)) == IntervalVector([[25],[0,1],[2,3],[4,5],[8,9],[1],[1],[1]]))
35
+ self.assertTrue(cart_prod([-oo,oo],[-oo,oo],42.) == IntervalVector([[-oo,oo],[-oo,oo],[42.,42.]]))
36
+
37
+ if __name__ == '__main__':
38
+ unittest.main()
@@ -0,0 +1,19 @@
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 TestEigen(unittest.TestCase):
14
+
15
+ def test_eigen(self):
16
+ self.assertTrue(True)
17
+
18
+ if __name__ == '__main__':
19
+ unittest.main()
@@ -0,0 +1,136 @@
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 TestGeometry(unittest.TestCase):
14
+
15
+ def test_orientation(self):
16
+
17
+ # Align points
18
+ self.assertTrue(orientation([0.,0.],[5.,0.],[8.,0.]) == OrientationInterval.COLINEAR)
19
+ self.assertTrue(orientation([0.,0.],[5.,0.],[-2.,0.]) == OrientationInterval.COLINEAR)
20
+ self.assertTrue(orientation([0.,0.],[-2.,0.],[5.,0.]) == OrientationInterval.COLINEAR)
21
+ self.assertTrue(orientation([0.,0.],[0.,0.],[5.,0.]) == OrientationInterval.COLINEAR)
22
+ self.assertTrue(orientation([0.,0.],[0.,0.],[0.,0.]) == OrientationInterval.COLINEAR)
23
+
24
+ # Clockwise points
25
+ self.assertTrue(orientation([0.,0.],[0.,-5.],[-2.,-5.]) == OrientationInterval.COUNTERCLOCKWISE)
26
+ self.assertTrue(orientation([-999.,0.1],[0.,0.],[-999.,-0.1]) == OrientationInterval.COUNTERCLOCKWISE)
27
+
28
+ # Anticlockwise points
29
+ self.assertTrue(orientation([0.,0.],[0.,-5.],[2.,-5.]) == OrientationInterval.CLOCKWISE)
30
+ self.assertTrue(orientation([999.,0.1],[0.,0.],[999.,-0.1]) == OrientationInterval.CLOCKWISE)
31
+
32
+ # Other tests
33
+ self.assertTrue(orientation([0,0],[1,1],[0,2]) == OrientationInterval.CLOCKWISE)
34
+ self.assertTrue(orientation([0,0],[1,1],[2,2]) == OrientationInterval.COLINEAR)
35
+ self.assertTrue(orientation([0,0],[1,1],[2.2,2]) == OrientationInterval.COUNTERCLOCKWISE)
36
+ self.assertTrue(orientation([0,0],[2,2],[2,2]) == OrientationInterval.COLINEAR)
37
+ self.assertTrue(orientation([0,0],[2,2],[4,4]) == OrientationInterval.COLINEAR)
38
+ self.assertTrue(orientation([0,0],[8,8],[4,4]) == OrientationInterval.COLINEAR)
39
+ self.assertTrue(orientation([0,0],[10,1],[4,4]) == OrientationInterval.CLOCKWISE)
40
+ self.assertTrue(orientation([0,0],[2,2],[10,1]) == OrientationInterval.COUNTERCLOCKWISE)
41
+
42
+ def test_alignments(self):
43
+
44
+ # Alignments
45
+ p1 = IntervalVector([0.,0.])
46
+ p2 = IntervalVector([0.,1.])
47
+ p3 = IntervalVector([0.,10.])
48
+ p4 = IntervalVector([1.,10.])
49
+ p5 = IntervalVector([0.,9.+1e-8*Interval(-1.,1.)])
50
+ p6 = IntervalVector([0.+1e-8*Interval(-1.,1.),9.])
51
+ p7 = IntervalVector([0.+1e-8*Interval(-1.,1.),9.+1e-8*Interval(-1.,1.)])
52
+
53
+ self.assertTrue(aligned(p1,p2,p3) == BoolInterval.TRUE)
54
+ self.assertTrue(aligned(p1,p2,p4) == BoolInterval.FALSE)
55
+ self.assertTrue(aligned(p1,p1,p4) == BoolInterval.TRUE)
56
+ self.assertTrue(aligned(p1,p2,p5) == BoolInterval.TRUE)
57
+ self.assertTrue(aligned(p1,p2,p6) == BoolInterval.UNKNOWN)
58
+ self.assertTrue(aligned(p1,p2,p7) == BoolInterval.UNKNOWN)
59
+ self.assertTrue(aligned([0,0],[1,1],[10,10]) == BoolInterval.TRUE)
60
+ self.assertTrue(aligned([[-oo,0],[-oo,0]],[1,1],[10,10]) == BoolInterval.UNKNOWN)
61
+ self.assertTrue(aligned(IntervalVector(2),[1,1],[10,10]) == BoolInterval.UNKNOWN)
62
+
63
+ def test_convex_hull(self):
64
+
65
+ v = [
66
+ [0,3],[1,1],[2,2],[4,4],[0,0],[1,2],[3,1],[3,3]
67
+ ]
68
+
69
+ hull = convex_hull(v)
70
+
71
+ self.assertTrue(hull[0] == IntervalVector([0,0]))
72
+ self.assertTrue(hull[1] == IntervalVector([3,1]))
73
+ self.assertTrue(hull[2] == IntervalVector([4,4]))
74
+ self.assertTrue(hull[3] == IntervalVector([0,3]))
75
+ self.assertTrue(len(hull) == 4)
76
+
77
+ v = [
78
+ [1,3],[1,4],[1.5,2],[2,1],[2,2],[3,0],
79
+ [3,3],[3,4.5],[4,2.5],[4,4],[5,1],[5,2],
80
+ [4,0],[5,0],[5,5],[6,0],[7,2]
81
+ ]
82
+
83
+ hull = convex_hull(v)
84
+
85
+ self.assertTrue(hull[0] == IntervalVector([3,0]))
86
+ self.assertTrue(hull[1] == IntervalVector([6,0]))
87
+ self.assertTrue(hull[2] == IntervalVector([7,2]))
88
+ self.assertTrue(hull[3] == IntervalVector([5,5]))
89
+ self.assertTrue(hull[4] == IntervalVector([3,4.5]))
90
+ self.assertTrue(hull[5] == IntervalVector([1,4]))
91
+ self.assertTrue(hull[6] == IntervalVector([1,3]))
92
+ self.assertTrue(hull[7] == IntervalVector([1.5,2]))
93
+ self.assertTrue(hull[8] == IntervalVector([2,1]))
94
+ self.assertTrue(len(hull) == 9)
95
+
96
+ v = [
97
+ [0.307007,0.0340742],
98
+ [0.0340742,0.307],
99
+ [0.1,0.2],[0.1,0.2],[0.2,0.1],[0.1,0.1]
100
+ ]
101
+
102
+ hull = convex_hull(v)
103
+
104
+ self.assertTrue(hull[0] == IntervalVector([0.307007,0.0340742]))
105
+ self.assertTrue(hull[1] == IntervalVector([0.0340742,0.307]))
106
+ self.assertTrue(hull[2] == IntervalVector([0.1,0.1]))
107
+ self.assertTrue(len(hull) == 3)
108
+
109
+ # Other test
110
+
111
+ v = [
112
+ [-4041.935273669676917052129283547401428223,-5492.667604696881426207255572080612182617],
113
+ [-2103.177277725693329557543620467185974121,-5492.667604696881426207255572080612182617],
114
+ [5720.923292917194885376375168561935424805,-975.4210340695084369144751690328121185303],
115
+ [9206.843580880462468485347926616668701172,5062.370015818080901226494461297988891602],
116
+ [52.79381299725321952109879930503666400909,5062.370015818080901226494461297988891602],
117
+ [-4041.935273669676917052129283547401428223-1,-5592.667604696874150249641388654708862305],
118
+ [9206.843580880462468485347926616668701172,6551.674997467660432448610663414001464844],
119
+ [52.79381299725321952109879930503666400909,6551.674997467660432448610663414001464844],
120
+ [-4041.935273669676917052129283547401428223,-540.603823869623056452837772667407989502]
121
+ ]
122
+ v_save = v
123
+
124
+ hull = convex_hull(v)
125
+
126
+ self.assertTrue(hull[0] == v_save[5])
127
+ self.assertTrue(hull[1] == v_save[1])
128
+ self.assertTrue(hull[2] == v_save[2])
129
+ self.assertTrue(hull[3] == v_save[3])
130
+ self.assertTrue(hull[4] == v_save[6])
131
+ self.assertTrue(hull[5] == v_save[7])
132
+ self.assertTrue(hull[6] == v_save[8])
133
+ self.assertTrue(len(hull) == 7)
134
+
135
+ if __name__ == '__main__':
136
+ unittest.main()
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Codac tests
4
+ # ----------------------------------------------------------------------------
5
+ # \date 2024
6
+ # \author Gilles Chabert, 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
+ import sys
13
+ import math
14
+
15
+ class TestHull(unittest.TestCase):
16
+
17
+ def test_hull_IntervalVector(self):
18
+
19
+ self.assertTrue(hull(Vector([1,2])) == IntervalVector([[1,1],[2,2]]))
20
+ self.assertTrue(hull(Vector([1,2]),Vector([1,2]),Vector([1,2]),Vector([1,2])) == IntervalVector([[1,1],[2,2]]))
21
+ self.assertTrue(hull(Vector([1,2]),Vector([9,10])) == IntervalVector([[1,9],[2,10]]))
22
+ self.assertTrue(hull(Vector([1,2]),IntervalVector([9,10])) == IntervalVector([[1,9],[2,10]]))
23
+ self.assertTrue(hull(IntervalVector([1,2]),Vector([9,10])) == IntervalVector([[1,9],[2,10]]))
24
+ self.assertTrue(hull(IntervalVector([1,2]),IntervalVector([9,10])) == IntervalVector([[1,9],[2,10]]))
25
+ self.assertTrue(hull(IntervalVector([1,2]),IntervalVector.empty(2)) == IntervalVector([[1,1],[2,2]]))
26
+ self.assertTrue(hull(IntervalVector([1,2])) == IntervalVector([[1,1],[2,2]]))
27
+ self.assertTrue(hull(2.*IntervalVector([1,2])) == IntervalVector([[2,2],[4,4]]))
28
+
29
+ def test_hull_IntervalMatrix(self):
30
+
31
+ self.assertTrue(hull(Matrix([[1,2],[3,4]])) == IntervalMatrix(Matrix([[1,2],[3,4]])))
32
+ self.assertTrue(hull(3.*Matrix([[1,2],[3,4]])) == IntervalMatrix(Matrix([[3,6],[9,12]])))
33
+
34
+ if __name__ == '__main__':
35
+ unittest.main()
@@ -0,0 +1,19 @@
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 TestIbex(unittest.TestCase):
14
+
15
+ def test_ibex(self):
16
+ self.assertTrue(True) # IBEX is not available in Python
17
+
18
+ if __name__ == '__main__':
19
+ unittest.main()
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Codac tests
4
+ # ----------------------------------------------------------------------------
5
+ # \date 2024
6
+ # \author Damien Massé
7
+ # \copyright Copyright 2024 Codac Team
8
+ # \license GNU Lesser General Public License (LGPL)
9
+
10
+
11
+ import unittest
12
+ from codac import *
13
+
14
+ class TestInversion(unittest.TestCase):
15
+
16
+ def test_Inversion_1(self):
17
+
18
+ x = Matrix([
19
+ [ 1, 2, 0 ],
20
+ [ 3, 4, 1 ],
21
+ [ 0, 1, 0 ],
22
+ ])
23
+
24
+ y = inverse_enclosure(x)
25
+ self.assertTrue((x*y).contains(Matrix.eye(3,3)))
26
+
27
+
28
+ def test_Inversion_2(self):
29
+
30
+ x = IntervalMatrix([
31
+ [ [0.0,0.0], [-0.1,-0.1], [0.2,0.2] ],
32
+ [ [0.0,0.0], [-0.2,-0.2], [0.1,0.1] ],
33
+ [ [0.1,0.1], [-0.1,-0.1], [0.1,0.1] ]
34
+ ])
35
+
36
+ y = infinite_sum_enclosure(x)
37
+ #self.assertTrue(Approx(y.max_rad())==Interval(5.0)/Interval(2.0))
38
+
39
+ z = inverse_enclosure(x)
40
+ self.assertTrue(z(1,2)==Interval(0))
41
+ self.assertTrue(Approx(z*x)==IntervalMatrix.eye(3,3))
42
+
43
+
44
+ def test_Inversion_3(self):
45
+
46
+ u = Matrix([
47
+ [ 1,2,3 ],
48
+ [ 1,3,5 ],
49
+ [ 3,4,5 ]
50
+ ])
51
+
52
+ v = inverse_enclosure(u)
53
+ self.assertTrue((u*v).contains(Matrix.eye(3,3)))
54
+
55
+
56
+ if __name__ == '__main__':
57
+ unittest.main()
@@ -0,0 +1,77 @@
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 TestLinearCtc(unittest.TestCase):
14
+
15
+ def test_linear_ctc(self):
16
+
17
+ A = IntervalMatrix([
18
+ [[4,5],[-1,1],[1.5,2.5]],
19
+ [[-0.5,0.5],[-7,-5],[1,2]],
20
+ [[-1.5,-0.5],[-0.7,-0.5],[2,3]]
21
+ ])
22
+ x = IntervalVector([[-oo,oo],[-oo,oo],[-oo,oo]])
23
+ b = IntervalVector([[3,4],[0,2],[3,4]])
24
+
25
+ # Numerical values come from the book:
26
+ # Applied Interval Analysis
27
+ # Luc Jaulin, Michel Kieffer, Olivier Didrit, Éric Walter
28
+ # 2001, Springer London
29
+ # doi: https:#doi.org/10.1007/978-1-4471-0249-6
30
+
31
+ # CtcGaussElim
32
+
33
+ ctc_ge = CtcGaussElim()
34
+ ctc_ge.contract(A,x,b)
35
+ self.assertTrue(Approx(x) == IntervalVector([
36
+ [-1.819278874340436,1.168720384766974],
37
+ [-0.4140698379116945,1.725229626734416],
38
+ [0.7002320584443487,3.42075434825093]
39
+ ]))
40
+
41
+ # CtcGaussSeidel
42
+
43
+ ctc_gs = CtcGaussSeidel()
44
+ x = IntervalVector([[-10,10],[-10,10],[-10,10]])
45
+ for k in range(0,100):
46
+ ctc_gs.contract(A,x,b)
47
+ self.assertTrue(Approx(x) == IntervalVector([
48
+ [-2.084512144759555,1.63672286912456],
49
+ [-0.7369829550424718,1.74356809144887],
50
+ [-0.3213286433350618,3.837791484351055]
51
+ ]))
52
+
53
+ # CtcGaussSeidel with preconditioning
54
+
55
+ ctc_gsp = CtcLinearPrecond(ctc_gs)
56
+ x = IntervalVector([[-10,10],[-10,10],[-10,10]])
57
+ for k in range(0,100):
58
+ ctc_gsp.contract(A,x,b)
59
+ self.assertTrue(Approx(x) == IntervalVector([
60
+ [-1.106970597649814,1.383669626776028],
61
+ [-0.8113846871807701,1.332001097010008],
62
+ [0.5757415290046493,2.984085335831012]
63
+ ]))
64
+
65
+ # CtcGaussElim with preconditioning
66
+
67
+ ctc_gep = CtcLinearPrecond(ctc_ge)
68
+ x = IntervalVector([[-oo,oo],[-oo,oo],[-oo,oo]])
69
+ ctc_gep.contract(A,x,b)
70
+ self.assertTrue(Approx(x) == IntervalVector([
71
+ [-1.106970597649814,1.383669626776028],
72
+ [-0.7852408901116992,1.332001097010009],
73
+ [0.7583501672635362,2.984085335831012]
74
+ ]))
75
+
76
+ if __name__ == '__main__':
77
+ unittest.main()