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
codac4matlab/__init__.py
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,340 @@
|
|
|
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
|
+
else:
|
|
41
|
+
codac_error("AnalyticFunction: invalid function argument")
|
|
42
|
+
|
|
43
|
+
def input_size(self):
|
|
44
|
+
return self.f.input_size()
|
|
45
|
+
|
|
46
|
+
def output_size(self):
|
|
47
|
+
return self.f.output_size()
|
|
48
|
+
|
|
49
|
+
def real_eval(self,*args):
|
|
50
|
+
return self.f.real_eval(*args)
|
|
51
|
+
|
|
52
|
+
def eval(self,m,*args):
|
|
53
|
+
return self.f.eval(m,*args)
|
|
54
|
+
|
|
55
|
+
def eval(self,*args):
|
|
56
|
+
return self.f.eval(*args)
|
|
57
|
+
|
|
58
|
+
def diff(self,*args):
|
|
59
|
+
return self.f.diff(*args)
|
|
60
|
+
|
|
61
|
+
def __call__(self,*args):
|
|
62
|
+
lst=[]
|
|
63
|
+
for arg in args:
|
|
64
|
+
if isinstance(arg, (int,float,Interval,ScalarVar,ScalarExpr)):
|
|
65
|
+
lst.append(ScalarExpr(arg))
|
|
66
|
+
elif isinstance(arg, (Vector,IntervalVector,VectorVar,VectorExpr)):
|
|
67
|
+
lst.append(VectorExpr(arg))
|
|
68
|
+
elif isinstance(arg, (Matrix,IntervalMatrix,MatrixVar,MatrixExpr)):
|
|
69
|
+
lst.append(MatrixExpr(arg))
|
|
70
|
+
else:
|
|
71
|
+
codac_error("AnalyticFunction: invalid input arguments")
|
|
72
|
+
return self.f(lst)
|
|
73
|
+
|
|
74
|
+
def __repr__(self):
|
|
75
|
+
return str(self.f)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class Ctc(CtcIntervalVector):
|
|
79
|
+
|
|
80
|
+
def __init__(self, n):
|
|
81
|
+
CtcIntervalVector.__init__(self,n)
|
|
82
|
+
|
|
83
|
+
def copy(self):
|
|
84
|
+
return super().copy()
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class Sep(SepBase):
|
|
88
|
+
|
|
89
|
+
def copy(self):
|
|
90
|
+
return super().copy()
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class CtcInverse(Ctc):
|
|
94
|
+
|
|
95
|
+
def __init__(self, f, y, with_centered_form = True):
|
|
96
|
+
Ctc.__init__(self, f.input_size())
|
|
97
|
+
if isinstance(f.f, AnalyticFunction_Scalar):
|
|
98
|
+
if not (isinstance(y, (int,float,Interval))
|
|
99
|
+
or (isinstance(y, list) and len(y) > 0 and len(y) <= 2 and isinstance(y[0], (int,float)))):
|
|
100
|
+
codac_error("CtcInverse: inverse argument 'y' should be a scalar type (float,Interval)")
|
|
101
|
+
self.c = CtcInverse_Interval(f.f,Interval(y),with_centered_form)
|
|
102
|
+
elif isinstance(f.f, AnalyticFunction_Vector):
|
|
103
|
+
if not isinstance(y, (Vector,IntervalVector,list,CtcIntervalVector)):
|
|
104
|
+
codac_error("CtcInverse: inverse argument 'y' should be a vector type (Vector,IntervalVector,CtcIntervalVector)")
|
|
105
|
+
if isinstance(y, CtcIntervalVector):
|
|
106
|
+
self.c = CtcInverse_IntervalVector(f,y,with_centered_form)
|
|
107
|
+
else:
|
|
108
|
+
self.c = CtcInverse_IntervalVector(f.f,IntervalVector(y),with_centered_form)
|
|
109
|
+
else:
|
|
110
|
+
codac_error("CtcInverse: can only build CtcInverse from scalar or vector functions")
|
|
111
|
+
|
|
112
|
+
def contract(self,x):
|
|
113
|
+
return self.c.contract(x)
|
|
114
|
+
|
|
115
|
+
def copy(self):
|
|
116
|
+
return self.c.copy()
|
|
117
|
+
|
|
118
|
+
def function(self):
|
|
119
|
+
return self.c.function()
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class CtcInverseNotIn(Ctc):
|
|
123
|
+
|
|
124
|
+
def __init__(self, f, y, with_centered_form = True):
|
|
125
|
+
Ctc.__init__(self, f.input_size())
|
|
126
|
+
if isinstance(f.f, AnalyticFunction_Scalar):
|
|
127
|
+
if not (isinstance(y, (int,float,Interval))
|
|
128
|
+
or (isinstance(y, list) and len(y) > 0 and len(y) <= 2 and isinstance(y[0], (int,float)))):
|
|
129
|
+
codac_error("CtcInverseNotIn: inverse argument 'y' should be a scalar type (float,Interval)")
|
|
130
|
+
self.c = CtcInverseNotIn_Interval(f.f,Interval(y),with_centered_form)
|
|
131
|
+
elif isinstance(f.f, AnalyticFunction_Vector):
|
|
132
|
+
if not isinstance(y, (Vector,IntervalVector,list)):
|
|
133
|
+
codac_error("CtcInverseNotIn: inverse argument 'y' should be a vector type (Vector,IntervalVector)")
|
|
134
|
+
self.c = CtcInverseNotIn_IntervalVector(f.f,IntervalVector(y),with_centered_form)
|
|
135
|
+
else:
|
|
136
|
+
codac_error("CtcInverseNotIn: can only build CtcInverseNotIn from scalar or vector functions")
|
|
137
|
+
|
|
138
|
+
def contract(self,x):
|
|
139
|
+
return self.c.contract(x)
|
|
140
|
+
|
|
141
|
+
def copy(self):
|
|
142
|
+
return self.c.copy()
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class Approx:
|
|
146
|
+
|
|
147
|
+
def __init__(self, x, eps = sys.float_info.epsilon*10):
|
|
148
|
+
if isinstance(x, (int,float)):
|
|
149
|
+
self.a = Approx_double(x,eps)
|
|
150
|
+
elif isinstance(x, (Interval)):
|
|
151
|
+
self.a = Approx_Interval(x,eps)
|
|
152
|
+
elif isinstance(x, (Vector)):
|
|
153
|
+
self.a = Approx_Vector(x,eps)
|
|
154
|
+
elif isinstance(x, (IntervalVector)):
|
|
155
|
+
self.a = Approx_IntervalVector(x,eps)
|
|
156
|
+
elif isinstance(x, (Matrix)):
|
|
157
|
+
self.a = Approx_Matrix(x,eps)
|
|
158
|
+
elif isinstance(x, (IntervalMatrix)):
|
|
159
|
+
self.a = Approx_IntervalMatrix(x,eps)
|
|
160
|
+
elif isinstance(x, (Segment)):
|
|
161
|
+
self.a = Approx_Segment(x,eps)
|
|
162
|
+
elif isinstance(x, (Polygon,ConvexPolygon)):
|
|
163
|
+
self.a = Approx_Polygon(x,eps)
|
|
164
|
+
else:
|
|
165
|
+
codac_error("Approx: can only build Approx for: \
|
|
166
|
+
double, Interval, [Interval]Vector, Matrix, [Interval]Matrix, Segment, [Convex]Polygon")
|
|
167
|
+
|
|
168
|
+
def __eq__(self, x):
|
|
169
|
+
return self.a == x
|
|
170
|
+
|
|
171
|
+
def __repr__(self):
|
|
172
|
+
return str(self.a)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def hull(*args):
|
|
176
|
+
# -1: to be defined, 0: IntervalVector, 1: IntervalMatrix
|
|
177
|
+
lst = []
|
|
178
|
+
mode = -1
|
|
179
|
+
|
|
180
|
+
for arg in args:
|
|
181
|
+
if isinstance(arg, (Vector)):
|
|
182
|
+
mode = 0
|
|
183
|
+
lst.append(IntervalVector(arg))
|
|
184
|
+
elif isinstance(arg, (IntervalVector)):
|
|
185
|
+
mode = 0
|
|
186
|
+
lst.append(arg)
|
|
187
|
+
elif isinstance(arg, (Matrix)):
|
|
188
|
+
mode = 1
|
|
189
|
+
lst.append(IntervalMatrix(arg))
|
|
190
|
+
elif isinstance(arg, (IntervalMatrix)):
|
|
191
|
+
mode = 1
|
|
192
|
+
lst.append(arg)
|
|
193
|
+
|
|
194
|
+
if mode == 0:
|
|
195
|
+
return hull_intervalvector(lst)
|
|
196
|
+
else:
|
|
197
|
+
return hull_intervalmatrix(lst)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def cart_prod(*args):
|
|
201
|
+
# -1: to be defined, 0: vector, 1: intervalvector, 2: ctc, 3: sep
|
|
202
|
+
lst = []
|
|
203
|
+
mode = -1
|
|
204
|
+
|
|
205
|
+
for arg in args:
|
|
206
|
+
|
|
207
|
+
if isinstance(arg, (int,float,Vector)):
|
|
208
|
+
if mode == -1:
|
|
209
|
+
mode = 0
|
|
210
|
+
|
|
211
|
+
elif isinstance(arg, (list,Interval,IntervalVector)):
|
|
212
|
+
if mode != 2 and mode != 3:
|
|
213
|
+
mode = 1
|
|
214
|
+
|
|
215
|
+
elif isinstance(arg, Ctc):
|
|
216
|
+
mode = 2
|
|
217
|
+
|
|
218
|
+
elif isinstance(arg, (Sep,SepBase)):
|
|
219
|
+
mode = 3
|
|
220
|
+
|
|
221
|
+
else:
|
|
222
|
+
codac_error("cart_prod: invalid input arguments (a/" + str(mode) + ")")
|
|
223
|
+
|
|
224
|
+
for arg in args:
|
|
225
|
+
|
|
226
|
+
if isinstance(arg, (int,float)):
|
|
227
|
+
if mode == 0:
|
|
228
|
+
lst.append(Vector([arg]))
|
|
229
|
+
elif mode == 1:
|
|
230
|
+
lst.append(IntervalVector(Vector([arg])))
|
|
231
|
+
elif mode == 2:
|
|
232
|
+
lst.append(CtcWrapper(IntervalVector([arg])))
|
|
233
|
+
elif mode == 3:
|
|
234
|
+
lst.append(SepWrapper(IntervalVector([arg])))
|
|
235
|
+
else:
|
|
236
|
+
codac_error("cart_prod: invalid input arguments (b/" + str(mode) + ")")
|
|
237
|
+
|
|
238
|
+
elif isinstance(arg, (Vector)):
|
|
239
|
+
if mode == 0:
|
|
240
|
+
lst.append(arg)
|
|
241
|
+
elif mode == 1:
|
|
242
|
+
lst.append(IntervalVector(arg))
|
|
243
|
+
elif mode == 2:
|
|
244
|
+
lst.append(CtcWrapper(IntervalVector(arg)))
|
|
245
|
+
elif mode == 3:
|
|
246
|
+
lst.append(SepWrapper(IntervalVector(arg)))
|
|
247
|
+
else:
|
|
248
|
+
codac_error("cart_prod: invalid input arguments (c/" + str(mode) + ")")
|
|
249
|
+
|
|
250
|
+
elif isinstance(arg, (Interval)):
|
|
251
|
+
if mode == 1:
|
|
252
|
+
lst.append(IntervalVector([arg]))
|
|
253
|
+
elif mode == 2:
|
|
254
|
+
lst.append(CtcWrapper(IntervalVector([arg])))
|
|
255
|
+
elif mode == 3:
|
|
256
|
+
lst.append(SepWrapper(IntervalVector([arg])))
|
|
257
|
+
else:
|
|
258
|
+
codac_error("cart_prod: invalid input arguments (d/" + str(mode) + ")")
|
|
259
|
+
|
|
260
|
+
elif isinstance(arg, (list,IntervalVector)):
|
|
261
|
+
if mode == 1:
|
|
262
|
+
lst.append(IntervalVector(arg))
|
|
263
|
+
elif mode == 2:
|
|
264
|
+
lst.append(CtcWrapper(IntervalVector(arg)))
|
|
265
|
+
elif mode == 3:
|
|
266
|
+
lst.append(SepWrapper(IntervalVector(arg)))
|
|
267
|
+
else:
|
|
268
|
+
codac_error("cart_prod: invalid input arguments (e/" + str(mode) + ")")
|
|
269
|
+
|
|
270
|
+
elif isinstance(arg, Ctc):
|
|
271
|
+
if mode != 2:
|
|
272
|
+
codac_error("cart_prod: invalid input arguments (f/" + str(mode) + ")")
|
|
273
|
+
lst.append(arg)
|
|
274
|
+
|
|
275
|
+
elif isinstance(arg, (Sep,SepBase)):
|
|
276
|
+
if mode != 3:
|
|
277
|
+
codac_error("cart_prod: invalid input arguments (g/" + str(mode) + ")")
|
|
278
|
+
lst.append(arg)
|
|
279
|
+
|
|
280
|
+
else:
|
|
281
|
+
mode = -2 # will generate an error
|
|
282
|
+
|
|
283
|
+
if mode == 0:
|
|
284
|
+
return cart_prod_vector(lst)
|
|
285
|
+
elif mode == 1:
|
|
286
|
+
return cart_prod_intervalvector(lst)
|
|
287
|
+
elif mode == 2:
|
|
288
|
+
return cart_prod_ctc(lst)
|
|
289
|
+
elif mode == 3:
|
|
290
|
+
return cart_prod_sep(lst)
|
|
291
|
+
else:
|
|
292
|
+
codac_error("cart_prod: invalid input arguments (h/" + str(mode) + ")")
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
class AnalyticTraj:
|
|
296
|
+
|
|
297
|
+
def __init__(self, f, t):
|
|
298
|
+
if isinstance(f, AnalyticFunction):
|
|
299
|
+
self.__init__(f.f,t)
|
|
300
|
+
elif isinstance(f, AnalyticFunction_Scalar):
|
|
301
|
+
self.traj = AnalyticTraj_Scalar(f,t)
|
|
302
|
+
elif isinstance(f, AnalyticFunction_Vector):
|
|
303
|
+
self.traj = AnalyticTraj_Vector(f,t)
|
|
304
|
+
else:
|
|
305
|
+
codac_error("AnalyticTraj: can only build this trajectory from an AnalyticFunction_[Scalar/Vector]")
|
|
306
|
+
|
|
307
|
+
# Methods from TrajBase:
|
|
308
|
+
|
|
309
|
+
def size(self):
|
|
310
|
+
return self.traj.size()
|
|
311
|
+
|
|
312
|
+
def is_empty(self):
|
|
313
|
+
return self.traj.is_empty()
|
|
314
|
+
|
|
315
|
+
def tdomain(self):
|
|
316
|
+
return self.traj.tdomain()
|
|
317
|
+
|
|
318
|
+
def truncate_tdomain(self, new_tdomain):
|
|
319
|
+
return self.traj.truncate_tdomain(new_tdomain)
|
|
320
|
+
|
|
321
|
+
def codomain(self):
|
|
322
|
+
return self.traj.codomain()
|
|
323
|
+
|
|
324
|
+
def __call__(self, t):
|
|
325
|
+
return self.traj(t)
|
|
326
|
+
|
|
327
|
+
def nan_value(self):
|
|
328
|
+
return self.traj.nan_value()
|
|
329
|
+
|
|
330
|
+
def sampled(self, dt):
|
|
331
|
+
return self.traj.sampled(dt)
|
|
332
|
+
|
|
333
|
+
def primitive(self, y0, t):
|
|
334
|
+
return self.traj.primitive(y0, t)
|
|
335
|
+
|
|
336
|
+
def as_function(self):
|
|
337
|
+
return AnalyticFunction(self.traj.as_function())
|
|
338
|
+
|
|
339
|
+
# Methods from AnalyticTraj:
|
|
340
|
+
# none
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from codac4matlab._graphics import *
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Codac tests are placed in this folder (see python/CMakeLists.txt)
|