30 CtcDeriv(
const TimePropag& time_propag = TimePropag::FWD_BWD,
bool fast_mode =
true);
32 void restrict_tdomain(
const Interval& tdomain)
38 inline void contract(Slice<T>& x,
const Slice<T>& v,
const std::vector<Index>& ctc_indices = {})
const
39 requires std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>
41 assert(x.size() == v.size());
42 assert(x.t0_tf() == v.t0_tf());
44 T input = x.input_gate();
45 T output = x.output_gate();
46 T envelope = x.codomain();
48 if constexpr(std::is_same_v<T,Interval>)
49 contract(x.t0_tf(), envelope, input, output, v.codomain(), _time_propag, _fast_mode);
51 else if constexpr(std::is_same_v<T,IntervalVector>)
53 std::vector<Index> ctc_indices_(ctc_indices);
54 if(ctc_indices_.empty())
57 ctc_indices_ = std::vector<Index>(x.size());
58 std::iota(ctc_indices_.begin(), ctc_indices_.end(), 0);
61 for(
auto i : ctc_indices_)
62 contract(x.t0_tf(), envelope[i], input[i], output[i], v.codomain()[i], _time_propag, _fast_mode);
65 auto x_next = x.next_slice();
66 if(x_next && x_next->is_gate())
67 x_next->set(output,
false);
69 auto x_prev = x.prev_slice();
70 if(x_prev && x_prev->is_gate())
71 x_prev->set(input,
false);
73 x.set(envelope,
false);
77 inline void contract(SlicedTube<T>& x,
const SlicedTube<T>& v,
const std::vector<Index>& ctc_indices = {})
const
78 requires std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>
81 Interval t = x.tdomain()->t0_tf() & _tdomain;
82 if(t.is_empty() || t.is_degenerated())
87 if(t.lb() > x.tdomain()->t0_tf().lb())
88 x.tdomain()->sample(t.lb(),
false);
89 if(t.ub() < x.tdomain()->t0_tf().ub())
90 x.tdomain()->sample(t.ub(),
false);
94 std::vector<std::shared_ptr<Slice<T>>> sx;
95 std::vector<std::shared_ptr<const Slice<T>>> sv;
96 for(
auto it = x.tdomain()->begin(); it != x.tdomain()->end(); ++it)
97 if(!it->is_gate() && it->is_subset(t))
99 sx.push_back(x.slice(it));
100 sv.push_back(v.slice(it));
106 std::vector<T> gates;
107 gates.reserve(sx.size()+1);
108 gates.push_back(sx.front()->input_gate());
109 for(
const auto& s : sx)
110 gates.push_back(s->output_gate());
112 auto contract_slice = [&](std::size_t i)
114 T envelope = sx[i]->codomain();
116 if constexpr(std::is_same_v<T,Interval>)
117 contract(sx[i]->t0_tf(), envelope, gates[i], gates[i+1],
118 sv[i]->codomain(), _time_propag, _fast_mode);
120 else if constexpr(std::is_same_v<T,IntervalVector>)
122 std::vector<Index> ctc_indices_(ctc_indices);
123 if(ctc_indices_.empty())
125 ctc_indices_.resize(sx[i]->size());
126 std::iota(ctc_indices_.begin(), ctc_indices_.end(), 0);
129 for(
auto j : ctc_indices_)
130 contract(sx[i]->t0_tf(), envelope[j], gates[i][j], gates[i+1][j],
131 sv[i]->codomain()[j], _time_propag, _fast_mode);
134 sx[i]->set(envelope,
false);
137 if((_time_propag & TimePropag::FWD) == TimePropag::FWD)
138 for(std::size_t i = 0 ; i < sx.size() ; i++)
141 if((_time_propag & TimePropag::BWD) == TimePropag::BWD)
142 for(std::size_t i = sx.size() ; i-- > 0 ; )
147 for(std::size_t i = 0 ; i < sx.size() ; i++)
149 auto prev = sx[i]->prev_slice();
150 if(prev && prev->is_gate())
151 prev->set(gates[i],
false);
153 auto next = sx[i]->next_slice();
154 if(next && next->is_gate())
155 next->set(gates[i+1],
false);
159 static ConvexPolygon polygon_slice(
160 const Interval& t,
const Interval& envelope,
161 const Interval& input,
const Interval& proj_input,
162 const Interval& output,
const Interval& proj_output,
167 static void contract(
168 const Interval& t, Interval& envelope,
169 Interval& input, Interval& output,
170 const Interval& v,
const TimePropag& time_propag,
bool fast_mode);
173 const bool _fast_mode;
Codomain of a sliced tube over one temporal slice.
Definition codac2_Slice.h:42
Tube represented over a sliced temporal domain.
Definition codac2_SlicedTube.h:38
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.
Definition codac2_OctaSym.h:21
TimePropag
Enumeration specifying the temporal propagation way (forward or backward in time).
Definition codac2_TimePropag.h:23