codac 2.0.0
Loading...
Searching...
No Matches
codac2_SlicedTube_operations.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <type_traits>
13
14#include "codac2_SlicedTube.h"
15#include "codac2_math.h"
16
17namespace codac2
18{
19 #define macro_unary_tube(f) \
20 { \
21 auto y = x1; \
22 for(auto it = y.tdomain()->begin() ; it != y.tdomain()->end() ; it++) \
23 { \
24 auto sy = y.slice(it); \
25 sy->codomain() = f(sy->codomain()); \
26 } \
27 return y; \
28 } \
29
30 #define macro_binary_tube_tube(f,output_type) \
31 { \
32 assert_release(x1.tdomain() == x2.tdomain()); \
33 auto y = output_type; \
34 for(auto it = y.tdomain()->begin() ; it != y.tdomain()->end() ; it++) \
35 { \
36 auto sy = y.slice(it); \
37 sy->codomain() = f(x1.slice(it)->codomain(), x2.slice(it)->codomain()); \
38 } \
39 return y; \
40 } \
41
42 #define macro_binary_real_tube(f) \
43 { \
44 auto y = x2; \
45 for(auto it = y.tdomain()->begin() ; it != y.tdomain()->end() ; it++) \
46 { \
47 auto sy = y.slice(it); \
48 sy->codomain() = f(x1, sy->codomain()); \
49 } \
50 return y; \
51 } \
52
53 #define macro_binary_tube_real(f) \
54 { \
55 auto y = x1; \
56 for(auto it = y.tdomain()->begin() ; it != y.tdomain()->end() ; it++) \
57 { \
58 auto sy = y.slice(it); \
59 sy->codomain() = f(sy->codomain(), x2); \
60 } \
61 return y; \
62 } \
63
64 #define macro_member_binary_tube_tube(f) \
65 { \
66 assert_release(x1.tdomain() == x2.tdomain()); \
67 for(auto it = x1.tdomain()->begin() ; it != x1.tdomain()->end() ; it++) \
68 { \
69 auto sx1 = x1.slice(it); \
70 sx1->codomain() = f(sx1->codomain(), x2.slice(it)->codomain()); \
71 } \
72 return x1; \
73 } \
74
75 #define macro_member_binary_tube_real(f) \
76 { \
77 for(auto it = x1.tdomain()->begin() ; it != x1.tdomain()->end() ; it++) \
78 { \
79 auto sx1 = x1.slice(it); \
80 sx1->codomain() = f(sx1->codomain(), x2); \
81 } \
82 return x1; \
83 } \
84
85 template<typename U>
86 struct is_slicedtube : std::false_type {};
87
88 template<typename U>
89 struct is_slicedtube<SlicedTube<U>> : std::true_type {};
90
91 template<typename U>
92 inline constexpr bool is_slicedtube_v = is_slicedtube<std::remove_cvref_t<U>>::value;
93
94 template<typename Q>
95 concept NonSlicedTube = !is_slicedtube_v<Q>;
96
97 template<typename T>
98 concept NonScalarTubeCodomain =
99 !std::is_same_v<std::remove_cvref_t<T>, double> &&
100 !std::is_same_v<std::remove_cvref_t<T>, Interval>;
101
102 template<typename T>
103 inline T operator_tube_union(const T& x1, const T& x2) { return x1 | x2; }
104
105 template<typename T>
106 inline T operator_tube_intersection(const T& x1, const T& x2) { return x1 & x2; }
107
108 template<typename T, typename X1, typename X2>
109 inline T operator_tube_add(const X1& x1, const X2& x2) { return x1 + x2; }
110
111 template<typename T, typename X1, typename X2>
112 inline T operator_tube_sub(const X1& x1, const X2& x2) { return x1 - x2; }
113
114 template<typename T, typename X1, typename X2>
115 inline T operator_tube_mul(const X1& x1, const X2& x2) { return x1 * x2; }
116
117 template<typename T>
118 inline T operator_tube_scal_mul(const Interval& x1, const T& x2) { return x1 * x2; }
119
120 template<typename T>
121 inline T operator_tube_mul_scal(const T& x1, const Interval& x2) { return x1 * x2; }
122
123 inline IntervalVector operator_tube_mul_vec(const IntervalMatrix& x1, const IntervalVector& x2) { return x1 * x2; }
124
125 template<typename T, typename X1, typename X2>
126 inline T operator_tube_div(const X1& x1, const X2& x2) { return x1 / x2; }
127
128 template<typename T, typename X1>
129 inline T operator_tube_div_scal(const X1& x1, const Interval& x2) { return x1 / x2; }
130
143 template<typename T>
145 macro_member_binary_tube_tube(operator_tube_union<T>);
146
159 template<typename T>
160 inline SlicedTube<T> operator|(const SlicedTube<T>& x1, const SlicedTube<T>& x2)
161 macro_binary_tube_tube(operator_tube_union<T>,x1);
162
175 template<typename T>
177 macro_member_binary_tube_tube(operator_tube_intersection<T>);
178
191 template<typename T>
193 macro_binary_tube_tube(operator_tube_intersection<T>,x1);
194
204 template<typename T>
205 inline const SlicedTube<T>& operator+(const SlicedTube<T>& x1)
206 {
207 return x1;
208 }
209
222 template<typename T>
224 macro_binary_tube_tube(operator_tube_add<T>,x1);
225
238 template<typename T, typename Q>
239 requires NonSlicedTube<Q>
240 inline SlicedTube<T> operator+(const SlicedTube<T>& x1, const Q& x2)
241 macro_binary_tube_real(operator_tube_add<T>);
242
255 template<typename T, typename Q>
256 requires NonSlicedTube<Q>
257 inline SlicedTube<T> operator+(const Q& x1, const SlicedTube<T>& x2)
258 macro_binary_real_tube(operator_tube_add<T>);
259
267 template<typename T, typename Q>
268 requires NonSlicedTube<Q>
269 inline SlicedTube<T>& operator+=(SlicedTube<T>& x1, const Q& x2)
270 macro_member_binary_tube_real(operator_tube_add<T>);
271
279 template<typename T>
281 macro_member_binary_tube_tube(operator_tube_add<T>);
282
292 template<typename T>
294 {
295 return -1. * x1;
296 }
297
310 template<typename T>
312 macro_binary_tube_tube(operator_tube_sub<T>,x1);
313
326 template<typename T, typename Q>
327 requires NonSlicedTube<Q>
328 inline SlicedTube<T> operator-(const SlicedTube<T>& x1, const Q& x2)
329 macro_binary_tube_real(operator_tube_sub<T>);
330
343 template<typename T, typename Q>
344 requires NonSlicedTube<Q>
345 inline SlicedTube<T> operator-(const Q& x1, const SlicedTube<T>& x2)
346 macro_binary_real_tube(operator_tube_sub<T>);
347
355 template<typename T, typename Q>
356 requires NonSlicedTube<Q>
357 inline SlicedTube<T>& operator-=(SlicedTube<T>& x1, const Q& x2)
358 macro_member_binary_tube_real(operator_tube_sub<T>);
359
367 template<typename T>
369 macro_member_binary_tube_tube(operator_tube_sub<T>);
370
383 template<typename T>
384 requires (!std::is_same_v<T, double>)
385 inline SlicedTube<T> operator*(const Interval& x1, const SlicedTube<T>& x2)
386 macro_binary_real_tube(operator_tube_scal_mul<T>);
387
400 template<typename T>
401 requires (!std::is_same_v<T, double>)
402 inline SlicedTube<T> operator*(const SlicedTube<T>& x1, const Interval& x2)
403 macro_binary_tube_real(operator_tube_mul_scal<T>);
404
415 macro_binary_tube_tube(operator_tube_mul<Interval>,x1);
416
427 macro_binary_tube_tube(operator_tube_mul<IntervalVector>,x1);
428
439 macro_binary_tube_tube(operator_tube_mul<IntervalMatrix>,x1);
440
452 template<typename T>
453 requires NonScalarTubeCodomain<T>
455 macro_binary_tube_tube(operator_tube_mul<T>,x2);
456
468 template<typename T>
469 requires NonScalarTubeCodomain<T>
471 macro_binary_tube_tube(operator_tube_mul<T>,x1);
472
485 template<typename T, typename Q>
486 requires NonSlicedTube<Q>
487 inline SlicedTube<T> operator*(const SlicedTube<T>& x1, const Q& x2)
488 macro_binary_tube_real(operator_tube_mul<T>);
489
502 template<typename T, typename Q>
503 requires NonSlicedTube<Q>
504 inline SlicedTube<T> operator*(const Q& x1, const SlicedTube<T>& x2)
505 macro_binary_real_tube(operator_tube_mul<T>);
506
517 macro_binary_tube_tube(operator_tube_mul_vec,x2);
518
526 template<typename T, typename Q>
527 requires NonSlicedTube<Q>
528 inline SlicedTube<T>& operator*=(SlicedTube<T>& x1, const Q& x2)
529 macro_member_binary_tube_real(operator_tube_mul<T>);
530
538 template<typename T>
540 macro_member_binary_tube_tube(operator_tube_mul<T>);
541
553 template<typename T>
554 requires NonScalarTubeCodomain<T>
556 macro_member_binary_tube_tube(operator_tube_mul<T>);
557
570 template<typename T>
571 requires (!std::is_same_v<T, double>)
572 inline SlicedTube<T> operator/(const SlicedTube<T>& x1, const Interval& x2)
573 macro_binary_tube_real(operator_tube_div_scal<T>);
574
585 macro_binary_tube_tube(operator_tube_div<Interval>,x1);
586
598 template<typename T>
599 requires NonScalarTubeCodomain<T>
601 macro_binary_tube_tube(operator_tube_div<T>,x1);
602
615 template<typename T, typename Q>
616 requires NonSlicedTube<Q>
617 inline SlicedTube<T> operator/(const SlicedTube<T>& x1, const Q& x2)
618 macro_binary_tube_real(operator_tube_div<T>);
619
632 template<typename T, typename Q>
633 requires NonSlicedTube<Q>
634 inline SlicedTube<T> operator/(const Q& x1, const SlicedTube<T>& x2)
635 macro_binary_real_tube(operator_tube_div<T>);
636
644 template<typename T, typename Q>
645 requires NonSlicedTube<Q>
646 inline SlicedTube<T>& operator/=(SlicedTube<T>& x1, const Q& x2)
647 macro_member_binary_tube_real(operator_tube_div<T>);
648
656 template<typename T>
658 macro_member_binary_tube_tube(operator_tube_div<T>);
659
671 template<typename T>
672 requires NonScalarTubeCodomain<T>
674 macro_member_binary_tube_tube(operator_tube_div<T>);
675
685
695
706
717
727
737
747
757
767
777
787
797
808
819
830
840
850
860
870
880
890
900
911
922
933
944
955
966
976
986
996
1006}
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:49
Tube represented over a sliced temporal domain.
Definition codac2_SlicedTube.h:38
Definition codac2_OctaSym.h:21
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
SlicedTube< T > & operator&=(SlicedTube< T > &x1, const SlicedTube< T > &x2) macro_member_binary_tube_tube(operator_tube_intersection< T >)
Pointwise intersection assignment of two tubes with the same codomain type.
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:445
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:468
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
Eigen::Matrix< Interval,-1, 1 > IntervalVector
Alias for a dynamic-size column vector of intervals.
Definition codac2_IntervalVector.h:25
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.
CtcInterType< typenameC1::ContractedTypes >::Ctc operator&(const C1 &c1, const C2 &c2)
Builds an intersection contractor from two contractors.
Definition codac2_CtcInter.h:216
Interval operator-(const Interval &x, double y)
Returns with .
Definition codac2_Interval_impl.h:422
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 SlicedTube< T > &x2) macro_member_binary_tube_tube(operator_tube_union< T >)
Pointwise hull-union assignment of two tubes with the same codomain type.
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 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
Eigen::Matrix< Interval,-1,-1 > IntervalMatrix
Alias for a dynamic-size matrix of intervals.
Definition codac2_IntervalMatrix.h:25
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