codac 2.0.0
Loading...
Searching...
No Matches
codac2_SlicedTube.h
Go to the documentation of this file.
1
9
10#pragma once
11
15#include "codac2_CtcDeriv.h"
16#include "codac2_Scalar.h"
17#include "codac2_AnalyticTraj.h"
18
19namespace codac2
20{
36 template<typename T>
38 {
39 public:
40
47 explicit SlicedTube(const std::shared_ptr<TDomain>& tdomain,
48 const T& codomain)
50 {
51 for(auto it = _tdomain->begin(); it != _tdomain->end(); ++it)
52 it->_slices.insert({
53 this,
54 std::make_shared<Slice<T>>(*this, it, codomain)
55 });
56 }
57
67 explicit SlicedTube(const std::shared_ptr<TDomain>& tdomain,
68 const AnalyticFunction<typename ExprType<T>::Type>& f)
70 {
71 assert_release(f.args().size() == 1
72 && "function's inputs must be limited to one system variable");
73
74 for(auto it = _tdomain->begin(); it != _tdomain->end(); ++it)
75 it->_slices.insert({
76 this,
77 std::make_shared<Slice<T>>(*this, it, f.eval((Interval)*it))
78 });
79 }
80
90 template<typename V>
91 requires std::is_same_v<typename ExprType<T>::Type,V>
92 explicit SlicedTube(const std::shared_ptr<TDomain>& tdomain,
93 const AnalyticTraj<V>& x)
95 {
96 for(auto it = _tdomain->begin(); it != _tdomain->end(); ++it)
97 it->_slices.insert({
98 this,
99 std::make_shared<Slice<T>>(*this, it, x.eval((Interval)*it))
100 });
101 }
102
110 template<typename V>
111 requires std::is_same_v<typename Wrapper<V>::Domain,T>
112 explicit SlicedTube(const std::shared_ptr<TDomain>& tdomain,
113 const SampledTraj<V>& x)
115 {
116 for(auto it = _tdomain->begin(); it != _tdomain->end(); ++it)
117 it->_slices.insert({
118 this,
119 std::make_shared<Slice<T>>(*this, it, x((Interval)*it))
120 });
121 }
122
132 {
133 for(auto it = _tdomain->begin(); it != _tdomain->end(); ++it)
134 it->_slices.insert({
135 this,
136 std::make_shared<Slice<T>>(*x.slice(it), *this)
137 });
138 }
139
149 {
150 assert_release(_tdomain == x._tdomain);
151
152 for(auto it = _tdomain->begin(); it != _tdomain->end(); ++it)
153 slice(it)->set(x.slice(it)->codomain(), false);
154
155 return *this;
156 }
157
163 inline Index size() const
164 {
165 return first_slice()->size();
166 }
167
175 virtual std::pair<Index,Index> shape() const
176 {
177 if constexpr(std::is_same_v<typename ExprType<T>::Type,ScalarType>)
178 return {1,1};
179 else
180 return {first_slice()->codomain().rows(),first_slice()->codomain().cols()};
181 }
182
190 inline double volume() const
191 {
192 double volume = 0.;
193 for(const auto& s : *this)
194 if(!s.is_gate())
195 volume += s.volume();
196 return volume;
197 }
198
204 inline std::shared_ptr<Slice<T>> first_slice()
205 {
206 return std::const_pointer_cast<Slice<T>>(
207 static_cast<const SlicedTube&>(*this).first_slice());
208 }
209
215 inline std::shared_ptr<const Slice<T>> first_slice() const
216 {
217 return std::static_pointer_cast<const Slice<T>>(
219 }
220
226 inline std::shared_ptr<Slice<T>> last_slice()
227 {
228 return std::const_pointer_cast<Slice<T>>(
229 static_cast<const SlicedTube&>(*this).last_slice());
230 }
231
237 inline std::shared_ptr<const Slice<T>> last_slice() const
238 {
239 return std::static_pointer_cast<const Slice<T>>(
241 }
242
249 inline std::shared_ptr<Slice<T>> slice(const std::list<TSlice>::iterator& it)
250 {
251 return std::const_pointer_cast<Slice<T>>(
252 static_cast<const SlicedTube&>(*this).slice(it));
253 }
254
261 inline std::shared_ptr<const Slice<T>> slice(const std::list<TSlice>::const_iterator& it) const
262 {
263 return std::static_pointer_cast<const Slice<T>>(
264 it->slices().at(this));
265 }
266
273 inline std::shared_ptr<Slice<T>> slice(const std::list<TSlice>::reverse_iterator& it)
274 {
275 return std::const_pointer_cast<Slice<T>>(
276 static_cast<const SlicedTube&>(*this).slice(it));
277 }
278
285 inline std::shared_ptr<const Slice<T>> slice(const std::list<TSlice>::const_reverse_iterator& it) const
286 {
287 return std::static_pointer_cast<const Slice<T>>(
288 it->slices().at(this));
289 }
290
299 inline std::shared_ptr<Slice<T>> slice(std::shared_ptr<TSlice> ptr)
300 {
301 // Used in Python binding
302 auto it = std::find_if(_tdomain->begin(), _tdomain->end(),
303 [&](TSlice& t){ return &t == ptr.get(); });
304 assert(it != _tdomain->end());
305 return slice(it);
306 }
307
316 inline bool is_empty() const
317 {
318 for(const auto& s : *this)
319 if(s.is_gate() && s.is_empty())
320 return true;
321 for(const auto& s : *this)
322 if(!s.is_gate() && s.is_empty())
323 return true;
324 return false;
325 }
326
332 inline bool is_unbounded() const
333 {
334 for(const auto& s : *this)
335 if(s.is_unbounded())
336 return true;
337 return false;
338 }
339
347 inline T codomain() const
348 {
349 T x = first_slice()->codomain();
350 for(const auto& s : *this)
351 x |= s.codomain();
352 return x;
353 }
354
355 template<typename Func>
356 inline T eval_common(const Interval& t, const Func& apply_eval) const
357 {
358 if(!tdomain()->t0_tf().is_superset(t))
359 return all_reals_value();
360
361 auto it = _tdomain->tslice(t.lb());
362 assert(it != _tdomain->end());
363 T codomain = apply_eval(it, t & *it);
364
365 while(it != std::next(_tdomain->tslice(t.ub())))
366 {
367 if(it->lb() == t.ub()) break;
368 codomain |= apply_eval(it, t & *it);
369 it++;
370 }
371
372 return codomain;
373 }
374
381 T operator()(const Interval& t) const
382 {
383 return eval_common(t,
384 [this](auto it, const Interval& t_) {
385 return slice(it)->operator()(t_);
386 });
387 }
388
396 T operator()(const Interval& t, const SlicedTube<T>& v) const
397 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
398 {
399 return eval_common(t,
400 [this,&v](auto it, const Interval& t_) {
401 return slice(it)->operator()(t_, *v.slice(it));
402 });
403 }
404
411 std::pair<T,T> enclosed_bounds(const Interval& t) const
412 {
413 auto x = this->empty_value();
414 auto bounds = std::make_pair(x,x);
415
416 if(t.lb() < _tdomain->t0_tf().lb() || t.ub() > _tdomain->t0_tf().ub())
417 {
418 x.init(Interval(-oo,0));
419 bounds.first |= x;
420 x.init(Interval(0,oo));
421 bounds.second |= x;
422 }
423
424 Interval t_inter = t & _tdomain->t0_tf();
425 auto si = slice(_tdomain->tslice(t_inter.lb()));
426
427 while(si && si->t0_tf().lb() <= t_inter.ub())
428 {
429 auto slice_bounds = si->enclosed_bounds(t_inter & si->t0_tf());
430 bounds.first |= slice_bounds.first;
431 bounds.second |= slice_bounds.second;
432 si = si->next_slice();
433 }
434
435 return bounds;
436 }
437
443 inline void set(const T& codomain)
444 {
445 assert_release(codomain.size() == this->size());
446
447 for(auto& s : *this)
448 if(!s.is_gate())
449 s.set(codomain, false);
450
451 for(auto& s : *this)
452 if(s.is_gate())
453 s.set(codomain, false);
454 }
455
464 inline void set(const T& codomain, double t)
465 {
466 assert_release(codomain.size() == this->size());
467 slice(_tdomain->sample(t,true))->set(codomain);
468 }
469
479 inline void set(const T& codomain, const Interval& t)
480 {
481 auto it_lb = _tdomain->sample(t.lb(), t.is_degenerated());
482 std::list<TSlice>::iterator it_ub;
483
484 if(!t.is_degenerated())
485 {
486 it_ub = _tdomain->sample(t.ub(), false);
487
488 if(it_ub->lb() == t.ub())
489 it_ub--; // pointing to the tslice [..,t.ub()]
490
491 if(it_lb->ub() == t.lb())
492 it_lb++;
493 }
494
495 else
496 it_ub = it_lb;
497
498 do
499 {
500 slice(it_lb)->set(codomain);
501 } while(it_lb != it_ub && (++it_lb) != _tdomain->end());
502 }
503
510 inline void set_ith_slice(const T& codomain, Index i)
511 {
512 Index j = 0;
513 for(auto& si : *this)
514 if(j++ == i)
515 {
516 si.set(codomain);
517 break;
518 }
519 }
520
528 template<typename V>
529 requires (std::is_same_v<typename Wrapper<V>::Domain,T> || std::is_same_v<V,double>)
530 const SlicedTube<T>& inflate(const V& rad)
531 {
532 // todo: faster implementation with iterators
533 for(auto& s : *this)
534 if(!s.is_gate())
535 s.set(T(s.codomain()).inflate(rad), false);
536
537 for(auto& s : *this)
538 if(s.is_gate())
539 s.set(T(s.codomain()).inflate(rad), false);
540
541 return *this;
542 }
543
551 template<typename V>
552 requires (std::is_same_v<typename Wrapper<V>::Domain,T> || std::is_same_v<V,double>)
553 const SlicedTube<T>& inflate(const SampledTraj<V>& rad)
554 {
555 // todo: faster implementation with iterators
556 assert_release(tdomain()->t0_tf().is_subset(rad.tdomain()));
557
558 for(auto& s : *this)
559 if(!s.is_gate())
560 s.set(T(s.codomain()).inflate(rad(s.t0_tf()).ub()), false);
561
562 for(auto& s : *this)
563 if(s.is_gate())
564 s.set(T(s.codomain()).inflate(rad(s.t0_tf()).ub()), false);
565
566 return *this;
567 }
568
576 {
577 assert_release(i >= 0 && i < size());
579 for(auto it = tdomain()->begin() ; it != tdomain()->end() ; it++)
580 xi.slice(it)->codomain() = slice(it)->codomain()[i];
581 return xi;
582 }
583
591 SlicedTube<IntervalVector> subvector(Index i, Index j) const
592 {
593 assert_release(i >= 0 && i <= j && j < size());
595 for(auto it = tdomain()->begin() ; it != tdomain()->end() ; it++)
596 xij.slice(it)->codomain() = slice(it)->codomain().subvector(i,j);
597 return xij;
598 }
599
609 inline bool operator==(const SlicedTube& x) const
610 {
612 return false;
613
614 auto it_this = _tdomain->begin();
615 auto it_x = x.tdomain()->cbegin();
616
617 while(it_this != _tdomain->end())
618 if(*slice(it_this++) != *x.slice(it_x++))
619 return false;
620
621 return true;
622 }
623
633 {
634 assert(TDomain::are_same(tdomain(), x.tdomain()));
635 auto it_this = _tdomain->begin();
636 auto it_x = x.tdomain()->cbegin();
637
638 while(it_this != _tdomain->end())
639 {
640 auto s = slice(it_this);
641 s->set(s->codomain() & x.slice(it_x)->codomain());
642 it_this++; it_x++;
643 }
644
645 assert(it_x == x.tdomain()->cend());
646 return *this;
647 }
648
656 friend inline std::ostream& operator<<(std::ostream& os, const SlicedTube<T>& x)
657 {
658 os << x.t0_tf()
659 << "↦" << (x.is_empty() ? x.empty_value() : x.codomain())
660 << ", " << x.nb_slices()
661 << " slice" << (x.nb_slices() > 1 ? "s" : "")
662 << std::flush;
663 return os;
664 }
665
672 AnalyticFunction<typename ExprType<T>::Type> as_function() const
673 {
674 ScalarVar t;
675 return {{t},
676 AnalyticExprWrapper<typename ExprType<T>::Type>(
677 std::make_shared<AnalyticOperationExpr<
678 TubeOp<SlicedTube<T>>,typename ExprType<T>::Type,ScalarType>>(*this,t))
679 };
680 }
681
682 // Inversion related methods
683
687
688 template<typename Func>
689 Interval invert_common(const T& y, const Interval& t, const Func& apply_invert) const
690 {
691 assert_release(y.size() == this->size());
692
693 if(t.is_empty() || y.is_empty())
694 return Interval::empty();
695
696 else if(!t.is_subset(_tdomain->t0_tf()))
697 return Interval();
698
700 Interval t_ = t & _tdomain->t0_tf();
701
702 assert(!t_.is_empty() && !t_.is_unbounded());
703 for(auto it = _tdomain->tslice(t_.lb()) ;
704 it != _tdomain->end() && it->lb() <= t_.ub() ; it++)
705 {
706 if(!t_.is_degenerated() && it->is_gate())
707 continue;
708
709 assert(it != _tdomain->end());
710 invert |= apply_invert(it, t & *it);
711 }
712
713 return invert;
714 }
715
716 template<typename Func>
717 void invert_common_subsets(const T& y, std::vector<Interval> &v_t,
718 const Interval& t, const Func& apply_invert) const
719 {
720 assert_release(y.size() == this->size());
721 v_t.clear();
722
723 if(t.is_empty() || y.is_empty())
724 return;
725
726 else if(!t.is_subset(_tdomain->t0_tf()))
727 {
728 v_t.push_back(Interval());
729 return;
730 }
731
732 Interval invert = Interval::empty();
733 Interval t_ = t & _tdomain->t0_tf();
734
735 assert(!t_.is_empty() && !t_.is_unbounded());
736 for(auto it = _tdomain->tslice(t_.lb()) ;
737 it != _tdomain->end() && it->lb() < t_.ub() ; it++)
738 {
739 if(it->is_gate())
740 continue;
741
742 assert(it != _tdomain->end());
743 Interval local_invert = apply_invert(it, t & *it);
744
745 if(local_invert.is_empty() && !invert.is_empty())
746 {
747 v_t.push_back(invert);
748 invert.set_empty();
749 }
750
751 else
752 invert |= local_invert;
753 }
754
755 if(!invert.is_empty())
756 v_t.push_back(invert);
757 }
758
767 Interval invert(const T& y) const
768 {
769 return invert(y,t0_tf());
770 }
771
782 Interval invert(const T& y, const Interval& t) const
783 {
784 return invert_common(y, t,
785 [this,&y](auto it, const Interval& t_) {
786 return slice(it)->invert(y, t_);
787 });
788 }
789
797 void invert(const T& y, std::vector<Interval> &v_t) const
798 {
799 invert(y,v_t,t0_tf());
800 }
801
811 void invert(const T& y, std::vector<Interval> &v_t, const Interval& t) const
812 {
813 return invert_common_subsets(y, v_t, t,
814 [this,&y](auto it, const Interval& t_) {
815 return slice(it)->invert(y, t_);
816 });
817 }
818
829 Interval invert(const T& y, const SlicedTube<T>& v) const
830 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
831 {
832 return invert(y,v,t0_tf());
833 }
834
847 Interval invert(const T& y, const SlicedTube<T>& v, const Interval& t) const
848 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
849 {
850 return invert_common(y, t,
851 [this,&v,&y](auto it, const Interval& t_) {
852 return slice(it)->invert(y, *v.slice(it), t_);
853 });
854 }
855
866 void invert(const T& y, std::vector<Interval> &v_t, const SlicedTube<T>& v) const
867 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
868 {
869 invert(y,v_t,v,t0_tf());
870 }
871
884 void invert(const T& y, std::vector<Interval> &v_t, const SlicedTube<T>& v, const Interval& t) const
885 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
886 {
887 return invert_common_subsets(y, v_t, t,
888 [this,&v,&y](auto it, const Interval& t_) {
889 return slice(it)->invert(y, *v.slice(it), t_);
890 });
891 }
892
893 // Integral related methods
894
901
918 T integral(const Interval& t) const;
919
938 T integral(const Interval& t1, const Interval& t2) const;
939
964 std::pair<T,T> partial_integral(const Interval& t) const;
965
992 std::pair<T,T> partial_integral(const Interval& t1, const Interval& t2) const;
993
1009 {
1010 auto x0 = all_reals_value();
1011 x0.init(0.);
1012 return primitive(x0);
1013 }
1014
1036 inline SlicedTube<T> primitive(const T& x0) const
1037 {
1038 auto x = all_reals_value();
1039 auto p = SlicedTube<T>(this->tdomain(), x);
1040 p.set(x0, this->tdomain()->t0_tf().lb()); // may create an unwanted gate
1041 CtcDeriv c;
1042 c.contract(p,*this);
1043 return p;
1044 }
1045
1051 inline T all_reals_value() const
1052 {
1053 T x = first_slice()->codomain();
1054 x.init();
1055 return x;
1056 }
1057
1063 inline T empty_value() const
1064 {
1065 T x = first_slice()->codomain();
1066 x.set_empty();
1067 return x;
1068 }
1069
1076 inline SampledTraj<typename Scalar<T>::Type> mid() const
1077 {
1078 SampledTraj<typename Scalar<T>::Type> m;
1079 double t0 = _tdomain->t0_tf().lb();
1080 m.set((*this)(t0).mid(), t0);
1081 for(const auto& s : *this)
1082 if(!s.is_gate())
1083 m.set(s.output_gate().mid(),s.t0_tf().ub());
1084 return m;
1085 }
1086
1087
1088 public:
1089
1090 using base_container = std::list<TSlice>;
1091
1095 struct iterator : public base_container::iterator
1096 {
1097 public:
1098
1099 iterator(SlicedTube& x, base_container::iterator it)
1100 : base_container::iterator(it), _x(x) { }
1101
1102 std::shared_ptr<Slice<T>> operator->()
1103 {
1104 return _x.slice(*this);
1105 }
1106
1107 Slice<T>& operator*()
1108 {
1109 return *operator->();
1110 }
1111
1112 protected:
1113
1114 SlicedTube& _x;
1115 };
1116
1120 iterator begin() { return { *this, _tdomain->begin() }; }
1121
1125 iterator end() { return { *this, _tdomain->end() }; }
1126
1130 struct reverse_iterator : public base_container::reverse_iterator
1131 {
1132 public:
1133
1134 reverse_iterator(SlicedTube& x, base_container::reverse_iterator it)
1135 : base_container::reverse_iterator(it), _x(x) { }
1136
1137 std::shared_ptr<Slice<T>> operator->()
1138 {
1139 return _x.slice(*this);
1140 }
1141
1142 Slice<T>& operator*()
1143 {
1144 return *operator->();
1145 }
1146
1147 protected:
1148
1149 SlicedTube& _x;
1150 };
1151
1155 reverse_iterator rbegin() { return { *this, _tdomain->rbegin() }; }
1156
1160 reverse_iterator rend() { return { *this, _tdomain->rend() }; }
1161
1165 struct const_iterator : public base_container::const_iterator
1166 {
1167 public:
1168
1169 const_iterator(const SlicedTube& x, base_container::const_iterator it)
1170 : base_container::const_iterator(it), _x(x) { }
1171
1172 std::shared_ptr<const Slice<T>> operator->()
1173 {
1174 return _x.slice(*this);
1175 }
1176
1177 const Slice<T>& operator*()
1178 {
1179 return *operator->();
1180 }
1181
1182 protected:
1183
1184 const SlicedTube& _x;
1185 };
1186
1190 const_iterator begin() const { return { *this, _tdomain->cbegin() }; }
1191
1195 const_iterator end() const { return { *this, _tdomain->cend() }; }
1196
1200 struct const_reverse_iterator : public base_container::const_reverse_iterator
1201 {
1202 public:
1203
1204 const_reverse_iterator(const SlicedTube& x, base_container::const_reverse_iterator it)
1205 : base_container::const_reverse_iterator(it), _x(x) { }
1206
1207 std::shared_ptr<const Slice<T>> operator->()
1208 {
1209 return _x.slice(*this);
1210 }
1211
1212 const Slice<T>& operator*()
1213 {
1214 return *operator->();
1215 }
1216
1217 protected:
1218
1219 const SlicedTube& _x;
1220 };
1221
1225 const_reverse_iterator rbegin() const { return { *this, _tdomain->crbegin() }; }
1226
1230 const_reverse_iterator rend() const { return { *this, _tdomain->crend() }; }
1231 };
1232
1233
1234 // Template deduction guide:
1235
1236 template<typename T>
1237 SlicedTube(const std::shared_ptr<TDomain>& tdomain, const AnalyticFunction<T>& f) ->
1238 SlicedTube<typename Wrapper<T>::Domain>;
1239
1240 template<typename T>
1241 SlicedTube(const std::shared_ptr<TDomain>& tdomain, const SampledTraj<T>& f) ->
1242 SlicedTube<typename Wrapper<T>::Domain>;
1243
1244 template<typename T>
1245 SlicedTube(const std::shared_ptr<TDomain>& tdomain, const AnalyticTraj<T>& f) ->
1246 SlicedTube<typename Wrapper<T>::Domain>;
1247
1248
1249 // Ctc
1250
1251 template<typename... X>
1252 inline void CtcBase<X...>::contract(SlicedTube<X>&... x) const
1253 {
1254 auto&& x0 = std::get<0>(std::forward_as_tuple(x...));
1255 for(auto it = x0.begin(); it != x0.end(); ++it)
1256 contract((x.slice(it)->codomain())...);
1257 }
1258
1259 template<typename... X>
1260 inline void CtcBase<X...>::contract_tube(SlicedTube<X>&... x) const
1261 {
1262 std::cout << "CtcInverse::contract_tube(...) is deprecated; \
1263 use CtcInverse::contract(...) with SlicedTube arguments instead" << std::endl;
1264 return contract(x...);
1265 }
1266}
1267
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:49
bool is_unbounded() const
Tests if one of the bounds of this is infinite.
Definition codac2_Interval_impl.h:220
bool is_empty() const
Tests if this is empty.
Definition codac2_Interval_impl.h:205
double ub() const
Returns the upper bound of this.
Definition codac2_Interval_impl.h:115
bool is_degenerated() const
Tests if this is degenerated, that is, in the form of .
Definition codac2_Interval_impl.h:225
bool is_subset(const Interval &x) const
Tests if this is a subset of x.
Definition codac2_Interval_impl.h:255
double lb() const
Returns the lower bound of this.
Definition codac2_Interval_impl.h:110
static Interval empty()
Provides an empty interval.
Definition codac2_Interval_impl.h:568
Codomain of a sliced tube over one temporal slice.
Definition codac2_Slice.h:42
std::shared_ptr< const SliceBase > first_slice() const
Returns the first slice of this tube.
Definition codac2_SlicedTubeBase.h:81
size_t nb_slices() const
Returns the number of temporal elements of this tube.
Definition codac2_SlicedTubeBase.h:67
std::shared_ptr< const SliceBase > last_slice() const
Returns the last slice of this tube.
Definition codac2_SlicedTubeBase.h:97
SlicedTubeBase(const std::shared_ptr< TDomain > &tdomain)
Creates a sliced tube over a given temporal domain.
Definition codac2_SlicedTubeBase.h:43
Tube represented over a sliced temporal domain.
Definition codac2_SlicedTube.h:38
SlicedTube(const std::shared_ptr< TDomain > &tdomain, const T &codomain)
Creates a sliced tube with constant codomain over all temporal slices.
Definition codac2_SlicedTube.h:47
SlicedTube(const SlicedTube< T > &x)
Copy constructor.
Definition codac2_SlicedTube.h:130
void set(const T &codomain, double t)
Sets the codomain at one temporal instant.
Definition codac2_SlicedTube.h:464
reverse_iterator rbegin()
Returns a reverse iterator to the last temporal slice.
Definition codac2_SlicedTube.h:1155
std::pair< T, T > enclosed_bounds(const Interval &t) const
Returns enclosed lower and upper bounds over a temporal interval.
Definition codac2_SlicedTube.h:411
void invert(const T &y, std::vector< Interval > &v_t, const SlicedTube< T > &v) const
Computes the set of continuous values of the optimal inversion .
Definition codac2_SlicedTube.h:866
void set(const T &codomain)
Sets all codomains of this tube to the same value.
Definition codac2_SlicedTube.h:443
T all_reals_value() const
Returns the unbounded codomain value associated with T.
Definition codac2_SlicedTube.h:1051
void set(const T &codomain, const Interval &t)
Sets the codomain over a temporal interval.
Definition codac2_SlicedTube.h:479
virtual std::pair< Index, Index > shape() const
Returns the matrix shape of this tube codomain.
Definition codac2_SlicedTube.h:175
SlicedTube & operator=(const SlicedTube &x)
Assignment operator.
Definition codac2_SlicedTube.h:148
void invert(const T &y, std::vector< Interval > &v_t) const
Computes the set of continuous values of the inversion .
Definition codac2_SlicedTube.h:797
SlicedTube(const std::shared_ptr< TDomain > &tdomain, const AnalyticTraj< V > &x)
Creates a sliced tube by evaluating an analytic trajectory on each temporal slice.
Definition codac2_SlicedTube.h:92
iterator begin()
Returns an iterator to the first temporal slice.
Definition codac2_SlicedTube.h:1120
T operator()(const Interval &t) const
Evaluates this tube over a temporal interval.
Definition codac2_SlicedTube.h:381
std::shared_ptr< const Slice< T > > last_slice() const
Returns the last slice of this tube.
Definition codac2_SlicedTube.h:237
std::shared_ptr< Slice< T > > first_slice()
Returns the first slice of this tube.
Definition codac2_SlicedTube.h:204
T codomain() const
Returns the global codomain of this tube.
Definition codac2_SlicedTube.h:347
T empty_value() const
Returns the empty codomain value associated with T.
Definition codac2_SlicedTube.h:1063
bool is_unbounded() const
Tests whether this tube is unbounded.
Definition codac2_SlicedTube.h:332
SlicedTube(const std::shared_ptr< TDomain > &tdomain, const AnalyticFunction< typename ExprType< T >::Type > &f)
Creates a sliced tube by evaluating an analytic function on each temporal slice.
Definition codac2_SlicedTube.h:67
SlicedTube< IntervalVector > subvector(Index i, Index j) const
Extracts a subvector of this tube.
Definition codac2_SlicedTube.h:591
void set_ith_slice(const T &codomain, Index i)
Sets the codomain of the -th stored slice.
Definition codac2_SlicedTube.h:510
std::shared_ptr< const Slice< T > > slice(const std::list< TSlice >::const_iterator &it) const
Returns the slice attached to a temporal iterator.
Definition codac2_SlicedTube.h:261
reverse_iterator rend()
Returns a reverse iterator past the first temporal slice.
Definition codac2_SlicedTube.h:1160
Index size() const
Returns the codomain dimension.
Definition codac2_SlicedTube.h:163
bool is_empty() const
Tests whether this tube is empty.
Definition codac2_SlicedTube.h:316
const_reverse_iterator rend() const
Returns a constant reverse iterator past the first temporal slice.
Definition codac2_SlicedTube.h:1230
double volume() const
Returns the volume of this tube.
Definition codac2_SlicedTube.h:190
SlicedTube(const std::shared_ptr< TDomain > &tdomain, const SampledTraj< V > &x)
Creates a sliced tube from a sampled trajectory.
Definition codac2_SlicedTube.h:112
const_reverse_iterator rbegin() const
Returns a constant reverse iterator to the last temporal slice.
Definition codac2_SlicedTube.h:1225
Interval invert(const T &y) const
Returns the interval inversion .
Definition codac2_SlicedTube.h:767
SlicedTube & operator&=(const SlicedTube &x)
Intersects this tube with another one.
Definition codac2_SlicedTube.h:632
const SlicedTube< T > & inflate(const SampledTraj< V > &rad)
Inflates this tube by a time-varying sampled radius.
Definition codac2_SlicedTube.h:553
std::shared_ptr< Slice< T > > slice(const std::list< TSlice >::reverse_iterator &it)
Returns the slice attached to a reverse temporal iterator.
Definition codac2_SlicedTube.h:273
std::shared_ptr< const Slice< T > > first_slice() const
Returns the first slice of this tube.
Definition codac2_SlicedTube.h:215
iterator end()
Returns an iterator past the last temporal slice.
Definition codac2_SlicedTube.h:1125
std::shared_ptr< Slice< T > > last_slice()
Returns the last slice of this tube.
Definition codac2_SlicedTube.h:226
bool operator==(const SlicedTube &x) const
Compares two sliced tubes.
Definition codac2_SlicedTube.h:609
SlicedTube< Interval > operator[](Index i) const
Extracts one scalar component of this tube.
Definition codac2_SlicedTube.h:575
T operator()(const Interval &t, const SlicedTube< T > &v) const
Returns the optimal evaluation over a temporal interval using a derivative tube.
Definition codac2_SlicedTube.h:396
const_iterator end() const
Returns a constant iterator past the last temporal slice.
Definition codac2_SlicedTube.h:1195
std::shared_ptr< Slice< T > > slice(std::shared_ptr< TSlice > ptr)
Returns the slice attached to a temporal slice pointer.
Definition codac2_SlicedTube.h:299
Interval invert(const T &y, const SlicedTube< T > &v) const
Returns the optimal interval inversion .
Definition codac2_SlicedTube.h:829
AnalyticFunction< typename ExprType< T >::Type > as_function() const
Returns an analytic wrapper of this tube, allowing to evaluate this tube as an operator in an analyti...
Definition codac2_SlicedTube.h:672
friend std::ostream & operator<<(std::ostream &os, const SlicedTube< T > &x)
Stream output for a sliced tube.
Definition codac2_SlicedTube.h:656
const SlicedTube< T > & inflate(const V &rad)
Inflates this tube by a constant radius.
Definition codac2_SlicedTube.h:530
SampledTraj< typename Scalar< T >::Type > mid() const
Returns the approximated midpoint trajectory of this tube.
Definition codac2_SlicedTube.h:1076
std::shared_ptr< const Slice< T > > slice(const std::list< TSlice >::const_reverse_iterator &it) const
Returns the slice attached to a reverse temporal iterator.
Definition codac2_SlicedTube.h:285
std::shared_ptr< Slice< T > > slice(const std::list< TSlice >::iterator &it)
Returns the slice attached to a temporal iterator.
Definition codac2_SlicedTube.h:249
const_iterator begin() const
Returns a constant iterator to the first temporal slice.
Definition codac2_SlicedTube.h:1190
static bool are_same(const std::shared_ptr< const TDomain > &tdom1, const std::shared_ptr< const TDomain > &tdom2)
Tests whether two temporal domains share the same temporal partition.
Temporal slice shared by sliced tubes.
Definition codac2_TSlice.h:34
const std::shared_ptr< TDomain > _tdomain
Shared temporal domain of this tube.
Definition codac2_TubeBase.h:71
Interval t0_tf() const
Returns the global temporal interval of this tube.
Definition codac2_TubeBase.h:61
const std::shared_ptr< TDomain > & tdomain() const
Returns the temporal domain of this tube.
Definition codac2_TubeBase.h:49
bool is_superset(const Matrix< codac2::Interval, RowsAtCompileTime, ColsAtCompileTime > &x) const
Checks whether this matrix is a superset of another interval matrix.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:858
bool is_subset(const Matrix< codac2::Interval, RowsAtCompileTime, ColsAtCompileTime > &x) const
Checks whether this matrix is a subset of another interval matrix.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:678
auto lb() const
Returns a matrix containing the lower bounds of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:91
auto rad() const
Returns a matrix containing the radii of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:197
std::pair< T, T > partial_integral(const Interval &t) const
Returns lower and upper enclosures of the integrals of this tube from to .
Definition codac2_SlicedTube_integral_impl.h:58
SlicedTube< T > primitive() const
Returns a primitive of this tube with zero initial condition.
Definition codac2_SlicedTube.h:1008
SlicedTube< T > primitive(const T &x0) const
Returns a primitive of this tube with prescribed initial condition.
Definition codac2_SlicedTube.h:1036
T integral(const Interval &t) const
Returns an enclosure of the integrals of this tube from to .
Definition codac2_SlicedTube_integral_impl.h:17
void invert(const T &y, std::vector< Interval > &v_t, const Interval &t) const
Computes the set of continuous values of the inversion .
Definition codac2_SlicedTube.h:811
Interval invert(const T &y, const SlicedTube< T > &v, const Interval &t) const
Returns the optimal interval inversion .
Definition codac2_SlicedTube.h:847
void invert(const T &y, std::vector< Interval > &v_t, const SlicedTube< T > &v, const Interval &t) const
Computes the set of continuous values of the optimal inversion .
Definition codac2_SlicedTube.h:884
Interval invert(const T &y, const Interval &t) const
Returns the interval inversion .
Definition codac2_SlicedTube.h:782
Definition codac2_OctaSym.h:21
Eigen::Matrix< Interval,-1, 1 > IntervalVector
Alias for a dynamic-size column vector of intervals.
Definition codac2_IntervalVector.h:25
Constant iterator over the slices of this tube.
Definition codac2_SlicedTube.h:1166
Constant reverse iterator over the slices of this tube.
Definition codac2_SlicedTube.h:1201
Mutable iterator over the slices of this tube.
Definition codac2_SlicedTube.h:1096
Mutable reverse iterator over the slices of this tube.
Definition codac2_SlicedTube.h:1131