codac 2.0.5
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 inline Vector operator_mul_aff(const Eigen::Affine2d& x1, const Vector& x2)
97 {
98 assert(x2.size() == 2);
99 return x1 * Eigen::Vector2d(x2);
100 }
101
102 template<typename T,typename X1,typename X2>
103 inline T operator_div(const X1& x1, const X2& x2) { return x1 / x2; }
104
105 template<typename T,typename X1>
106 inline T operator_div_scal(const X1& x1, double x2) { return x1 / x2; }
107
112 template<typename T>
113 inline const SampledTraj<T>& operator+(const SampledTraj<T>& x1) {
114 return x1;
115 }
116
122 template<typename T>
123 inline SampledTraj<T> operator+(const SampledTraj<T>& x1, const SampledTraj<T>& x2)
124 macro_binary_traj_traj(operator_add<T>);
125
131 template<typename T,typename Q>
132 inline SampledTraj<T> operator+(const SampledTraj<T>& x1, const Q& x2)
133 macro_binary_traj_real(operator_add<T>);
134
140 template<typename T,typename Q>
141 inline SampledTraj<T> operator+(const Q& x1, const SampledTraj<T>& x2)
142 macro_binary_real_traj(operator_add<T>);
143
150 template<typename T,typename Q>
151 inline SampledTraj<T>& operator+=(SampledTraj<T>& x1, const Q& x2)
152 macro_member_binary_traj_real(operator_add<T>);
153
160 template<typename T>
161 inline SampledTraj<T>& operator+=(SampledTraj<T>& x1, const SampledTraj<T>& x2)
162 macro_member_binary_traj_traj(operator_add<T>);
163
168 template<typename T>
169 inline SampledTraj<T> operator-(const SampledTraj<T>& x1) {
170 return -1.*x1;
171 }
172
178 template<typename T>
179 inline SampledTraj<T> operator-(const SampledTraj<T>& x1, const SampledTraj<T>& x2)
180 macro_binary_traj_traj(operator_sub<T>);
181
187 template<typename T,typename Q>
188 inline SampledTraj<T> operator-(const SampledTraj<T>& x1, const Q& x2)
189 macro_binary_traj_real(operator_sub<T>);
190
196 template<typename T,typename Q>
197 inline SampledTraj<T> operator-(const Q& x1, const SampledTraj<T>& x2)
198 macro_binary_real_traj(operator_sub<T>);
199
206 template<typename T,typename Q>
207 inline SampledTraj<T>& operator-=(SampledTraj<T>& x1, const Q& x2)
208 macro_member_binary_traj_real(operator_sub<T>);
209
216 template<typename T>
217 inline SampledTraj<T>& operator-=(SampledTraj<T>& x1, const SampledTraj<T>& x2)
218 macro_member_binary_traj_traj(operator_sub<T>);
219
225 template<typename T>
226 requires (!std::is_same_v<T,double>)
227 inline SampledTraj<T> operator*(double x1, const SampledTraj<T>& x2)
228 macro_binary_real_traj(operator_mul_scal<T>);
229
235 template<typename T>
236 requires (!std::is_same_v<T,double>)
237 inline SampledTraj<T> operator*(const SampledTraj<T>& x1, double x2)
238 macro_binary_traj_real(operator_mul_scal<T>);
239
245 template<typename T>
246 inline SampledTraj<T> operator*(const SampledTraj<T>& x1, const SampledTraj<T>& x2)
247 macro_binary_traj_traj(operator_mul<T>);
248
254 template<typename T,typename Q>
255 inline SampledTraj<T> operator*(const SampledTraj<T>& x1, const Q& x2)
256 macro_binary_traj_real(operator_mul<T>);
257
263 template<typename T,typename Q>
264 inline SampledTraj<T> operator*(const Q& x1, const SampledTraj<T>& x2)
265 macro_binary_real_traj(operator_mul<T>);
266
272 inline SampledTraj<Vector> operator*(const SampledTraj<Matrix>& x1, const SampledTraj<Vector>& x2)
273 macro_binary_traj_traj(operator_mul_vec);
274
280 inline SampledTraj<Vector> operator*(const Eigen::Affine2d& x1, const SampledTraj<Vector>& x2)
281 macro_binary_real_traj(operator_mul_aff);
282
289 template<typename T,typename Q>
290 inline SampledTraj<T>& operator*=(SampledTraj<T>& x1, const Q& x2)
291 macro_member_binary_traj_real(operator_mul<T>);
292
299 template<typename T>
300 inline SampledTraj<T>& operator*=(SampledTraj<T>& x1, const SampledTraj<T>& x2)
301 macro_member_binary_traj_traj(operator_mul<T>);
302
308 template<typename T>
309 requires (!std::is_same_v<T,double>)
310 inline SampledTraj<T> operator/(const SampledTraj<T>& x1, double x2)
311 macro_binary_traj_real(operator_div_scal<T>);
312
318 template<typename T>
319 inline SampledTraj<T> operator/(const SampledTraj<T>& x1, const SampledTraj<T>& x2)
320 macro_binary_traj_traj(operator_div<T>);
321
327 template<typename T,typename Q>
328 inline SampledTraj<T> operator/(const SampledTraj<T>& x1, const Q& x2)
329 macro_binary_traj_real(operator_div<T>);
330
336 template<typename T,typename Q>
337 inline SampledTraj<T> operator/(const Q& x1, const SampledTraj<T>& x2)
338 macro_binary_real_traj(operator_div<T>);
339
346 template<typename T,typename Q>
347 inline SampledTraj<T>& operator/=(SampledTraj<T>& x1, const Q& x2)
348 macro_member_binary_traj_real(operator_div<T>);
349
356 template<typename T>
357 inline SampledTraj<T>& operator/=(SampledTraj<T>& x1, const SampledTraj<T>& x2)
358 macro_member_binary_traj_traj(operator_div<T>);
359
364 SampledTraj<double> sqr(const SampledTraj<double>& x1);
365
370 SampledTraj<double> sqrt(const SampledTraj<double>& x1);
371
377 SampledTraj<double> pow(const SampledTraj<double>& x1, int x2);
378
384 SampledTraj<double> pow(const SampledTraj<double>& x1, double x2);
385
391 SampledTraj<double> root(const SampledTraj<double>& x1, int x2);
392
397 SampledTraj<double> exp(const SampledTraj<double>& x1);
398
403 SampledTraj<double> log(const SampledTraj<double>& x1);
404
409 SampledTraj<double> cos(const SampledTraj<double>& x1);
410
415 SampledTraj<double> sin(const SampledTraj<double>& x1);
416
421 SampledTraj<double> tan(const SampledTraj<double>& x1);
422
427 SampledTraj<double> acos(const SampledTraj<double>& x1);
428
433 SampledTraj<double> asin(const SampledTraj<double>& x1);
434
439 SampledTraj<double> atan(const SampledTraj<double>& x1);
440
446 SampledTraj<double> atan2(const SampledTraj<double>& x1, const SampledTraj<double>& x2);
447
453 SampledTraj<double> atan2(const SampledTraj<double>& x1, double x2);
454
460 SampledTraj<double> atan2(double x1, const SampledTraj<double>& x2);
461
466 SampledTraj<double> cosh(const SampledTraj<double>& x1);
467
472 SampledTraj<double> sinh(const SampledTraj<double>& x1);
473
478 SampledTraj<double> tanh(const SampledTraj<double>& x1);
479
484 SampledTraj<double> acosh(const SampledTraj<double>& x1);
485
490 SampledTraj<double> asinh(const SampledTraj<double>& x1);
491
496 SampledTraj<double> atanh(const SampledTraj<double>& x1);
497
502 SampledTraj<double> abs(const SampledTraj<double>& x1);
503
509 SampledTraj<double> min(const SampledTraj<double>& x1, const SampledTraj<double>& x2);
510
516 SampledTraj<double> min(const SampledTraj<double>& x1, double x2);
517
523 SampledTraj<double> min(double x1, const SampledTraj<double>& x2);
524
530 SampledTraj<double> max(const SampledTraj<double>& x1, const SampledTraj<double>& x2);
531
537 SampledTraj<double> max(const SampledTraj<double>& x1, double x2);
538
544 SampledTraj<double> max(double x1, const SampledTraj<double>& x2);
545
546 SampledTraj<double> sign(const SampledTraj<double>& x1);
547
548 SampledTraj<double> integer(const SampledTraj<double>& x1);
549
550 SampledTraj<double> floor(const SampledTraj<double>& x1);
551
552 SampledTraj<double> ceil(const SampledTraj<double>& x1);
553}
Definition codac2_OctaSym.h:21
Interval ceil(const Interval &x)
Returns ceil of .
Definition codac2_Interval_operations_impl.h:294
Eigen::Matrix< double,-1, 1 > Vector
Alias for a dynamically-sized column vector of doubles.
Definition codac2_Vector.h:24
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 operator*(const Interval &x, double y)
Returns with .
Definition codac2_Interval_impl.h:461
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
SlicedTube< T > & operator+=(SlicedTube< T > &x1, const Q &x2) macro_member_binary_tube_real(operator_tube_add< T >)
Pointwise addition assignment with a constant object of matching codomain type.
Interval sqrt(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:26
Interval operator/(const Interval &x, double y)
Returns with .
Definition codac2_Interval_impl.h:484
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
Ellipsoid operator+(const Ellipsoid &e1, const Ellipsoid &e2)
Compute the Minkowski sum of two ellipsoids.
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
SlicedTube< T > & operator/=(SlicedTube< T > &x1, const Q &x2) macro_member_binary_tube_real(operator_tube_div< T >)
Pointwise division assignment with a constant object of matching codomain type.
Interval operator-(const Interval &x, double y)
Returns with .
Definition codac2_Interval_impl.h:438
Eigen::Matrix< double,-1,-1 > Matrix
Alias for a dynamic-size matrix of doubles.
Definition codac2_Matrix.h:26
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
SlicedTube< T > & operator-=(SlicedTube< T > &x1, const Q &x2) macro_member_binary_tube_real(operator_tube_sub< T >)
Pointwise subtraction assignment with a constant object of matching codomain type.
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
SlicedTube< T > & operator*=(SlicedTube< T > &x1, const Q &x2) macro_member_binary_tube_real(operator_tube_mul< T >)
Pointwise multiplication assignment with a constant object of matching codomain type.
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