24 template<
typename Y,
typename... X>
25 requires (
sizeof...(X) > 0)
26 class CtcInverse : public Ctc<CtcInverse<Y,X...>,X...>
31 requires IsCtcBaseOrPtr<C,Y>
32 CtcInverse(
const AnalyticFunction<
typename ExprType<Y>::Type>& f,
const C& ctc_y,
bool with_centered_form =
true,
bool is_not_in =
false)
33 : 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)
35 assert_release([&]() {
return f.output_size() == size_of(ctc_y); }()
36 &&
"CtcInverse: invalid dimension of image argument ('y' or 'ctc_y')");
39 CtcInverse(
const AnalyticFunction<
typename ExprType<Y>::Type>& f,
const Y& y,
bool with_centered_form =
true,
bool is_not_in =
false)
40 : CtcInverse(f, CtcWrapper<Y>(y), with_centered_form, is_not_in)
43 void contract(X&... x)
const
45 return contract_(*_ctc_y.front(), x...);
48 void contract_(
const Y& y, X&... x)
const
50 return contract_(CtcWrapper<Y>(y), x...);
53 void contract_(
const CtcBase<Y>& ctc_y, X&... x)
const
57 _f.fill_from_args(v, x...);
62 _f.expr()->fwd_eval(v, _f.args().total_size(), !_with_centered_form);
63 auto& val_expr = _f.expr()->value(v);
65 if(_is_not_in && !val_expr.def_domain)
73 ctc_y.contract(val_expr.a);
80 if(_with_centered_form && val_expr.def_domain && !val_expr.da.is_unbounded() && val_expr.da.size() != 0)
84 using X0 = std::tuple_element_t<0, std::tuple<X...>>;
86 if constexpr(
sizeof...(X) == 1 && std::is_same_v<X0,IntervalVector>)
88 X0& x_ = std::get<0>(std::tie(x...));
89 X0 x_mid = X0(x_.mid());
91 assert(val_expr.a.size() == val_expr.m.size());
92 IntervalVector fm { val_expr.a - val_expr.m };
94 if constexpr(std::is_same_v<Y,IntervalMatrix>)
96 std::cout <<
"CtcInverse: matrices expressions not (yet) supported with centered form" << std::endl;
101 IntervalVector p = x_ - x_mid;
102 MulOp::bwd(fm, val_expr.da, p);
114 _f.expr()->bwd_eval(v);
115 _f.intersect_from_args(v, x...);
118 const AnalyticFunction<typename ExprType<Y>::Type>& function()
const
125 const AnalyticFunction<typename ExprType<Y>::Type> _f;
126 const Collection<CtcBase<Y>> _ctc_y;
127 bool _with_centered_form;
128 bool _is_not_in =
false;
136 CtcInverse(
const AnalyticFunction<ScalarType>&, std::initializer_list<double>,
bool =
true,
bool =
false) ->
137 CtcInverse<Interval,IntervalVector>;
140 CtcInverse(
const AnalyticFunction<ScalarType>&, std::initializer_list<Y>,
bool =
true,
bool =
false) ->
141 CtcInverse<Interval,IntervalVector>;
143 CtcInverse(
const AnalyticFunction<VectorType>&,
const Interval&,
bool =
true,
bool =
false) ->
144 CtcInverse<Interval,IntervalVector>;
147 requires IsCtcBaseOrPtr<C,Interval>
148 CtcInverse(
const AnalyticFunction<ScalarType>&,
const C&,
bool =
true,
bool =
false) ->
149 CtcInverse<Interval,IntervalVector>;
153 CtcInverse(
const AnalyticFunction<VectorType>&, std::initializer_list<double>,
bool =
true,
bool =
false) ->
154 CtcInverse<IntervalVector,IntervalVector>;
156 CtcInverse(
const AnalyticFunction<VectorType>&, std::initializer_list<std::initializer_list<double>>,
bool =
true,
bool =
false) ->
157 CtcInverse<IntervalVector,IntervalVector>;
159 CtcInverse(
const AnalyticFunction<VectorType>&,
const Vector&,
bool =
true,
bool =
false) ->
160 CtcInverse<IntervalVector,IntervalVector>;
162 CtcInverse(
const AnalyticFunction<VectorType>&,
const IntervalVector&,
bool =
true,
bool =
false) ->
163 CtcInverse<IntervalVector,IntervalVector>;
165 template<
typename OtherDerived>
166 requires (OtherDerived::RowsAtCompileTime == -1 && OtherDerived::ColsAtCompileTime == 1)
167 CtcInverse(
const AnalyticFunction<VectorType>&,
const Eigen::MatrixBase<OtherDerived>&,
bool =
true,
bool =
false) ->
168 CtcInverse<IntervalVector,IntervalVector>;
171 requires IsCtcBaseOrPtr<C,IntervalVector>
172 CtcInverse(
const AnalyticFunction<VectorType>&,
const C&,
bool =
true,
bool =
false) ->
173 CtcInverse<IntervalVector,IntervalVector>;
177 CtcInverse(
const AnalyticFunction<MatrixType>&, std::initializer_list<std::initializer_list<double>>,
bool =
true,
bool =
false) ->
178 CtcInverse<IntervalMatrix,IntervalVector>;
180 CtcInverse(
const AnalyticFunction<MatrixType>&, std::initializer_list<std::initializer_list<std::initializer_list<double>>>,
bool =
true,
bool =
false) ->
181 CtcInverse<IntervalMatrix,IntervalVector>;
183 template<
typename OtherDerived>
184 requires (OtherDerived::RowsAtCompileTime == -1 && OtherDerived::ColsAtCompileTime == -1)
185 CtcInverse(
const AnalyticFunction<VectorType>&,
const Eigen::MatrixBase<OtherDerived>&,
bool =
true,
bool =
false) ->
186 CtcInverse<IntervalMatrix,IntervalVector>;
189 requires IsCtcBaseOrPtr<C,IntervalMatrix>
190 CtcInverse(
const AnalyticFunction<MatrixType>&,
const C&,
bool =
true,
bool =
false) ->
191 CtcInverse<IntervalMatrix,IntervalVector>;
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:62