codac 2.0.0
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 // These macros stand in for the body of the functions declared below. Doxygen
18 // parses this header to produce the Python docstrings, and it cannot name a
19 // function whose body it does not recognise, so every macro used that way is
20 // listed in EXPAND_AS_DEFINED in doc/api/Doxyfile.in. Add any new one there
21 // too, otherwise the bindings lose the docstring identifiers they expect and
22 // stop compiling.
23 #define macro_unary_traj(f) \
24 { \
25 auto y = x1; \
26 for(auto it = y.begin() ; it != y.end() ; it++) \
27 it->second = f(it->second); \
28 return y; \
29 } \
30
31 #define macro_binary_traj_traj(f) \
32 { \
33 assert_release(x1.nb_samples() == x2.nb_samples()); \
34 auto y = x2; \
35 auto it_y = y.begin(); \
36 auto it_x1 = x1.begin(); \
37 while(it_y != y.end()) \
38 { \
39 assert_release(it_y->first == it_x1->first \
40 && "inconsistent dates between the two trajectories"); \
41 it_y->second = f(it_x1->second,it_y->second); \
42 it_y++; it_x1++; \
43 } \
44 return y; \
45 } \
46
47 #define macro_binary_real_traj(f) \
48 { \
49 auto y = x2; \
50 for(auto it_y = y.begin() ; it_y != y.end() ; it_y++) \
51 it_y->second = f(x1,it_y->second); \
52 return y; \
53 } \
54
55 #define macro_binary_traj_real(f) \
56 { \
57 auto y = x1; \
58 for(auto it_y = y.begin() ; it_y != y.end() ; it_y++) \
59 it_y->second = f(it_y->second,x2); \
60 return y; \
61 } \
62
63 #define macro_member_binary_traj_traj(f) \
64 { \
65 assert_release(x1.nb_samples() == x2.nb_samples()); \
66 auto it_x1 = x1.begin(); \
67 auto it_x2 = x2.begin(); \
68 while(it_x1 != x1.end()) \
69 { \
70 assert_release(it_x1->first == it_x2->first \
71 && "inconsistent dates between the two trajectories"); \
72 it_x1->second = f(it_x1->second,it_x2->second); \
73 it_x1++; it_x2++; \
74 } \
75 return x1; \
76 } \
77
78 #define macro_member_binary_traj_real(f) \
79 { \
80 for(auto it_x1 = x1.begin() ; it_x1 != x1.end() ; it_x1++) \
81 it_x1->second = f(it_x1->second,x2); \
82 return x1; \
83 } \
84
85 template<typename T,typename X1,typename X2>
86 inline T operator_add(const X1& x1, const X2& x2) { return x1 + x2; }
87
88 template<typename T,typename X1,typename X2>
89 inline T operator_sub(const X1& x1, const X2& x2) { return x1 - x2; }
90
91 template<typename T,typename X1,typename X2>
92 inline T operator_mul(const X1& x1, const X2& x2) { return x1 * x2; }
93
94 template<typename T,typename X2>
95 inline T operator_mul_scal(double x1, const X2& x2) { return x1 * x2; }
96
97 template<typename T,typename X1>
98 inline T operator_mul_scal(const X1& x1, double x2) { return x1 * x2; }
99
100 inline Matrix operator_mul_vec(const Matrix& x1, const Vector& x2) { return x1 * x2; }
101
102 inline Vector operator_mul_aff(const Eigen::Affine2d& x1, const Vector& x2)
103 {
104 assert(x2.size() == 2);
105 return x1 * Eigen::Vector2d(x2);
106 }
107
108 template<typename T,typename X1,typename X2>
109 inline T operator_div(const X1& x1, const X2& x2) { return x1 / x2; }
110
111 template<typename T,typename X1>
112 inline T operator_div_scal(const X1& x1, double x2) { return x1 / x2; }
113
118 template<typename T>
119 inline const SampledTraj<T>& operator+(const SampledTraj<T>& x1) {
120 return x1;
121 }
122
128 template<typename T>
129 inline SampledTraj<T> operator+(const SampledTraj<T>& x1, const SampledTraj<T>& x2)
130 macro_binary_traj_traj(operator_add<T>)
131
132
137 template<typename T,typename Q>
138 inline SampledTraj<T> operator+(const SampledTraj<T>& x1, const Q& x2)
139 macro_binary_traj_real(operator_add<T>)
140
141
146 template<typename T,typename Q>
147 inline SampledTraj<T> operator+(const Q& x1, const SampledTraj<T>& x2)
148 macro_binary_real_traj(operator_add<T>)
149
150
156 template<typename T,typename Q>
157 inline SampledTraj<T>& operator+=(SampledTraj<T>& x1, const Q& x2)
158 macro_member_binary_traj_real(operator_add<T>)
159
160
166 template<typename T>
167 inline SampledTraj<T>& operator+=(SampledTraj<T>& x1, const SampledTraj<T>& x2)
168 macro_member_binary_traj_traj(operator_add<T>)
169
170
174 template<typename T>
175 inline SampledTraj<T> operator-(const SampledTraj<T>& x1) {
176 return -1.*x1;
177 }
178
184 template<typename T>
185 inline SampledTraj<T> operator-(const SampledTraj<T>& x1, const SampledTraj<T>& x2)
186 macro_binary_traj_traj(operator_sub<T>)
187
188
193 template<typename T,typename Q>
194 inline SampledTraj<T> operator-(const SampledTraj<T>& x1, const Q& x2)
195 macro_binary_traj_real(operator_sub<T>)
196
197
202 template<typename T,typename Q>
203 inline SampledTraj<T> operator-(const Q& x1, const SampledTraj<T>& x2)
204 macro_binary_real_traj(operator_sub<T>)
205
206
212 template<typename T,typename Q>
213 inline SampledTraj<T>& operator-=(SampledTraj<T>& x1, const Q& x2)
214 macro_member_binary_traj_real(operator_sub<T>)
215
216
222 template<typename T>
223 inline SampledTraj<T>& operator-=(SampledTraj<T>& x1, const SampledTraj<T>& x2)
224 macro_member_binary_traj_traj(operator_sub<T>)
225
226
231 template<typename T>
232 requires (!std::is_same_v<T,double>)
233 inline SampledTraj<T> operator*(double x1, const SampledTraj<T>& x2)
234 macro_binary_real_traj(operator_mul_scal<T>)
235
236
241 template<typename T>
242 requires (!std::is_same_v<T,double>)
243 inline SampledTraj<T> operator*(const SampledTraj<T>& x1, double x2)
244 macro_binary_traj_real(operator_mul_scal<T>)
245
246
251 template<typename T>
252 inline SampledTraj<T> operator*(const SampledTraj<T>& x1, const SampledTraj<T>& x2)
253 macro_binary_traj_traj(operator_mul<T>)
254
255
260 template<typename T,typename Q>
261 inline SampledTraj<T> operator*(const SampledTraj<T>& x1, const Q& x2)
262 macro_binary_traj_real(operator_mul<T>)
263
264
269 template<typename T,typename Q>
270 inline SampledTraj<T> operator*(const Q& x1, const SampledTraj<T>& x2)
271 macro_binary_real_traj(operator_mul<T>)
272
273
278 inline SampledTraj<Vector> operator*(const SampledTraj<Matrix>& x1, const SampledTraj<Vector>& x2)
279 macro_binary_traj_traj(operator_mul_vec)
280
286 inline SampledTraj<Vector> operator*(const Eigen::Affine2d& x1, const SampledTraj<Vector>& x2)
287 macro_binary_real_traj(operator_mul_aff)
288
295 template<typename T,typename Q>
296 inline SampledTraj<T>& operator*=(SampledTraj<T>& x1, const Q& x2)
297 macro_member_binary_traj_real(operator_mul<T>)
298
305 template<typename T>
306 inline SampledTraj<T>& operator*=(SampledTraj<T>& x1, const SampledTraj<T>& x2)
307 macro_member_binary_traj_traj(operator_mul<T>)
308
314 template<typename T>
315 requires (!std::is_same_v<T,double>)
316 inline SampledTraj<T> operator/(const SampledTraj<T>& x1, double x2)
317 macro_binary_traj_real(operator_div_scal<T>)
318
324 template<typename T>
325 inline SampledTraj<T> operator/(const SampledTraj<T>& x1, const SampledTraj<T>& x2)
326 macro_binary_traj_traj(operator_div<T>)
327
333 template<typename T,typename Q>
334 inline SampledTraj<T> operator/(const SampledTraj<T>& x1, const Q& x2)
335 macro_binary_traj_real(operator_div<T>)
336
342 template<typename T,typename Q>
343 inline SampledTraj<T> operator/(const Q& x1, const SampledTraj<T>& x2)
344 macro_binary_real_traj(operator_div<T>)
345
352 template<typename T,typename Q>
353 inline SampledTraj<T>& operator/=(SampledTraj<T>& x1, const Q& x2)
354 macro_member_binary_traj_real(operator_div<T>)
355
362 template<typename T>
363 inline SampledTraj<T>& operator/=(SampledTraj<T>& x1, const SampledTraj<T>& x2)
364 macro_member_binary_traj_traj(operator_div<T>)
365
370 SampledTraj<double> sqr(const SampledTraj<double>& x1);
371
376 SampledTraj<double> sqrt(const SampledTraj<double>& x1);
377
383 SampledTraj<double> pow(const SampledTraj<double>& x1, int x2);
384
390 SampledTraj<double> pow(const SampledTraj<double>& x1, double x2);
391
397 SampledTraj<double> root(const SampledTraj<double>& x1, int x2);
398
403 SampledTraj<double> exp(const SampledTraj<double>& x1);
404
409 SampledTraj<double> log(const SampledTraj<double>& x1);
410
415 SampledTraj<double> cos(const SampledTraj<double>& x1);
416
421 SampledTraj<double> sin(const SampledTraj<double>& x1);
422
427 SampledTraj<double> tan(const SampledTraj<double>& x1);
428
433 SampledTraj<double> acos(const SampledTraj<double>& x1);
434
439 SampledTraj<double> asin(const SampledTraj<double>& x1);
440
445 SampledTraj<double> atan(const SampledTraj<double>& x1);
446
452 SampledTraj<double> atan2(const SampledTraj<double>& x1, const SampledTraj<double>& x2);
453
459 SampledTraj<double> atan2(const SampledTraj<double>& x1, double x2);
460
466 SampledTraj<double> atan2(double x1, const SampledTraj<double>& x2);
467
472 SampledTraj<double> cosh(const SampledTraj<double>& x1);
473
478 SampledTraj<double> sinh(const SampledTraj<double>& x1);
479
484 SampledTraj<double> tanh(const SampledTraj<double>& x1);
485
490 SampledTraj<double> acosh(const SampledTraj<double>& x1);
491
496 SampledTraj<double> asinh(const SampledTraj<double>& x1);
497
502 SampledTraj<double> atanh(const SampledTraj<double>& x1);
503
508 SampledTraj<double> abs(const SampledTraj<double>& x1);
509
515 SampledTraj<double> min(const SampledTraj<double>& x1, const SampledTraj<double>& x2);
516
522 SampledTraj<double> min(const SampledTraj<double>& x1, double x2);
523
529 SampledTraj<double> min(double x1, const SampledTraj<double>& x2);
530
536 SampledTraj<double> max(const SampledTraj<double>& x1, const SampledTraj<double>& x2);
537
543 SampledTraj<double> max(const SampledTraj<double>& x1, double x2);
544
550 SampledTraj<double> max(double x1, const SampledTraj<double>& x2);
551
552 SampledTraj<double> sign(const SampledTraj<double>& x1);
553
554 SampledTraj<double> integer(const SampledTraj<double>& x1);
555
556 SampledTraj<double> floor(const SampledTraj<double>& x1);
557
558 SampledTraj<double> ceil(const SampledTraj<double>& x1);
559}
Definition codac2_matrices.h:47
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
SlicedTube< T > & operator+=(SlicedTube< T > &x1, const Q &x2)
Pointwise addition assignment with a constant object of matching codomain type.
Definition codac2_SlicedTube_operations.h:275
Interval max(const Interval &x, const Interval &y)
Returns .
Definition codac2_Interval_operations_impl.h:274
SlicedTube< T > & operator-=(SlicedTube< T > &x1, const Q &x2)
Pointwise subtraction assignment with a constant object of matching codomain type.
Definition codac2_SlicedTube_operations.h:363
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
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
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
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
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