codac 1.5.6
Loading...
Searching...
No Matches
codac2_SampledTraj_operations.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include "codac2_SampledTraj.h"
13#include "codac2_math.h"
14
15namespace codac2
16{
17 #define macro_unary_traj(f) \
18 { \
19 auto y = x1; \
20 for(auto it = y.begin() ; it != y.end() ; it++) \
21 it->second = f(it->second); \
22 return y; \
23 }; \
24
25 #define macro_binary_traj_traj(f) \
26 { \
27 assert_release(x1.nb_samples() == x2.nb_samples()); \
28 auto y = x2; \
29 auto it_y = y.begin(); \
30 auto it_x1 = x1.begin(); \
31 while(it_y != y.end()) \
32 { \
33 assert_release(it_y->first == it_x1->first \
34 && "inconsistent dates between the two trajectories"); \
35 it_y->second = f(it_x1->second,it_y->second); \
36 it_y++; it_x1++; \
37 } \
38 return y; \
39 } \
40
41 #define macro_binary_real_traj(f) \
42 { \
43 auto y = x2; \
44 for(auto it_y = y.begin() ; it_y != y.end() ; it_y++) \
45 it_y->second = f(x1,it_y->second); \
46 return y; \
47 } \
48
49 #define macro_binary_traj_real(f) \
50 { \
51 auto y = x1; \
52 for(auto it_y = y.begin() ; it_y != y.end() ; it_y++) \
53 it_y->second = f(it_y->second,x2); \
54 return y; \
55 } \
56
57 #define macro_member_binary_traj_traj(f) \
58 { \
59 assert_release(x1.nb_samples() == x2.nb_samples()); \
60 auto it_x1 = x1.begin(); \
61 auto it_x2 = x2.begin(); \
62 while(it_x1 != x1.end()) \
63 { \
64 assert_release(it_x1->first == it_x2->first \
65 && "inconsistent dates between the two trajectories"); \
66 it_x1->second = f(it_x1->second,it_x2->second); \
67 it_x1++; it_x2++; \
68 } \
69 return x1; \
70 } \
71
72 #define macro_member_binary_traj_real(f) \
73 { \
74 for(auto it_x1 = x1.begin() ; it_x1 != x1.end() ; it_x1++) \
75 it_x1->second = f(it_x1->second,x2); \
76 return x1; \
77 } \
78
79 template<typename T,typename X1,typename X2>
80 inline T operator_add(const X1& x1, const X2& x2) { return x1 + x2; }
81
82 template<typename T,typename X1,typename X2>
83 inline T operator_sub(const X1& x1, const X2& x2) { return x1 - x2; }
84
85 template<typename T,typename X1,typename X2>
86 inline T operator_mul(const X1& x1, const X2& x2) { return x1 * x2; }
87
88 template<typename T,typename X2>
89 inline T operator_mul_scal(double x1, const X2& x2) { return x1 * x2; }
90
91 template<typename T,typename X1>
92 inline T operator_mul_scal(const X1& x1, double x2) { return x1 * x2; }
93
94 inline Matrix operator_mul_vec(const Matrix& x1, const Vector& x2) { return x1 * x2; }
95
96 template<typename T,typename X1,typename X2>
97 inline T operator_div(const X1& x1, const X2& x2) { return x1 / x2; }
98
99 template<typename T,typename X1>
100 inline T operator_div_scal(const X1& x1, double x2) { return x1 / x2; }
101
106 template<typename T>
107 inline const SampledTraj<T>& operator+(const SampledTraj<T>& x1) {
108 return x1;
109 }
110
116 template<typename T>
117 inline SampledTraj<T> operator+(const SampledTraj<T>& x1, const SampledTraj<T>& x2)
118 macro_binary_traj_traj(operator_add<T>);
119
125 template<typename T,typename Q>
126 inline SampledTraj<T> operator+(const SampledTraj<T>& x1, const Q& x2)
127 macro_binary_traj_real(operator_add<T>);
128
134 template<typename T,typename Q>
135 inline SampledTraj<T> operator+(const Q& x1, const SampledTraj<T>& x2)
136 macro_binary_real_traj(operator_add<T>);
137
144 template<typename T,typename Q>
145 inline SampledTraj<T>& operator+=(SampledTraj<T>& x1, const Q& x2)
146 macro_member_binary_traj_real(operator_add<T>);
147
154 template<typename T>
155 inline SampledTraj<T>& operator+=(SampledTraj<T>& x1, const SampledTraj<T>& x2)
156 macro_member_binary_traj_traj(operator_add<T>);
157
162 template<typename T>
163 inline SampledTraj<T> operator-(const SampledTraj<T>& x1) {
164 return -1.*x1;
165 }
166
172 template<typename T>
173 inline SampledTraj<T> operator-(const SampledTraj<T>& x1, const SampledTraj<T>& x2)
174 macro_binary_traj_traj(operator_sub<T>);
175
181 template<typename T,typename Q>
182 inline SampledTraj<T> operator-(const SampledTraj<T>& x1, const Q& x2)
183 macro_binary_traj_real(operator_sub<T>);
184
190 template<typename T,typename Q>
191 inline SampledTraj<T> operator-(const Q& x1, const SampledTraj<T>& x2)
192 macro_binary_real_traj(operator_sub<T>);
193
200 template<typename T,typename Q>
201 inline SampledTraj<T>& operator-=(SampledTraj<T>& x1, const Q& x2)
202 macro_member_binary_traj_real(operator_sub<T>);
203
210 template<typename T>
211 inline SampledTraj<T>& operator-=(SampledTraj<T>& x1, const SampledTraj<T>& x2)
212 macro_member_binary_traj_traj(operator_sub<T>);
213
219 template<typename T>
220 requires (!std::is_same_v<T,double>)
221 inline SampledTraj<T> operator*(double x1, const SampledTraj<T>& x2)
222 macro_binary_real_traj(operator_mul_scal<T>);
223
229 template<typename T>
230 requires (!std::is_same_v<T,double>)
231 inline SampledTraj<T> operator*(const SampledTraj<T>& x1, double x2)
232 macro_binary_traj_real(operator_mul_scal<T>);
233
239 template<typename T>
240 inline SampledTraj<T> operator*(const SampledTraj<T>& x1, const SampledTraj<T>& x2)
241 macro_binary_traj_traj(operator_mul<T>);
242
248 template<typename T,typename Q>
249 inline SampledTraj<T> operator*(const SampledTraj<T>& x1, const Q& x2)
250 macro_binary_traj_real(operator_mul<T>);
251
257 template<typename T,typename Q>
258 inline SampledTraj<T> operator*(const Q& x1, const SampledTraj<T>& x2)
259 macro_binary_real_traj(operator_mul<T>);
260
266 inline SampledTraj<Vector> operator*(const SampledTraj<Matrix>& x1, const SampledTraj<Vector>& x2)
267 macro_binary_traj_traj(operator_mul_vec);
268
275 template<typename T,typename Q>
276 inline SampledTraj<T>& operator*=(SampledTraj<T>& x1, const Q& x2)
277 macro_member_binary_traj_real(operator_mul<T>);
278
285 template<typename T>
286 inline SampledTraj<T>& operator*=(SampledTraj<T>& x1, const SampledTraj<T>& x2)
287 macro_member_binary_traj_traj(operator_mul<T>);
288
294 template<typename T>
295 requires (!std::is_same_v<T,double>)
296 inline SampledTraj<T> operator/(const SampledTraj<T>& x1, double x2)
297 macro_binary_traj_real(operator_div_scal<T>);
298
304 template<typename T>
305 inline SampledTraj<T> operator/(const SampledTraj<T>& x1, const SampledTraj<T>& x2)
306 macro_binary_traj_traj(operator_div<T>);
307
313 template<typename T,typename Q>
314 inline SampledTraj<T> operator/(const SampledTraj<T>& x1, const Q& x2)
315 macro_binary_traj_real(operator_div<T>);
316
322 template<typename T,typename Q>
323 inline SampledTraj<T> operator/(const Q& x1, const SampledTraj<T>& x2)
324 macro_binary_real_traj(operator_div<T>);
325
332 template<typename T,typename Q>
333 inline SampledTraj<T>& operator/=(SampledTraj<T>& x1, const Q& x2)
334 macro_member_binary_traj_real(operator_div<T>);
335
342 template<typename T>
343 inline SampledTraj<T>& operator/=(SampledTraj<T>& x1, const SampledTraj<T>& x2)
344 macro_member_binary_traj_traj(operator_div<T>);
345
350 SampledTraj<double> sqr(const SampledTraj<double>& x1);
351
356 SampledTraj<double> sqrt(const SampledTraj<double>& x1);
357
363 SampledTraj<double> pow(const SampledTraj<double>& x1, int x2);
364
370 SampledTraj<double> pow(const SampledTraj<double>& x1, double x2);
371
377 SampledTraj<double> root(const SampledTraj<double>& x1, int x2);
378
383 SampledTraj<double> exp(const SampledTraj<double>& x1);
384
389 SampledTraj<double> log(const SampledTraj<double>& x1);
390
395 SampledTraj<double> cos(const SampledTraj<double>& x1);
396
401 SampledTraj<double> sin(const SampledTraj<double>& x1);
402
407 SampledTraj<double> tan(const SampledTraj<double>& x1);
408
413 SampledTraj<double> acos(const SampledTraj<double>& x1);
414
419 SampledTraj<double> asin(const SampledTraj<double>& x1);
420
425 SampledTraj<double> atan(const SampledTraj<double>& x1);
426
432 SampledTraj<double> atan2(const SampledTraj<double>& x1, const SampledTraj<double>& x2);
433
439 SampledTraj<double> atan2(const SampledTraj<double>& x1, double x2);
440
446 SampledTraj<double> atan2(double x1, const SampledTraj<double>& x2);
447
452 SampledTraj<double> cosh(const SampledTraj<double>& x1);
453
458 SampledTraj<double> sinh(const SampledTraj<double>& x1);
459
464 SampledTraj<double> tanh(const SampledTraj<double>& x1);
465
470 SampledTraj<double> acosh(const SampledTraj<double>& x1);
471
476 SampledTraj<double> asinh(const SampledTraj<double>& x1);
477
482 SampledTraj<double> atanh(const SampledTraj<double>& x1);
483
488 SampledTraj<double> abs(const SampledTraj<double>& x1);
489
495 SampledTraj<double> min(const SampledTraj<double>& x1, const SampledTraj<double>& x2);
496
502 SampledTraj<double> min(const SampledTraj<double>& x1, double x2);
503
509 SampledTraj<double> min(double x1, const SampledTraj<double>& x2);
510
516 SampledTraj<double> max(const SampledTraj<double>& x1, const SampledTraj<double>& x2);
517
523 SampledTraj<double> max(const SampledTraj<double>& x1, double x2);
524
530 SampledTraj<double> max(double x1, const SampledTraj<double>& x2);
531
532 SampledTraj<double> sign(const SampledTraj<double>& x1);
533
534 SampledTraj<double> integer(const SampledTraj<double>& x1);
535
536 SampledTraj<double> floor(const SampledTraj<double>& x1);
537
538 SampledTraj<double> ceil(const SampledTraj<double>& x1);
539}
Ellipsoid operator+(const Ellipsoid &e1, const Ellipsoid &e2)
Compute the Minkowski sum of two ellipsoids.
Interval operator*(const Interval &x, double y)
Returns with .
Definition codac2_Interval_impl.h:412
Interval operator/(const Interval &x, double y)
Returns with .
Definition codac2_Interval_impl.h:435
Interval operator-(const Interval &x, double y)
Returns with .
Definition codac2_Interval_impl.h:389
Interval ceil(const Interval &x)
Returns ceil of .
Definition codac2_Interval_operations_impl.h:294
Interval atan(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:133
Interval max(const Interval &x, const Interval &y)
Returns .
Definition codac2_Interval_operations_impl.h:274
Interval asinh(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:237
Interval atanh(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:257
Interval pow(const Interval &x, int n)
Returns , .
Definition codac2_Interval_operations_impl.h:33
Interval sqrt(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:26
Interval cosh(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:205
Interval floor(const Interval &x)
Returns floor of .
Definition codac2_Interval_operations_impl.h:289
Interval sinh(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:216
Interval acos(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:119
Interval atan2(const Interval &y, const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:140
Interval log(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:85
Interval cos(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:98
Interval exp(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:78
Interval tanh(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:223
Interval sqr(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:21
Interval root(const Interval &x, int p)
Returns the p-th root: .
Definition codac2_Interval_operations_impl.h:60
Interval abs(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:264
Interval asin(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:126
Interval integer(const Interval &x)
Returns the largest integer interval included in .
Definition codac2_Interval_operations_impl.h:284
Interval min(const Interval &x, const Interval &y)
Returns .
Definition codac2_Interval_operations_impl.h:269
Interval acosh(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:230
Interval sign(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:279
Interval sin(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:105
Interval tan(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:112
SampledTraj< T > & operator*=(SampledTraj< T > &x1, const Q &x2) macro_member_binary_traj_real(operator_mul< T >)
Operates *=.
SampledTraj< T > & operator/=(SampledTraj< T > &x1, const Q &x2) macro_member_binary_traj_real(operator_div< T >)
Operates /=.
SampledTraj< T > & operator+=(SampledTraj< T > &x1, const Q &x2) macro_member_binary_traj_real(operator_add< T >)
Operates +=.
SampledTraj< T > & operator-=(SampledTraj< T > &x1, const Q &x2) macro_member_binary_traj_real(operator_sub< T >)
Operates -=.