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(it->t0_tf()))
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(it->t0_tf()))
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(it->t0_tf()))
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 assert_release(ptr != nullptr);
302 auto s = std::static_pointer_cast<Slice<T>>(ptr->slices().at(this));
303 assert_release(&s->tslice() == ptr.get());
304 return s;
305 }
306
315 inline bool is_empty() const
316 {
317 for(const auto& s : *this)
318 if(s.is_gate() && s.is_empty())
319 return true;
320 for(const auto& s : *this)
321 if(!s.is_gate() && s.is_empty())
322 return true;
323 return false;
324 }
325
331 inline bool is_unbounded() const
332 {
333 for(const auto& s : *this)
334 if(s.is_unbounded())
335 return true;
336 return false;
337 }
338
346 inline T codomain() const
347 {
348 T x = first_slice()->codomain();
349 for(const auto& s : *this)
350 x |= s.codomain();
351 return x;
352 }
353
354 template<typename Func>
355 inline T eval_common(const Interval& t, const Func& apply_eval) const
356 {
357 if(!tdomain()->t0_tf().is_superset(t))
358 return all_reals_value();
359
360 auto it = _tdomain->tslice(t.lb());
361 assert(it != _tdomain->end());
362 T codomain = apply_eval(it, t & it->t0_tf());
363
364 const auto it_end = std::next(_tdomain->tslice(t.ub()));
365 while(it != it_end)
366 {
367 if(it->lb() == t.ub()) break;
368 codomain |= apply_eval(it, t & it->t0_tf());
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 this->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 this->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
699 Interval t_ = t & _tdomain->t0_tf();
700 assert(!t_.is_empty() && !t_.is_unbounded());
701
702 auto first = _tdomain->tslice(t_.lb());
703 auto last = _tdomain->tslice(t_.ub());
704
705 // Include the envelope following a gate at the upper temporal bound.
706 auto next = std::next(last);
707 if(next != _tdomain->end() && next->lb() == t_.ub())
708 last = next;
709
710 auto local_invert = [&](auto it) -> Interval
711 {
712 if(!t_.is_degenerated() && it->is_gate())
713 return Interval::empty();
714
715 const Interval local_t = t_ & it->t0_tf();
716 // The two-sided search relies on each result being contained
717 // in its temporal support, including after geometric inversion.
718 return apply_invert(it, local_t) & local_t;
719 };
720
721 // Find the first non-empty local inversion.
722 Interval invert = local_invert(first);
723 while(invert.is_empty() && first != last)
724 invert = local_invert(++first);
725
726 if(invert.is_empty())
727 return invert;
728
729 // Only the last non-empty local inversion can extend the hull.
730 // Do not evaluate the first successful slice a second time.
731 while(last != first)
732 {
733 Interval right = local_invert(last);
734 if(!right.is_empty())
735 return invert | right;
736 --last;
737 }
738
739 return invert;
740 }
741
742 template<typename Func>
743 void invert_common_subsets(const T& y, std::vector<Interval> &v_t,
744 const Interval& t, const Func& apply_invert) const
745 {
746 assert_release(y.size() == this->size());
747 v_t.clear();
748
749 if(t.is_empty() || y.is_empty())
750 return;
751
752 else if(!t.is_subset(_tdomain->t0_tf()))
753 {
754 v_t.push_back(Interval());
755 return;
756 }
757
758 Interval invert = Interval::empty();
759 Interval t_ = t & _tdomain->t0_tf();
760
761 assert(!t_.is_empty() && !t_.is_unbounded());
762 for(auto it = _tdomain->tslice(t_.lb()) ;
763 it != _tdomain->end() && it->lb() < t_.ub() ; it++)
764 {
765 if(it->is_gate())
766 continue;
767
768 assert(it != _tdomain->end());
769 Interval local_invert = apply_invert(it, t & it->t0_tf());
770
771 if(local_invert.is_empty() && !invert.is_empty())
772 {
773 v_t.push_back(invert);
774 invert.set_empty();
775 }
776
777 else
778 invert |= local_invert;
779 }
780
781 if(!invert.is_empty())
782 v_t.push_back(invert);
783 }
784
793 Interval invert(const T& y) const
794 {
795 return invert(y,t0_tf());
796 }
797
808 Interval invert(const T& y, const Interval& t) const
809 {
810 return invert_common(y, t,
811 [this,&y](auto it, const Interval& t_) {
812 return this->slice(it)->invert(y, t_);
813 });
814 }
815
823 void invert(const T& y, std::vector<Interval> &v_t) const
824 {
825 invert(y,v_t,t0_tf());
826 }
827
837 void invert(const T& y, std::vector<Interval> &v_t, const Interval& t) const
838 {
839 return invert_common_subsets(y, v_t, t,
840 [this,&y](auto it, const Interval& t_) {
841 return this->slice(it)->invert(y, t_);
842 });
843 }
844
855 Interval invert(const T& y, const SlicedTube<T>& v) const
856 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
857 {
858 return invert(y,v,t0_tf());
859 }
860
873 Interval invert(const T& y, const SlicedTube<T>& v, const Interval& t) const
874 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
875 {
876 return invert_common(y, t,
877 [this,&v,&y](auto it, const Interval& t_) {
878 return this->slice(it)->invert(y, *v.slice(it), t_);
879 });
880 }
881
892 void invert(const T& y, std::vector<Interval> &v_t, const SlicedTube<T>& v) const
893 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
894 {
895 invert(y,v_t,v,t0_tf());
896 }
897
910 void invert(const T& y, std::vector<Interval> &v_t, const SlicedTube<T>& v, const Interval& t) const
911 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
912 {
913 return invert_common_subsets(y, v_t, t,
914 [this,&v,&y](auto it, const Interval& t_) {
915 return this->slice(it)->invert(y, *v.slice(it), t_);
916 });
917 }
918
919 // Integral related methods
920
936 {
937 auto x0 = all_reals_value();
938 x0.init(0.);
939 return primitive(x0);
940 }
941
963 inline SlicedTube<T> primitive(const T& x0) const
964 {
965 auto x = all_reals_value();
966 auto p = SlicedTube<T>(this->tdomain(), x);
967 p.set(x0, this->tdomain()->t0_tf().lb()); // may create an unwanted gate
968 CtcDeriv c;
969 c.contract(p,*this);
970 return p;
971 }
972
979
996 T integral(const Interval& t) const;
997
1018 T integral(const Interval& t1, const Interval& t2) const;
1019
1044 std::pair<T,T> partial_integral(const Interval& t) const;
1045
1072 std::pair<T,T> partial_integral(const Interval& t1, const Interval& t2) const;
1073
1101 std::pair<SlicedTube<T>,SlicedTube<T>> partial_primitives() const;
1102
1120 T integral(const Interval& t,
1121 const std::pair<SlicedTube<T>,SlicedTube<T>>& primitives) const;
1122
1149 T integral(const Interval& t1, const Interval& t2,
1150 const std::pair<SlicedTube<T>,SlicedTube<T>>& primitives) const;
1151
1177 std::pair<T,T> partial_integral(const Interval& t,
1178 const std::pair<SlicedTube<T>,SlicedTube<T>>& primitives) const;
1179
1205 std::pair<T,T> partial_integral(const Interval& t1, const Interval& t2,
1206 const std::pair<SlicedTube<T>,SlicedTube<T>>& primitives) const;
1207
1213 inline T all_reals_value() const
1214 {
1215 T x = first_slice()->codomain();
1216 x.init();
1217 return x;
1218 }
1219
1225 inline T empty_value() const
1226 {
1227 T x = first_slice()->codomain();
1228 x.set_empty();
1229 return x;
1230 }
1231
1238 inline SampledTraj<typename Scalar<T>::Type> mid() const
1239 {
1240 SampledTraj<typename Scalar<T>::Type> m;
1241 double t0 = _tdomain->t0_tf().lb();
1242 m.set((*this)(t0).mid(), t0);
1243 for(const auto& s : *this)
1244 if(!s.is_gate())
1245 m.set(s.output_gate().mid(),s.t0_tf().ub());
1246 return m;
1247 }
1248
1249
1250 public:
1251
1252 using base_container = std::list<TSlice>;
1253
1257 struct iterator : public base_container::iterator
1258 {
1259 public:
1260
1261 iterator(SlicedTube& x, base_container::iterator it)
1262 : base_container::iterator(it), _x(x) { }
1263
1264 std::shared_ptr<Slice<T>> operator->()
1265 {
1266 return _x.slice(*this);
1267 }
1268
1269 Slice<T>& operator*()
1270 {
1271 return *operator->();
1272 }
1273
1274 protected:
1275
1276 SlicedTube& _x;
1277 };
1278
1282 iterator begin() { return { *this, _tdomain->begin() }; }
1283
1287 iterator end() { return { *this, _tdomain->end() }; }
1288
1292 struct reverse_iterator : public base_container::reverse_iterator
1293 {
1294 public:
1295
1296 reverse_iterator(SlicedTube& x, base_container::reverse_iterator it)
1297 : base_container::reverse_iterator(it), _x(x) { }
1298
1299 std::shared_ptr<Slice<T>> operator->()
1300 {
1301 return _x.slice(*this);
1302 }
1303
1304 Slice<T>& operator*()
1305 {
1306 return *operator->();
1307 }
1308
1309 protected:
1310
1311 SlicedTube& _x;
1312 };
1313
1317 reverse_iterator rbegin() { return { *this, _tdomain->rbegin() }; }
1318
1322 reverse_iterator rend() { return { *this, _tdomain->rend() }; }
1323
1327 struct const_iterator : public base_container::const_iterator
1328 {
1329 public:
1330
1331 const_iterator(const SlicedTube& x, base_container::const_iterator it)
1332 : base_container::const_iterator(it), _x(x) { }
1333
1334 std::shared_ptr<const Slice<T>> operator->()
1335 {
1336 return _x.slice(*this);
1337 }
1338
1339 const Slice<T>& operator*()
1340 {
1341 return *operator->();
1342 }
1343
1344 protected:
1345
1346 const SlicedTube& _x;
1347 };
1348
1352 const_iterator begin() const { return { *this, _tdomain->cbegin() }; }
1353
1357 const_iterator end() const { return { *this, _tdomain->cend() }; }
1358
1362 struct const_reverse_iterator : public base_container::const_reverse_iterator
1363 {
1364 public:
1365
1366 const_reverse_iterator(const SlicedTube& x, base_container::const_reverse_iterator it)
1367 : base_container::const_reverse_iterator(it), _x(x) { }
1368
1369 std::shared_ptr<const Slice<T>> operator->()
1370 {
1371 return _x.slice(*this);
1372 }
1373
1374 const Slice<T>& operator*()
1375 {
1376 return *operator->();
1377 }
1378
1379 protected:
1380
1381 const SlicedTube& _x;
1382 };
1383
1387 const_reverse_iterator rbegin() const { return { *this, _tdomain->crbegin() }; }
1388
1392 const_reverse_iterator rend() const { return { *this, _tdomain->crend() }; }
1393 };
1394
1395
1396 // Template deduction guide:
1397
1398 template<typename T>
1399 SlicedTube(const std::shared_ptr<TDomain>& tdomain, const AnalyticFunction<T>& f) ->
1400 SlicedTube<typename Wrapper<T>::Domain>;
1401
1402 template<typename T>
1403 SlicedTube(const std::shared_ptr<TDomain>& tdomain, const SampledTraj<T>& f) ->
1404 SlicedTube<typename Wrapper<T>::Domain>;
1405
1406 template<typename T>
1407 SlicedTube(const std::shared_ptr<TDomain>& tdomain, const AnalyticTraj<T>& f) ->
1408 SlicedTube<typename Wrapper<T>::Domain>;
1409
1410
1411 // Ctc
1412
1413 template<typename... X>
1414 inline void CtcBase<X...>::contract(SlicedTube<X>&... x) const
1415 {
1416 auto&& x0 = std::get<0>(std::forward_as_tuple(x...));
1417 for(auto it = x0.begin(); it != x0.end(); ++it)
1418 contract((x.slice(it)->codomain())...);
1419 }
1420
1421 template<typename... X>
1422 inline void CtcBase<X...>::contract_tube(SlicedTube<X>&... x) const
1423 {
1424 std::cout << "CtcInverse::contract_tube(...) is deprecated; \
1425 use CtcInverse::contract(...) with SlicedTube arguments instead" << std::endl;
1426 return contract(x...);
1427 }
1428}
1429
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:50
bool is_unbounded() const
Tests if one of the bounds of this is infinite.
Definition codac2_Interval_impl.h:236
bool is_empty() const
Tests if this is empty.
Definition codac2_Interval_impl.h:221
double ub() const
Returns the upper bound of this.
Definition codac2_Interval_impl.h:131
bool is_degenerated() const
Tests if this is degenerated, that is, in the form of .
Definition codac2_Interval_impl.h:241
bool is_subset(const Interval &x) const
Tests if this is a subset of x.
Definition codac2_Interval_impl.h:271
double lb() const
Returns the lower bound of this.
Definition codac2_Interval_impl.h:126
static Interval empty()
Provides an empty interval.
Definition codac2_Interval_impl.h:584
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:1317
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:892
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:1213
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:823
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:1282
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:346
T empty_value() const
Returns the empty codomain value associated with T.
Definition codac2_SlicedTube.h:1225
bool is_unbounded() const
Tests whether this tube is unbounded.
Definition codac2_SlicedTube.h:331
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:1322
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:315
const_reverse_iterator rend() const
Returns a constant reverse iterator past the first temporal slice.
Definition codac2_SlicedTube.h:1392
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:1387
std::pair< SlicedTube< T >, SlicedTube< T > > partial_primitives() const
Returns the primitives of the lower and upper bounds of this tube .
Definition codac2_SlicedTube_integral_impl.h:143
Interval invert(const T &y) const
Returns the interval inversion .
Definition codac2_SlicedTube.h:793
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:1287
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:1357
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:855
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:1238
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:1352
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.
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:83
SlicedTube< T > primitive() const
Returns a primitive of this tube with zero initial condition.
Definition codac2_SlicedTube.h:935
SlicedTube< T > primitive(const T &x0) const
Returns a primitive of this tube with prescribed initial condition.
Definition codac2_SlicedTube.h:963
T integral(const Interval &t) const
Returns an enclosure of the integrals of this tube from to .
Definition codac2_SlicedTube_integral_impl.h:20
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:837
Interval invert(const T &y, const SlicedTube< T > &v, const Interval &t) const
Returns the optimal interval inversion .
Definition codac2_SlicedTube.h:873
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:910
Interval invert(const T &y, const Interval &t) const
Returns the interval inversion .
Definition codac2_SlicedTube.h:808
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:1328
Constant reverse iterator over the slices of this tube.
Definition codac2_SlicedTube.h:1363
Mutable iterator over the slices of this tube.
Definition codac2_SlicedTube.h:1258
Mutable reverse iterator over the slices of this tube.
Definition codac2_SlicedTube.h:1293