29 requires IsCtcBaseOrPtr<C,Y>
30 CtcInverse_(
const AnalyticFunction<
typename ValueType<Y>::Type>& f,
const C& ctc_y,
bool with_centered_form =
true,
bool is_not_in =
false)
31 : _f(f), _ctc_y(ctc_y), _with_centered_form(with_centered_form), _is_not_in(is_not_in)
33 assert_release([&]() {
return f.output_size() == size_of(ctc_y); }()
34 &&
"CtcInverse_: invalid dimension of image argument ('y' or 'ctc_y')");
37 CtcInverse_(
const AnalyticFunction<
typename ValueType<Y>::Type>& f,
const Y& y,
bool with_centered_form =
true,
bool is_not_in =
false)
38 : CtcInverse_(f, CtcWrapper<Y>(y), with_centered_form, is_not_in)
46 template<
typename... X>
47 void contract(X&... x)
const
49 return contract_(_ctc_y.front(), x...);
52 template<
typename... X>
53 void contract_(
const Y& y, X&... x)
const
55 return contract_(CtcWrapper<Y>(y), x...);
58 template<
typename... X>
59 void contract_(
const CtcBase<Y>& ctc_y, X&... x)
const
63 _f.fill_from_args(v, x...);
68 _f.expr()->fwd_eval(v, _f.args().total_size(), !_with_centered_form);
69 auto& val_expr = _f.expr()->value(v);
71 if(_is_not_in && !val_expr.def_domain)
79 ctc_y.contract(val_expr.a);
86 if(_with_centered_form && val_expr.def_domain && !val_expr.da.is_unbounded() && val_expr.da.size() != 0)
90 using X0 = std::tuple_element_t<0, std::tuple<X...>>;
92 if constexpr(
sizeof...(X) == 1 && std::is_same_v<X0,IntervalVector>)
94 X0& x_ = std::get<0>(std::tie(x...));
95 X0 x_mid = X0(x_.mid());
97 assert(val_expr.a.size() == val_expr.m.size());
98 IntervalVector fm { val_expr.a - val_expr.m };
100 if constexpr(std::is_same_v<Y,IntervalMatrix>)
102 std::cout <<
"CtcInverse_: matrices expressions not (yet) supported with centered form" << std::endl;
107 IntervalVector p = x_ - x_mid;
108 MulOp::bwd(fm, val_expr.da, p);
120 _f.expr()->bwd_eval(v);
121 _f.intersect_from_args(v, x...);
124 const AnalyticFunction<typename ValueType<Y>::Type>& function()
const
131 const AnalyticFunction<typename ValueType<Y>::Type> _f;
132 const Collection<CtcBase<Y>> _ctc_y;
133 bool _with_centered_form;
134 bool _is_not_in =
false;
137 template<
typename Y,
typename X=IntervalVector>
138 class CtcInverse :
public Ctc<CtcInverse<Y,X>,X>,
public CtcInverse_<Y>
142 CtcInverse(
const AnalyticFunction<
typename ValueType<Y>::Type>& f,
const Y& y,
bool with_centered_form =
true,
bool is_not_in =
false)
143 : Ctc<CtcInverse<Y,X>,X>(f.args()[0]->size() ),
144 CtcInverse_<Y>(f, y, with_centered_form,is_not_in)
146 assert_release(f.args().size() == 1 &&
"f must have only one arg");
150 requires IsCtcBaseOrPtr<C,Y>
151 CtcInverse(
const AnalyticFunction<
typename ValueType<Y>::Type>& f,
const C& ctc_y,
bool with_centered_form =
true,
bool is_not_in =
false)
152 : Ctc<CtcInverse<Y,X>,X>(f.args()[0]->size() ),
153 CtcInverse_<Y>(f, ctc_y, with_centered_form,is_not_in)
155 assert_release(f.args().size() == 1 &&
"f must have only one arg");
158 void contract(X& x)
const
160 CtcInverse_<Y>::contract(x);
168 CtcInverse(
const AnalyticFunction<ScalarType>&, std::initializer_list<double>,
bool with_centered_form =
true,
bool is_not_in =
false) ->
169 CtcInverse<Interval,IntervalVector>;
172 CtcInverse(
const AnalyticFunction<ScalarType>&, std::initializer_list<Y>,
bool with_centered_form =
true,
bool is_not_in =
false) ->
173 CtcInverse<Interval,IntervalVector>;
176 requires IsCtcBaseOrPtr<C,Interval>
177 CtcInverse(
const AnalyticFunction<ScalarType>&,
const C&,
bool with_centered_form =
true,
bool is_not_in =
false) ->
178 CtcInverse<Interval,IntervalVector>;
182 CtcInverse(
const AnalyticFunction<VectorType>&, std::initializer_list<double>,
bool with_centered_form =
true,
bool is_not_in =
false) ->
183 CtcInverse<IntervalVector,IntervalVector>;
185 CtcInverse(
const AnalyticFunction<VectorType>&, std::initializer_list<std::initializer_list<double>>,
bool with_centered_form =
true,
bool is_not_in =
false) ->
186 CtcInverse<IntervalVector,IntervalVector>;
189 requires IsCtcBaseOrPtr<C,IntervalVector>
190 CtcInverse(
const AnalyticFunction<VectorType>&,
const C&,
bool with_centered_form =
true,
bool is_not_in =
false) ->
191 CtcInverse<IntervalVector,IntervalVector>;
195 CtcInverse(
const AnalyticFunction<MatrixType>&, std::initializer_list<std::initializer_list<double>>,
bool with_centered_form =
true,
bool is_not_in =
false) ->
196 CtcInverse<IntervalMatrix,IntervalVector>;
198 CtcInverse(
const AnalyticFunction<MatrixType>&, std::initializer_list<std::initializer_list<std::initializer_list<double>>>,
bool with_centered_form =
true,
bool is_not_in =
false) ->
199 CtcInverse<IntervalMatrix,IntervalVector>;
202 requires IsCtcBaseOrPtr<C,IntervalMatrix>
203 CtcInverse(
const AnalyticFunction<MatrixType>&,
const C&,
bool with_centered_form =
true,
bool is_not_in =
false) ->
204 CtcInverse<IntervalMatrix,IntervalVector>;