19 static inline std::string str(
const X1& x1)
21 return "sym(" + x1->str() +
")";
25 static inline std::pair<Index,Index> output_shape([[maybe_unused]]
const X1& s1)
27 return s1->output_shape();
32 assert((Index)s.size() == x1.size());
36 static inline VectorType fwd_natural(
const OctaSym& s,
const VectorType& x1)
38 assert((Index)s.size() == x1.m.size());
45 static inline VectorType fwd_centered(
const OctaSym& s,
const VectorType& x1)
47 assert((Index)s.size() == x1.m.size());
50 for(
size_t i = 0 ; i < s.size() ; i++)
51 da.row(i) =
sign(s[i])*x1.da.row(std::abs(s[i])-1);
63 assert((Index)s.size() == y.size() && (Index)s.size() == x1.size());
70 class AnalyticOperationExpr<OctaSymOp,VectorType,VectorType>
71 :
public AnalyticExpr<VectorType>,
public OperationExprBase<AnalyticExpr<VectorType>>
75 AnalyticOperationExpr(
const OctaSym& s,
const VectorExpr& x1)
79 std::shared_ptr<ExprBase> copy()
const
81 return std::make_shared<AnalyticOperationExpr<OctaSymOp,VectorType,VectorType>>(*this);
84 void replace_arg(
const ExprID& old_arg_id,
const std::shared_ptr<ExprBase>& new_expr)
89 VectorType fwd_eval(ValuesMap& v, Index total_input_size,
bool natural_eval)
const
92 return AnalyticExpr<VectorType>::init_value(
93 v, OctaSymOp::fwd_natural(_s, std::get<0>(this->
_x)->fwd_eval(v, total_input_size, natural_eval)));
95 return AnalyticExpr<VectorType>::init_value(
96 v, OctaSymOp::fwd_centered(_s, std::get<0>(this->
_x)->fwd_eval(v, total_input_size, natural_eval)));
99 void bwd_eval(ValuesMap& v)
const
101 OctaSymOp::bwd(_s, AnalyticExpr<VectorType>::value(v).a, std::get<0>(this->
_x)->value(v).a);
102 std::get<0>(this->
_x)->bwd_eval(v);
105 std::pair<Index,Index> output_shape()
const {
106 return { _s.size(), 1 };
109 virtual bool belongs_to_args_list(
const FunctionArgsList& args)
const
111 return std::get<0>(this->
_x)->belongs_to_args_list(args);
114 std::string str(
bool in_parentheses =
false)
const
117 return in_parentheses ?
"(" + s +
")" : s;
120 virtual bool is_str_leaf()
const
A base class for expressions representing operations with multiple operands.
Definition codac2_ExprBase.h:164
OperationExprBase(std::shared_ptr< X >... x)
Definition codac2_ExprBase.h:176
std::tuple< std::shared_ptr< X >... > _x
Definition codac2_ExprBase.h:258
Definition codac2_OctaSym.h:21
Eigen::Matrix< Interval,-1, 1 > IntervalVector
Alias for a dynamic-size column vector of intervals.
Definition codac2_IntervalVector.h:25
Interval sign(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:279