30 requires IsCtcBaseOrPtr<C,Y>
31 CtcInverse_(
const AnalyticFunction<
typename ValueType<Y>::Type>& f,
const C& ctc_y,
bool with_centered_form =
true,
bool is_not_in =
false)
32 : _f(f), _ctc_y(ctc_y), _with_centered_form(with_centered_form), _is_not_in(is_not_in)
34 assert_release([&]() {
return f.output_size() == size_of(ctc_y); }()
35 &&
"CtcInverse_: invalid dimension of image argument ('y' or 'ctc_y')");
38 CtcInverse_(
const AnalyticFunction<
typename ValueType<Y>::Type>& f,
const Y& y,
bool with_centered_form =
true,
bool is_not_in =
false)
39 : CtcInverse_(f, CtcWrapper<Y>(y), with_centered_form, is_not_in)
47 template<
typename... X>
48 void contract(X&... x)
const
50 return contract_(*_ctc_y.front(), x...);
53 template<
typename... X>
54 void contract_(
const Y& y, X&... x)
const
56 return contract_(CtcWrapper<Y>(y), x...);
59 template<
typename... X>
60 void contract_(
const CtcBase<Y>& ctc_y, X&... x)
const
64 _f.fill_from_args(v, x...);
69 _f.expr()->fwd_eval(v, _f.args().total_size(), !_with_centered_form);
70 auto& val_expr = _f.expr()->value(v);
72 if(_is_not_in && !val_expr.def_domain)
80 ctc_y.contract(val_expr.a);
87 if(_with_centered_form && val_expr.def_domain && !val_expr.da.is_unbounded() && val_expr.da.size() != 0)
91 using X0 = std::tuple_element_t<0, std::tuple<X...>>;
93 if constexpr(
sizeof...(X) == 1 && std::is_same_v<X0,IntervalVector>)
95 X0& x_ = std::get<0>(std::tie(x...));
96 X0 x_mid = X0(x_.mid());
98 assert(val_expr.a.size() == val_expr.m.size());
99 IntervalVector fm { val_expr.a - val_expr.m };
101 if constexpr(std::is_same_v<Y,IntervalMatrix>)
103 std::cout <<
"CtcInverse_: matrices expressions not (yet) supported with centered form" << std::endl;
108 IntervalVector p = x_ - x_mid;
109 MulOp::bwd(fm, val_expr.da, p);
121 _f.expr()->bwd_eval(v);
122 _f.intersect_from_args(v, x...);
125 const AnalyticFunction<typename ValueType<Y>::Type>& function()
const
132 const AnalyticFunction<typename ValueType<Y>::Type> _f;
133 const Collection<CtcBase<Y>> _ctc_y;
134 bool _with_centered_form;
135 bool _is_not_in =
false;
138 template<
typename Y,
typename X=IntervalVector>
139 class CtcInverse :
public Ctc<CtcInverse<Y,X>,X>,
public CtcInverse_<Y>
143 CtcInverse(
const AnalyticFunction<
typename ValueType<Y>::Type>& f,
const typename Wrapper<Y>::Domain& y,
bool with_centered_form =
true,
bool is_not_in =
false)
144 : Ctc<CtcInverse<Y,X>,X>(f.args()[0]->size() ),
145 CtcInverse_<Y>(f, y, with_centered_form,is_not_in)
147 assert_release(f.args().size() == 1 &&
"f must have only one arg");
151 requires IsCtcBaseOrPtr<C,Y>
152 CtcInverse(
const AnalyticFunction<
typename ValueType<Y>::Type>& f,
const C& ctc_y,
bool with_centered_form =
true,
bool is_not_in =
false)
153 : Ctc<CtcInverse<Y,X>,X>(f.args()[0]->size() ),
154 CtcInverse_<Y>(f, ctc_y, with_centered_form,is_not_in)
156 assert_release(f.args().size() == 1 &&
"f must have only one arg");
159 void contract(X& x)
const
161 CtcInverse_<Y>::contract(x);
169 CtcInverse(
const AnalyticFunction<ScalarType>&, std::initializer_list<double>,
bool =
true,
bool =
false) ->
170 CtcInverse<Interval,IntervalVector>;
173 CtcInverse(
const AnalyticFunction<ScalarType>&, std::initializer_list<Y>,
bool =
true,
bool =
false) ->
174 CtcInverse<Interval,IntervalVector>;
176 CtcInverse(
const AnalyticFunction<VectorType>&,
const Interval&,
bool =
true,
bool =
false) ->
177 CtcInverse<Interval,IntervalVector>;
180 requires IsCtcBaseOrPtr<C,Interval>
181 CtcInverse(
const AnalyticFunction<ScalarType>&,
const C&,
bool =
true,
bool =
false) ->
182 CtcInverse<Interval,IntervalVector>;
186 CtcInverse(
const AnalyticFunction<VectorType>&, std::initializer_list<double>,
bool =
true,
bool =
false) ->
187 CtcInverse<IntervalVector,IntervalVector>;
189 CtcInverse(
const AnalyticFunction<VectorType>&, std::initializer_list<std::initializer_list<double>>,
bool =
true,
bool =
false) ->
190 CtcInverse<IntervalVector,IntervalVector>;
192 CtcInverse(
const AnalyticFunction<VectorType>&,
const Vector&,
bool =
true,
bool =
false) ->
193 CtcInverse<IntervalVector,IntervalVector>;
195 CtcInverse(
const AnalyticFunction<VectorType>&,
const IntervalVector&,
bool =
true,
bool =
false) ->
196 CtcInverse<IntervalVector,IntervalVector>;
198 template<
typename OtherDerived>
199 requires (OtherDerived::RowsAtCompileTime == -1 && OtherDerived::ColsAtCompileTime == 1)
200 CtcInverse(
const AnalyticFunction<VectorType>&,
const Eigen::MatrixBase<OtherDerived>&,
bool =
true,
bool =
false) ->
201 CtcInverse<IntervalVector,IntervalVector>;
204 requires IsCtcBaseOrPtr<C,IntervalVector>
205 CtcInverse(
const AnalyticFunction<VectorType>&,
const C&,
bool =
true,
bool =
false) ->
206 CtcInverse<IntervalVector,IntervalVector>;
210 CtcInverse(
const AnalyticFunction<MatrixType>&, std::initializer_list<std::initializer_list<double>>,
bool =
true,
bool =
false) ->
211 CtcInverse<IntervalMatrix,IntervalVector>;
213 CtcInverse(
const AnalyticFunction<MatrixType>&, std::initializer_list<std::initializer_list<std::initializer_list<double>>>,
bool =
true,
bool =
false) ->
214 CtcInverse<IntervalMatrix,IntervalVector>;
216 template<
typename OtherDerived>
217 requires (OtherDerived::RowsAtCompileTime == -1 && OtherDerived::ColsAtCompileTime == -1)
218 CtcInverse(
const AnalyticFunction<VectorType>&,
const Eigen::MatrixBase<OtherDerived>&,
bool =
true,
bool =
false) ->
219 CtcInverse<IntervalMatrix,IntervalVector>;
222 requires IsCtcBaseOrPtr<C,IntervalMatrix>
223 CtcInverse(
const AnalyticFunction<MatrixType>&,
const C&,
bool =
true,
bool =
false) ->
224 CtcInverse<IntervalMatrix,IntervalVector>;
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:62