codac4matlab 2.0.0.dev25__cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.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.cpython-314t-x86_64-linux-gnu.so +0 -0
- codac4matlab/_graphics.cpython-314t-x86_64-linux-gnu.so +0 -0
- codac4matlab/_unsupported.cpython-314t-x86_64-linux-gnu.so +0 -0
- codac4matlab/core/__init__.py +588 -0
- codac4matlab/empty.cpython-314t-x86_64-linux-gnu.so +0 -0
- codac4matlab/graphics/__init__.py +1 -0
- codac4matlab/tests/__init__.py +1 -0
- codac4matlab/tests/test_AnalyticFunction.py +442 -0
- codac4matlab/tests/test_AnalyticTraj.py +62 -0
- codac4matlab/tests/test_Approx.py +27 -0
- codac4matlab/tests/test_BoolInterval.py +96 -0
- codac4matlab/tests/test_Color.py +77 -0
- codac4matlab/tests/test_ConvexPolygon.py +300 -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_CtcDeriv.py +434 -0
- codac4matlab/tests/test_CtcEval.py +214 -0
- codac4matlab/tests/test_CtcFixpoint.py +65 -0
- codac4matlab/tests/test_CtcInter.py +39 -0
- codac4matlab/tests/test_CtcInverse.py +213 -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_GaussJordan.py +34 -0
- codac4matlab/tests/test_IntFullPivLU.py +84 -0
- codac4matlab/tests/test_Interval.py +254 -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 +81 -0
- codac4matlab/tests/test_OctaSym.py +41 -0
- codac4matlab/tests/test_Parallelepiped.py +35 -0
- codac4matlab/tests/test_Parallelepiped_eval.py +62 -0
- codac4matlab/tests/test_Polygon.py +120 -0
- codac4matlab/tests/test_SampledTraj.py +135 -0
- codac4matlab/tests/test_Segment.py +138 -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_Slice.py +78 -0
- codac4matlab/tests/test_Slice_polygon.py +208 -0
- codac4matlab/tests/test_SlicedTube.py +562 -0
- codac4matlab/tests/test_SlicedTube_integral.py +380 -0
- codac4matlab/tests/test_TDomain.py +115 -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 +38 -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 +377 -0
- codac4matlab/tests/test_peibos.py +83 -0
- codac4matlab/tests/test_predefined_tubes.py +193 -0
- codac4matlab/tests/test_serialization.py +30 -0
- codac4matlab/tests/test_transformations.py +61 -0
- codac4matlab/tests/test_trunc.py +95 -0
- codac4matlab/unsupported/__init__.py +1 -0
- codac4matlab/version.py +1 -0
- codac4matlab-2.0.0.dev25.dist-info/METADATA +23 -0
- codac4matlab-2.0.0.dev25.dist-info/RECORD +76 -0
- codac4matlab-2.0.0.dev25.dist-info/WHEEL +6 -0
- codac4matlab-2.0.0.dev25.dist-info/top_level.txt +1 -0
codac4matlab/__init__.py
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
from codac4matlab._core import *
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
def codac_error(message):
|
|
5
|
+
print(f'''
|
|
6
|
+
=============================================================================
|
|
7
|
+
The following Codac assertion failed:
|
|
8
|
+
|
|
9
|
+
{message}
|
|
10
|
+
|
|
11
|
+
You need help? Submit an issue on: https://github.com/codac-team/codac/issues
|
|
12
|
+
=============================================================================
|
|
13
|
+
''')
|
|
14
|
+
raise ValueError("")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class AnalyticFunction:
|
|
18
|
+
|
|
19
|
+
def __init__(self, args, e=None):
|
|
20
|
+
if e:
|
|
21
|
+
if isinstance(e, (int,float,Interval,ScalarVar,ScalarExpr)):
|
|
22
|
+
self.f = AnalyticFunction_Scalar(args,ScalarExpr(e))
|
|
23
|
+
elif isinstance(e, (Vector,IntervalVector,VectorVar,VectorExpr)):
|
|
24
|
+
self.f = AnalyticFunction_Vector(args,VectorExpr(e))
|
|
25
|
+
elif isinstance(e, (Matrix,IntervalMatrix,MatrixVar,MatrixExpr)):
|
|
26
|
+
self.f = AnalyticFunction_Matrix(args,MatrixExpr(e))
|
|
27
|
+
elif isinstance(e, list):
|
|
28
|
+
lst=[]
|
|
29
|
+
for e_i in e:
|
|
30
|
+
if isinstance(e_i, (int,float,Interval,ScalarVar,ScalarExpr)):
|
|
31
|
+
lst.append(ScalarExpr(e_i))
|
|
32
|
+
else:
|
|
33
|
+
codac_error("AnalyticFunction: invalid vectorial expression")
|
|
34
|
+
self.f = AnalyticFunction_Vector(args,lst)
|
|
35
|
+
else:
|
|
36
|
+
codac_error("AnalyticFunction: can only build functions from scalar or vector expressions")
|
|
37
|
+
else:
|
|
38
|
+
if isinstance(args, (AnalyticFunction_Scalar,AnalyticFunction_Vector,AnalyticFunction_Matrix)):
|
|
39
|
+
self.f = args
|
|
40
|
+
elif isinstance(args, (AnalyticFunction)):
|
|
41
|
+
self.f = args.f
|
|
42
|
+
else:
|
|
43
|
+
codac_error("AnalyticFunction: invalid function argument")
|
|
44
|
+
|
|
45
|
+
def input_size(self):
|
|
46
|
+
return self.f.input_size()
|
|
47
|
+
|
|
48
|
+
def output_size(self):
|
|
49
|
+
return self.f.output_size()
|
|
50
|
+
|
|
51
|
+
def nb_args(self):
|
|
52
|
+
return self.f.nb_args()
|
|
53
|
+
|
|
54
|
+
def args(self):
|
|
55
|
+
return self.f.args()
|
|
56
|
+
|
|
57
|
+
def real_eval(self,*args):
|
|
58
|
+
return self.f.real_eval(*args)
|
|
59
|
+
|
|
60
|
+
def eval(self,m,*args):
|
|
61
|
+
return self.f.eval(m,*args)
|
|
62
|
+
|
|
63
|
+
def eval(self,*args):
|
|
64
|
+
return self.f.eval(*args)
|
|
65
|
+
|
|
66
|
+
def traj_eval(self,*args):
|
|
67
|
+
return self.f.traj_eval(*args)
|
|
68
|
+
|
|
69
|
+
def tube_eval(self,*args):
|
|
70
|
+
return self.f.tube_eval(*args)
|
|
71
|
+
|
|
72
|
+
def parallelepiped_eval(self,*args):
|
|
73
|
+
return self.f.parallelepiped_eval(*args)
|
|
74
|
+
|
|
75
|
+
def diff(self,*args):
|
|
76
|
+
return self.f.diff(*args)
|
|
77
|
+
|
|
78
|
+
def __call__(self,*args):
|
|
79
|
+
lst=[]
|
|
80
|
+
for arg in args:
|
|
81
|
+
if isinstance(arg, (int,float,Interval,ScalarVar,ScalarExpr)):
|
|
82
|
+
lst.append(ScalarExpr(arg))
|
|
83
|
+
elif isinstance(arg, (Vector,IntervalVector,VectorVar,VectorExpr)):
|
|
84
|
+
lst.append(VectorExpr(arg))
|
|
85
|
+
elif isinstance(arg, (Matrix,IntervalMatrix,MatrixVar,MatrixExpr)):
|
|
86
|
+
lst.append(MatrixExpr(arg))
|
|
87
|
+
else:
|
|
88
|
+
codac_error("AnalyticFunction: invalid input arguments")
|
|
89
|
+
return self.f(lst)
|
|
90
|
+
|
|
91
|
+
def __repr__(self):
|
|
92
|
+
return str(self.f)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class Ctc_IntervalVector(Ctc_IntervalVector_):
|
|
96
|
+
|
|
97
|
+
def __init__(self, n):
|
|
98
|
+
Ctc_IntervalVector_.__init__(self,n)
|
|
99
|
+
|
|
100
|
+
def copy(self):
|
|
101
|
+
return super().copy()
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class Sep(SepBase):
|
|
105
|
+
|
|
106
|
+
def copy(self):
|
|
107
|
+
return super().copy()
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class CtcInverse(Ctc_IntervalVector):
|
|
111
|
+
|
|
112
|
+
def __init__(self, f, y, with_centered_form = True):
|
|
113
|
+
|
|
114
|
+
if f.nb_args() > 1:
|
|
115
|
+
total_var = VectorVar(f.input_size())
|
|
116
|
+
|
|
117
|
+
i = 0
|
|
118
|
+
f_args = []
|
|
119
|
+
for a in f.args():
|
|
120
|
+
if a.size() == 1:
|
|
121
|
+
f_args.append(total_var.get_item_0(i))
|
|
122
|
+
i = i+1
|
|
123
|
+
else:
|
|
124
|
+
f_args.append(total_var.subvector_0(i,i+a.size()-1))
|
|
125
|
+
i = i+a.size()
|
|
126
|
+
|
|
127
|
+
g = AnalyticFunction([total_var], f(*f_args))
|
|
128
|
+
CtcInverse.__init__(self, g, y, with_centered_form)
|
|
129
|
+
|
|
130
|
+
else:
|
|
131
|
+
Ctc_IntervalVector.__init__(self, f.input_size())
|
|
132
|
+
if isinstance(f.f, AnalyticFunction_Scalar):
|
|
133
|
+
if not (isinstance(y, (int,float,Interval))
|
|
134
|
+
or (isinstance(y, list) and len(y) > 0 and len(y) <= 2 and isinstance(y[0], (int,float)))):
|
|
135
|
+
codac_error("CtcInverse: inverse argument 'y' should be a scalar type (float,Interval)")
|
|
136
|
+
self.c = CtcInverse_Interval(f.f,Interval(y),with_centered_form)
|
|
137
|
+
elif isinstance(f.f, AnalyticFunction_Vector):
|
|
138
|
+
if not isinstance(y, (Vector,IntervalVector,list,Ctc_IntervalVector,Ctc_IntervalVector_)):
|
|
139
|
+
codac_error("CtcInverse: inverse argument 'y' should be a vector type (Vector,IntervalVector,Ctc_IntervalVector,Ctc_IntervalVector_)")
|
|
140
|
+
if isinstance(y, (Ctc_IntervalVector,Ctc_IntervalVector_)):
|
|
141
|
+
self.c = CtcInverse_IntervalVector(f,y,with_centered_form)
|
|
142
|
+
else:
|
|
143
|
+
self.c = CtcInverse_IntervalVector(f.f,IntervalVector(y),with_centered_form)
|
|
144
|
+
else:
|
|
145
|
+
codac_error("CtcInverse: can only build CtcInverse from scalar or vector functions")
|
|
146
|
+
|
|
147
|
+
def contract(self,*x):
|
|
148
|
+
|
|
149
|
+
if len(x) == 1:
|
|
150
|
+
return self.c.contract(x[0])
|
|
151
|
+
|
|
152
|
+
else:
|
|
153
|
+
total = cart_prod(*x)
|
|
154
|
+
total = self.c.contract(total)
|
|
155
|
+
i = 0
|
|
156
|
+
for xi in x:
|
|
157
|
+
k = xi.size()
|
|
158
|
+
if k==1:
|
|
159
|
+
xi &= total.get_item_0(i)
|
|
160
|
+
else:
|
|
161
|
+
xi &= total.subvector_0(i,i+k-1)
|
|
162
|
+
i = i+k
|
|
163
|
+
return x
|
|
164
|
+
|
|
165
|
+
def contract_tube(self,*x):
|
|
166
|
+
|
|
167
|
+
if len(x) == 1:
|
|
168
|
+
return self.c.contract_tube(x[0])
|
|
169
|
+
|
|
170
|
+
else:
|
|
171
|
+
total = tube_cart_prod(*x)
|
|
172
|
+
total = self.c.contract_tube(total)
|
|
173
|
+
i = 0
|
|
174
|
+
for xi in x:
|
|
175
|
+
k = xi.size()
|
|
176
|
+
if k==1:
|
|
177
|
+
xi &= total.get_item_0(i)
|
|
178
|
+
else:
|
|
179
|
+
xi &= total.subvector_0(i,i+k-1)
|
|
180
|
+
i = i+k
|
|
181
|
+
return x
|
|
182
|
+
|
|
183
|
+
def copy(self):
|
|
184
|
+
return self.c.copy()
|
|
185
|
+
|
|
186
|
+
def fnc(self):
|
|
187
|
+
return self.c.fnc()
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class CtcInverseNotIn(Ctc_IntervalVector):
|
|
191
|
+
|
|
192
|
+
def __init__(self, f, y, with_centered_form = True):
|
|
193
|
+
Ctc_IntervalVector.__init__(self, f.input_size())
|
|
194
|
+
if isinstance(f.f, AnalyticFunction_Scalar):
|
|
195
|
+
if not (isinstance(y, (int,float,Interval))
|
|
196
|
+
or (isinstance(y, list) and len(y) > 0 and len(y) <= 2 and isinstance(y[0], (int,float)))):
|
|
197
|
+
codac_error("CtcInverseNotIn: inverse argument 'y' should be a scalar type (float,Interval)")
|
|
198
|
+
self.c = CtcInverseNotIn_Interval(f.f,Interval(y),with_centered_form)
|
|
199
|
+
elif isinstance(f.f, AnalyticFunction_Vector):
|
|
200
|
+
if not isinstance(y, (Vector,IntervalVector,list)):
|
|
201
|
+
codac_error("CtcInverseNotIn: inverse argument 'y' should be a vector type (Vector,IntervalVector)")
|
|
202
|
+
self.c = CtcInverseNotIn_IntervalVector(f.f,IntervalVector(y),with_centered_form)
|
|
203
|
+
else:
|
|
204
|
+
codac_error("CtcInverseNotIn: can only build CtcInverseNotIn from scalar or vector functions")
|
|
205
|
+
|
|
206
|
+
def contract(self,x):
|
|
207
|
+
return self.c.contract(x)
|
|
208
|
+
|
|
209
|
+
def copy(self):
|
|
210
|
+
return self.c.copy()
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
class Approx:
|
|
214
|
+
|
|
215
|
+
def __init__(self, x, eps = sys.float_info.epsilon*10):
|
|
216
|
+
if isinstance(x, (int,float)):
|
|
217
|
+
self.a = Approx_double(x,eps)
|
|
218
|
+
elif isinstance(x, (Interval)):
|
|
219
|
+
self.a = Approx_Interval(x,eps)
|
|
220
|
+
elif isinstance(x, (Vector)):
|
|
221
|
+
self.a = Approx_Vector(x,eps)
|
|
222
|
+
elif isinstance(x, (IntervalVector)):
|
|
223
|
+
self.a = Approx_IntervalVector(x,eps)
|
|
224
|
+
elif isinstance(x, (Matrix)):
|
|
225
|
+
self.a = Approx_Matrix(x,eps)
|
|
226
|
+
elif isinstance(x, (IntervalMatrix)):
|
|
227
|
+
self.a = Approx_IntervalMatrix(x,eps)
|
|
228
|
+
elif isinstance(x, (Segment)):
|
|
229
|
+
self.a = Approx_Segment(x,eps)
|
|
230
|
+
elif isinstance(x, (Polygon,ConvexPolygon)):
|
|
231
|
+
self.a = Approx_Polygon(x,eps)
|
|
232
|
+
elif isinstance(x, tuple) and isinstance(x[0], Interval) and isinstance(x[1], Interval):
|
|
233
|
+
self.a = Approx_pair_Interval(x,eps)
|
|
234
|
+
else:
|
|
235
|
+
codac_error("Approx: can only build Approx for: \
|
|
236
|
+
double, Interval, [Interval]Vector, Matrix, [Interval]Matrix, Segment, [Convex]Polygon")
|
|
237
|
+
|
|
238
|
+
def __eq__(self, x):
|
|
239
|
+
return self.a == x
|
|
240
|
+
|
|
241
|
+
def __repr__(self):
|
|
242
|
+
return str(self.a)
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def hull(*args):
|
|
246
|
+
# -1: to be defined, 0: IntervalVector, 1: IntervalMatrix
|
|
247
|
+
lst = []
|
|
248
|
+
mode = -1
|
|
249
|
+
|
|
250
|
+
for arg in args:
|
|
251
|
+
if isinstance(arg, (Vector)):
|
|
252
|
+
mode = 0
|
|
253
|
+
lst.append(IntervalVector(arg))
|
|
254
|
+
elif isinstance(arg, (IntervalVector)):
|
|
255
|
+
mode = 0
|
|
256
|
+
lst.append(arg)
|
|
257
|
+
elif isinstance(arg, (Matrix)):
|
|
258
|
+
mode = 1
|
|
259
|
+
lst.append(IntervalMatrix(arg))
|
|
260
|
+
elif isinstance(arg, (IntervalMatrix)):
|
|
261
|
+
mode = 1
|
|
262
|
+
lst.append(arg)
|
|
263
|
+
elif isinstance(arg, (list)):
|
|
264
|
+
if(isinstance(arg[0], (IntervalVector))):
|
|
265
|
+
return hull_intervalvector(arg)
|
|
266
|
+
elif(isinstance(arg[0], (IntervalMatrix))):
|
|
267
|
+
return hull_intervalmatrix(arg)
|
|
268
|
+
else:
|
|
269
|
+
codac_error("hull: invalid input arguments")
|
|
270
|
+
else:
|
|
271
|
+
codac_error("hull: invalid input arguments")
|
|
272
|
+
|
|
273
|
+
if mode == 0:
|
|
274
|
+
return hull_intervalvector(lst)
|
|
275
|
+
else:
|
|
276
|
+
return hull_intervalmatrix(lst)
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def cart_prod(*args):
|
|
280
|
+
# -1: to be defined, 0: vector, 1: intervalvector, 2: ctc, 3: sep
|
|
281
|
+
lst = []
|
|
282
|
+
mode = -1
|
|
283
|
+
|
|
284
|
+
for arg in args:
|
|
285
|
+
|
|
286
|
+
if isinstance(arg, (int,float,Vector)):
|
|
287
|
+
if mode == -1:
|
|
288
|
+
mode = 0
|
|
289
|
+
|
|
290
|
+
elif isinstance(arg, (list,Interval,IntervalVector)):
|
|
291
|
+
if mode != 2 and mode != 3:
|
|
292
|
+
mode = 1
|
|
293
|
+
|
|
294
|
+
elif isinstance(arg, (Ctc_IntervalVector,Ctc_IntervalVector_)):
|
|
295
|
+
mode = 2
|
|
296
|
+
|
|
297
|
+
elif isinstance(arg, (Sep,SepBase)):
|
|
298
|
+
mode = 3
|
|
299
|
+
|
|
300
|
+
else:
|
|
301
|
+
codac_error("cart_prod: invalid input arguments (a/" + str(mode) + ", " + str(arg) + ")")
|
|
302
|
+
|
|
303
|
+
for arg in args:
|
|
304
|
+
|
|
305
|
+
if isinstance(arg, (int,float)):
|
|
306
|
+
if mode == 0:
|
|
307
|
+
lst.append(Vector([arg]))
|
|
308
|
+
elif mode == 1:
|
|
309
|
+
lst.append(IntervalVector(Vector([arg])))
|
|
310
|
+
elif mode == 2:
|
|
311
|
+
lst.append(CtcWrapper(IntervalVector([arg])))
|
|
312
|
+
elif mode == 3:
|
|
313
|
+
lst.append(SepWrapper(IntervalVector([arg])))
|
|
314
|
+
else:
|
|
315
|
+
codac_error("cart_prod: invalid input arguments (b/" + str(mode) + ")")
|
|
316
|
+
|
|
317
|
+
elif isinstance(arg, (Vector)):
|
|
318
|
+
if mode == 0:
|
|
319
|
+
lst.append(arg)
|
|
320
|
+
elif mode == 1:
|
|
321
|
+
lst.append(IntervalVector(arg))
|
|
322
|
+
elif mode == 2:
|
|
323
|
+
lst.append(CtcWrapper(IntervalVector(arg)))
|
|
324
|
+
elif mode == 3:
|
|
325
|
+
lst.append(SepWrapper(IntervalVector(arg)))
|
|
326
|
+
else:
|
|
327
|
+
codac_error("cart_prod: invalid input arguments (c/" + str(mode) + ")")
|
|
328
|
+
|
|
329
|
+
elif isinstance(arg, (Interval)) or (isinstance(arg, list) and not isinstance(arg[0], list)):
|
|
330
|
+
if mode == 1:
|
|
331
|
+
lst.append(IntervalVector([arg]))
|
|
332
|
+
elif mode == 2:
|
|
333
|
+
lst.append(CtcWrapper(IntervalVector([arg])))
|
|
334
|
+
elif mode == 3:
|
|
335
|
+
lst.append(SepWrapper(IntervalVector([arg])))
|
|
336
|
+
else:
|
|
337
|
+
codac_error("cart_prod: invalid input arguments (d/" + str(mode) + ")")
|
|
338
|
+
|
|
339
|
+
elif isinstance(arg, (list,IntervalVector)) or (isinstance(arg, list) and isinstance(arg[0], list)):
|
|
340
|
+
if mode == 1:
|
|
341
|
+
lst.append(IntervalVector(arg))
|
|
342
|
+
elif mode == 2:
|
|
343
|
+
lst.append(CtcWrapper(IntervalVector(arg)))
|
|
344
|
+
elif mode == 3:
|
|
345
|
+
lst.append(SepWrapper(IntervalVector(arg)))
|
|
346
|
+
else:
|
|
347
|
+
codac_error("cart_prod: invalid input arguments (e/" + str(mode) + ")")
|
|
348
|
+
|
|
349
|
+
elif isinstance(arg, (Ctc_IntervalVector,Ctc_IntervalVector_)):
|
|
350
|
+
if mode != 2:
|
|
351
|
+
codac_error("cart_prod: invalid input arguments (f/" + str(mode) + ")")
|
|
352
|
+
lst.append(arg)
|
|
353
|
+
|
|
354
|
+
elif isinstance(arg, (Sep,SepBase)):
|
|
355
|
+
if mode != 3:
|
|
356
|
+
codac_error("cart_prod: invalid input arguments (g/" + str(mode) + ")")
|
|
357
|
+
lst.append(arg)
|
|
358
|
+
|
|
359
|
+
else:
|
|
360
|
+
mode = -2 # will generate an error
|
|
361
|
+
|
|
362
|
+
if mode == 0:
|
|
363
|
+
return cart_prod_vector(lst)
|
|
364
|
+
elif mode == 1:
|
|
365
|
+
return cart_prod_intervalvector(lst)
|
|
366
|
+
elif mode == 2:
|
|
367
|
+
return cart_prod_ctc(lst)
|
|
368
|
+
elif mode == 3:
|
|
369
|
+
return cart_prod_sep(lst)
|
|
370
|
+
else:
|
|
371
|
+
codac_error("cart_prod: invalid input arguments (h/" + str(mode) + ")")
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
def tube_cart_prod(*x):
|
|
375
|
+
if not isinstance(x,tuple):
|
|
376
|
+
return tube_cart_prod_list([x])
|
|
377
|
+
else:
|
|
378
|
+
return tube_cart_prod_list([*x])
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
class AnalyticTraj:
|
|
382
|
+
|
|
383
|
+
def __init__(self, f, t):
|
|
384
|
+
if isinstance(f, AnalyticFunction):
|
|
385
|
+
self.__init__(f.f,t)
|
|
386
|
+
elif isinstance(f, AnalyticFunction_Scalar):
|
|
387
|
+
self.traj = AnalyticTraj_Scalar(f,t)
|
|
388
|
+
elif isinstance(f, AnalyticFunction_Vector):
|
|
389
|
+
self.traj = AnalyticTraj_Vector(f,t)
|
|
390
|
+
else:
|
|
391
|
+
codac_error("AnalyticTraj: can only build this trajectory from an AnalyticFunction_[Scalar/Vector]")
|
|
392
|
+
|
|
393
|
+
# Methods from TrajBase:
|
|
394
|
+
|
|
395
|
+
def size(self):
|
|
396
|
+
return self.traj.size()
|
|
397
|
+
|
|
398
|
+
def is_empty(self):
|
|
399
|
+
return self.traj.is_empty()
|
|
400
|
+
|
|
401
|
+
def tdomain(self):
|
|
402
|
+
return self.traj.tdomain()
|
|
403
|
+
|
|
404
|
+
def truncate_tdomain(self, new_tdomain):
|
|
405
|
+
return self.traj.truncate_tdomain(new_tdomain)
|
|
406
|
+
|
|
407
|
+
def codomain(self):
|
|
408
|
+
return self.traj.codomain()
|
|
409
|
+
|
|
410
|
+
def __call__(self, t):
|
|
411
|
+
return self.traj(t)
|
|
412
|
+
|
|
413
|
+
def nan_value(self):
|
|
414
|
+
return self.traj.nan_value()
|
|
415
|
+
|
|
416
|
+
def sampled(self, dt):
|
|
417
|
+
return self.traj.sampled(dt)
|
|
418
|
+
|
|
419
|
+
def primitive(self,*args):
|
|
420
|
+
return self.traj.primitive(*args)
|
|
421
|
+
|
|
422
|
+
def as_function(self):
|
|
423
|
+
return AnalyticFunction(self.traj.as_function())
|
|
424
|
+
|
|
425
|
+
# Methods from AnalyticTraj:
|
|
426
|
+
# none
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
class SlicedTube:
|
|
430
|
+
|
|
431
|
+
def __init__(self, x, y=None):
|
|
432
|
+
|
|
433
|
+
if y is None:
|
|
434
|
+
if isinstance(x, SlicedTube):
|
|
435
|
+
self.__init__(x.tube)
|
|
436
|
+
elif isinstance(x, SlicedTube_Interval):
|
|
437
|
+
self.tube = SlicedTube_Interval(x)
|
|
438
|
+
elif isinstance(x, SlicedTube_IntervalVector):
|
|
439
|
+
self.tube = SlicedTube_IntervalVector(x)
|
|
440
|
+
elif isinstance(x, SlicedTube_IntervalMatrix):
|
|
441
|
+
self.tube = SlicedTube_IntervalMatrix(x)
|
|
442
|
+
else:
|
|
443
|
+
codac_error("SlicedTube: unable to copy this tube from another one")
|
|
444
|
+
|
|
445
|
+
else:
|
|
446
|
+
if isinstance(y, AnalyticFunction):
|
|
447
|
+
self.__init__(x, y.f)
|
|
448
|
+
elif isinstance(y, (Interval,AnalyticFunction_Scalar,SampledScalarTraj)):
|
|
449
|
+
self.tube = SlicedTube_Interval(x, y)
|
|
450
|
+
elif isinstance(y, (IntervalVector,AnalyticFunction_Vector,SampledVectorTraj)):
|
|
451
|
+
self.tube = SlicedTube_IntervalVector(x, y)
|
|
452
|
+
elif isinstance(y, (IntervalMatrix,AnalyticFunction_Matrix,SampledMatrixTraj)):
|
|
453
|
+
self.tube = SlicedTube_IntervalMatrix(x, y)
|
|
454
|
+
else:
|
|
455
|
+
codac_error("SlicedTube: can only build this tube from an AnalyticFunction_[Scalar/Vector/Matrix]")
|
|
456
|
+
|
|
457
|
+
def __iter__(self):
|
|
458
|
+
return self.tube.__iter__()
|
|
459
|
+
|
|
460
|
+
# From TubeBase:
|
|
461
|
+
|
|
462
|
+
def tdomain(self):
|
|
463
|
+
return self.tube.tdomain()
|
|
464
|
+
|
|
465
|
+
def t0_tf(self):
|
|
466
|
+
return self.tube.t0_tf()
|
|
467
|
+
|
|
468
|
+
# From SlicedTube<T>:
|
|
469
|
+
|
|
470
|
+
def nb_slices(self):
|
|
471
|
+
return self.tube.nb_slices()
|
|
472
|
+
|
|
473
|
+
def size(self):
|
|
474
|
+
return self.tube.size()
|
|
475
|
+
|
|
476
|
+
def volume(self):
|
|
477
|
+
return self.tube.volume()
|
|
478
|
+
|
|
479
|
+
def first_slice(self):
|
|
480
|
+
return self.tube.first_slice()
|
|
481
|
+
|
|
482
|
+
def last_slice(self):
|
|
483
|
+
return self.tube.last_slice()
|
|
484
|
+
|
|
485
|
+
def slice(self,*args):
|
|
486
|
+
return self.tube.slice(*args)
|
|
487
|
+
|
|
488
|
+
def is_empty(self):
|
|
489
|
+
return self.tube.is_empty()
|
|
490
|
+
|
|
491
|
+
def is_unbounded(self):
|
|
492
|
+
return self.tube.is_unbounded()
|
|
493
|
+
|
|
494
|
+
def codomain(self):
|
|
495
|
+
return self.tube.codomain()
|
|
496
|
+
|
|
497
|
+
def __call__(self,*args):
|
|
498
|
+
return self.tube.__call__(*args)
|
|
499
|
+
|
|
500
|
+
def enclosed_bounds(self,t):
|
|
501
|
+
return self.tube.enclosed_bounds(t)
|
|
502
|
+
|
|
503
|
+
def set(self,x,t=None):
|
|
504
|
+
if t is None:
|
|
505
|
+
return self.tube.set(x)
|
|
506
|
+
else:
|
|
507
|
+
return self.tube.set(x,t)
|
|
508
|
+
|
|
509
|
+
def set_ith_slice(self,x,i):
|
|
510
|
+
return self.tube.set_ith_slice(x,i)
|
|
511
|
+
|
|
512
|
+
def inflate(self,rad):
|
|
513
|
+
return self.tube.inflate(rad)
|
|
514
|
+
|
|
515
|
+
def __eq__(self,x):
|
|
516
|
+
return self.tube.__eq__(x.tube)
|
|
517
|
+
|
|
518
|
+
def __iand__(self,x):
|
|
519
|
+
return self.tube.__iand__(x)
|
|
520
|
+
|
|
521
|
+
def self_inter(self,x):
|
|
522
|
+
return self.tube.self_inter(x)
|
|
523
|
+
|
|
524
|
+
def __repr__(self):
|
|
525
|
+
return str(self.tube)
|
|
526
|
+
|
|
527
|
+
def integral(self,t1,t2=None):
|
|
528
|
+
if t2 is None:
|
|
529
|
+
return self.tube.integral(t1)
|
|
530
|
+
else:
|
|
531
|
+
return self.tube.integral(t1,t2)
|
|
532
|
+
|
|
533
|
+
def partial_integral(self,t1,t2=None):
|
|
534
|
+
if t2 is None:
|
|
535
|
+
return self.tube.partial_integral(t1)
|
|
536
|
+
else:
|
|
537
|
+
return self.tube.partial_integral(t1,t2)
|
|
538
|
+
|
|
539
|
+
def primitive(self):
|
|
540
|
+
return self.tube.primitive()
|
|
541
|
+
|
|
542
|
+
def as_function(self):
|
|
543
|
+
return AnalyticFunction(self.tube.as_function())
|
|
544
|
+
|
|
545
|
+
def invert(self,*args):
|
|
546
|
+
return self.tube.invert(*args)
|
|
547
|
+
|
|
548
|
+
def all_reals_value(self):
|
|
549
|
+
return self.tube.all_reals_value()
|
|
550
|
+
|
|
551
|
+
def empty_value(self):
|
|
552
|
+
return self.tube.empty_value()
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
def fixpoint(contract, *x):
|
|
556
|
+
vol = -1.0
|
|
557
|
+
prev_vol = None
|
|
558
|
+
|
|
559
|
+
while vol != prev_vol:
|
|
560
|
+
|
|
561
|
+
prev_vol = vol
|
|
562
|
+
if isinstance(x, tuple):
|
|
563
|
+
x = contract(*x)
|
|
564
|
+
else: # prevent from unpacking
|
|
565
|
+
x = contract(x)
|
|
566
|
+
|
|
567
|
+
if not isinstance(x,tuple):
|
|
568
|
+
vol = x.get_item_0(0).volume()
|
|
569
|
+
else:
|
|
570
|
+
vol = 0.0
|
|
571
|
+
for xi in x:
|
|
572
|
+
if xi.is_empty():
|
|
573
|
+
return x
|
|
574
|
+
w = xi.volume()
|
|
575
|
+
# As infinity is absorbent, this would not
|
|
576
|
+
# allow us to identify a contraction, so we
|
|
577
|
+
# exclude these cases:
|
|
578
|
+
if w != oo:
|
|
579
|
+
vol += w
|
|
580
|
+
|
|
581
|
+
return x
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
# Deprecated function draw_while_paving(..)
|
|
585
|
+
draw_while_paving = lambda *args, **kwargs: (_ for _ in ()).throw(
|
|
586
|
+
NotImplementedError("draw_while_paving(..) is deprecated,\n \
|
|
587
|
+
please replace by DefaultFigure.pave(..) (or any Figure2D object)")
|
|
588
|
+
)
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from codac4matlab._graphics import *
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Codac tests are placed in this folder (see python/CMakeLists.txt)
|