24 template<
typename Y,
typename... X>
25 requires (
sizeof...(X) > 0)
26 class CtcInverse : public Ctc<CtcInverse<Y,X...>,X...>
30 using Ctc<CtcInverse<Y,X...>,X...>::contract;
33 requires IsCtcBaseOrPtr<C,Y>
34 CtcInverse(
const AnalyticFunction<
typename ExprType<Y>::Type>& f,
const C& ctc_y,
bool with_centered_form =
true,
bool is_not_in =
false)
35 : Ctc<CtcInverse<Y,X...>,X...>(f.args()[0]->size()), _f(f), _ctc_y(ctc_y), _with_centered_form(with_centered_form), _is_not_in(is_not_in)
37 assert_release([&]() {
return f.output_size() == size_of(ctc_y); }()
38 &&
"CtcInverse: invalid dimension of image argument ('y' or 'ctc_y')");
41 CtcInverse(
const AnalyticFunction<
typename ExprType<Y>::Type>& f,
const Y& y,
bool with_centered_form =
true,
bool is_not_in =
false)
42 : CtcInverse(f, CtcWrapper<Y>(y), with_centered_form, is_not_in)
45 void contract(X&... x)
const
47 return contract_(*_ctc_y.front(), x...);
50 void contract_(
const Y& y, X&... x)
const
52 return contract_(CtcWrapper<Y>(y), x...);
55 void contract_(
const CtcBase<Y>& ctc_y, X&... x)
const
59 _f.fill_from_args(v, x...);
64 _f.expr()->fwd_eval(v, _f.args().total_size(), !_with_centered_form);
65 auto& val_expr = _f.expr()->value(v);
67 if(_is_not_in && !val_expr.def_domain)
75 ctc_y.contract(val_expr.a);
82 if(_with_centered_form && val_expr.def_domain && !val_expr.da.is_unbounded() && val_expr.da.size() != 0)
86 using X0 = std::tuple_element_t<0, std::tuple<X...>>;
88 if constexpr(
sizeof...(X) == 1 && std::is_same_v<X0,IntervalVector>)
90 X0& x_ = std::get<0>(std::tie(x...));
91 X0 x_mid = X0(x_.mid());
93 assert(val_expr.a.size() == val_expr.m.size());
94 IntervalVector fm { val_expr.a - val_expr.m };
96 if constexpr(std::is_same_v<Y,IntervalMatrix>)
98 std::cout <<
"CtcInverse: matrices expressions not (yet) supported with centered form" << std::endl;
103 IntervalVector p = x_ - x_mid;
104 MulOp::bwd(fm, val_expr.da, p);
116 _f.expr()->bwd_eval(v);
117 _f.intersect_from_args(v, x...);
120 const AnalyticFunction<typename ExprType<Y>::Type>& function()
const
127 const AnalyticFunction<typename ExprType<Y>::Type> _f;
128 const Collection<CtcBase<Y>> _ctc_y;
129 bool _with_centered_form;
130 bool _is_not_in =
false;
138 CtcInverse(
const AnalyticFunction<ScalarType>&, std::initializer_list<double>,
bool =
true,
bool =
false) ->
139 CtcInverse<Interval,IntervalVector>;
142 CtcInverse(
const AnalyticFunction<ScalarType>&, std::initializer_list<Y>,
bool =
true,
bool =
false) ->
143 CtcInverse<Interval,IntervalVector>;
145 CtcInverse(
const AnalyticFunction<VectorType>&,
const Interval&,
bool =
true,
bool =
false) ->
146 CtcInverse<Interval,IntervalVector>;
149 requires IsCtcBaseOrPtr<C,Interval>
150 CtcInverse(
const AnalyticFunction<ScalarType>&,
const C&,
bool =
true,
bool =
false) ->
151 CtcInverse<Interval,IntervalVector>;
155 CtcInverse(
const AnalyticFunction<VectorType>&, std::initializer_list<double>,
bool =
true,
bool =
false) ->
156 CtcInverse<IntervalVector,IntervalVector>;
158 CtcInverse(
const AnalyticFunction<VectorType>&, std::initializer_list<std::initializer_list<double>>,
bool =
true,
bool =
false) ->
159 CtcInverse<IntervalVector,IntervalVector>;
161 CtcInverse(
const AnalyticFunction<VectorType>&,
const Vector&,
bool =
true,
bool =
false) ->
162 CtcInverse<IntervalVector,IntervalVector>;
164 CtcInverse(
const AnalyticFunction<VectorType>&,
const IntervalVector&,
bool =
true,
bool =
false) ->
165 CtcInverse<IntervalVector,IntervalVector>;
167 template<
typename OtherDerived>
168 requires (OtherDerived::RowsAtCompileTime == -1 && OtherDerived::ColsAtCompileTime == 1)
169 CtcInverse(
const AnalyticFunction<VectorType>&,
const Eigen::MatrixBase<OtherDerived>&,
bool =
true,
bool =
false) ->
170 CtcInverse<IntervalVector,IntervalVector>;
173 requires IsCtcBaseOrPtr<C,IntervalVector>
174 CtcInverse(
const AnalyticFunction<VectorType>&,
const C&,
bool =
true,
bool =
false) ->
175 CtcInverse<IntervalVector,IntervalVector>;
179 CtcInverse(
const AnalyticFunction<MatrixType>&, std::initializer_list<std::initializer_list<double>>,
bool =
true,
bool =
false) ->
180 CtcInverse<IntervalMatrix,IntervalVector>;
182 CtcInverse(
const AnalyticFunction<MatrixType>&, std::initializer_list<std::initializer_list<std::initializer_list<double>>>,
bool =
true,
bool =
false) ->
183 CtcInverse<IntervalMatrix,IntervalVector>;
185 template<
typename OtherDerived>
186 requires (OtherDerived::RowsAtCompileTime == -1 && OtherDerived::ColsAtCompileTime == -1)
187 CtcInverse(
const AnalyticFunction<VectorType>&,
const Eigen::MatrixBase<OtherDerived>&,
bool =
true,
bool =
false) ->
188 CtcInverse<IntervalMatrix,IntervalVector>;
191 requires IsCtcBaseOrPtr<C,IntervalMatrix>
192 CtcInverse(
const AnalyticFunction<MatrixType>&,
const C&,
bool =
true,
bool =
false) ->
193 CtcInverse<IntervalMatrix,IntervalVector>;
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:49