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>
80 assert_release(TDomain::are_same(x.tdomain(), v.tdomain()));
81 Interval t = x.tdomain()->t0_tf() & _tdomain;
82 auto it_beg = x.tdomain()->sample(t.lb(),
true);
83 auto it_end = x.tdomain()->sample(t.ub(),
true);
85 if((_time_propag & TimePropag::FWD) == TimePropag::FWD)
87 for(
auto it = it_beg ; it != std::next(it_end) ; it++)
89 auto sx = x.slice(it);
91 this->contract(*sx, *v.slice(it), ctc_indices);
95 if((_time_propag & TimePropag::BWD) == TimePropag::BWD)
97 for(
auto it = it_end ; it != std::prev(it_beg) ; it--)
99 auto sx = x.slice(it);
101 this->contract(*sx, *v.slice(it), ctc_indices);
106 static ConvexPolygon polygon_slice(
107 const Interval& t,
const Interval& envelope,
108 const Interval& input,
const Interval& proj_input,
109 const Interval& output,
const Interval& proj_output,
114 static void contract(
115 const Interval& t, Interval& envelope,
116 Interval& input, Interval& output,
117 const Interval& v,
const TimePropag& time_propag,
bool fast_mode);
120 const bool _fast_mode;
Definition codac2_OctaSym.h:21
TimePropag
Enumeration specifying the temporal propagation way (forward or backward in time).
Definition codac2_TimePropag.h:23