25 SetFunction(
const FunctionArgsList&
args,
const std::shared_ptr<SetExpr>& y)
28 assert_release(y->belongs_to_args_list(this->args()) &&
29 "Invalid arguments: variable not present in input arguments");
32 SetFunction(
const SetFunction& f)
36 template<
typename... Args>
37 auto create_ctc(
const Args&... x)
39 std::vector<std::shared_ptr<CtcBase<IntervalVector>>> ref_x(
sizeof...(Args));
41 ((ref_x[i++] = create_arg_ctc_copy(x)), ...);
42 assert_release(
args().size() == ref_x.size() &&
43 "Invalid arguments: wrong number of input arguments");
44 return this->
expr()->create_ctc(
args(), ref_x);
47 template<
typename... Args>
48 auto create_sep(
const Args&... x)
50 std::vector<std::shared_ptr<SepBase>> ref_x(
sizeof...(Args));
52 ((ref_x[i++] = create_arg_sep_copy(x)), ...);
53 assert_release(
args().size() == ref_x.size() &&
54 "Invalid arguments: wrong number of input arguments");
55 return this->
expr()->create_sep(
args(), ref_x);
58 template<
typename... X>
59 std::shared_ptr<SetExpr> operator()(
const X&... x)
const
61 auto expr_copy =
expr()->copy();
63 (expr_copy->replace_arg(
_args[i++]->unique_id(), this->__get_copy(x)), ...);
64 assert_release(i == this->
args().size() &&
65 "Invalid arguments: wrong number of input arguments");
66 return std::dynamic_pointer_cast<SetExpr>(expr_copy);
69 friend std::ostream& operator<<(std::ostream& os,
const SetFunction& f)
79 std::shared_ptr<CtcBase<IntervalVector>> create_arg_ctc_copy(
const A& x)
81 if constexpr(std::is_base_of_v<Domain,A>)
87 else if constexpr(std::is_base_of_v<CtcBase<IntervalVector>,A>)
92 assert_release(
false &&
"Invalid argument: unknown input type");
98 std::shared_ptr<SepBase> create_arg_sep_copy(
const A& x)
100 if constexpr(std::is_base_of_v<Domain,A>)
106 else if constexpr(std::is_base_of_v<SepBase,A>)
111 assert_release(
false &&
"Invalid argument: unknown input type");
116 std::shared_ptr<SetExpr> __get_copy(std::shared_ptr<SetExpr> x)
const
118 return std::dynamic_pointer_cast<SetExpr>(x->copy());
122 std::shared_ptr<SetExpr> __get_copy(
const A& x)
const
124 if constexpr(std::is_base_of_v<VarBase,A>)
125 return std::dynamic_pointer_cast<A>(x.copy());
A base class for functions (either analytic functions, or set functions).
Definition codac2_FunctionBase.h:41
const FunctionArgsList & args() const
Definition codac2_FunctionBase.h:93
const FunctionArgsList _args
Definition codac2_FunctionBase.h:208
FunctionBase(const std::vector< std::reference_wrapper< VarBase > > &args, const std::shared_ptr< SetExpr > &y)
Definition codac2_FunctionBase.h:52
const std::shared_ptr< SetExpr > & expr() const
Definition codac2_FunctionBase.h:103