20 template<
typename X1,
typename X2>
21 static std::string str(
const X1& x1,
const X2& x2)
23 return "max(" + x1->str() +
"," + x2->str() +
")";
26 template<
typename X1,
typename X2>
27 static std::pair<Index,Index> output_shape([[maybe_unused]]
const X1& s1, [[maybe_unused]]
const X2& s2)
32 static Interval fwd(
const Interval& x1,
const Interval& x2);
33 static ScalarType fwd_natural(
const ScalarType& x1,
const ScalarType& x2);
34 static ScalarType fwd_centered(
const ScalarType& x1,
const ScalarType& x2);
35 static void bwd(
const Interval& y, Interval& x1, Interval& x2);
42 max(
const ScalarExpr& x1,
const ScalarExpr& x2)
44 return { std::make_shared<AnalyticOperationExpr<MaxOp,ScalarType,ScalarType,ScalarType>>(x1,x2) };
47 inline ScalarType MaxOp::fwd_natural(
const ScalarType& x1,
const ScalarType& x2)
51 x1.def_domain && x2.def_domain
55 inline ScalarType MaxOp::fwd_centered(
const ScalarType& x1,
const ScalarType& x2)
57 if(centered_form_not_available_for_args(x1,x2))
58 return fwd_natural(x1,x2);
60 assert(x1.da.rows() == 1);
61 assert(x1.da.rows() == x2.da.rows() && x1.da.cols() == x2.da.cols());
63 IntervalMatrix d(1,x1.da.cols());
64 for(Index i = 0 ; i < d.size() ; i++)
65 d(0,i) =
chi(x1.a-x2.a, x2.da(0,i), x1.da(0,i));
71 x1.def_domain && x2.def_domain
96 else if(x2.lb() > x1.ub() || y.lb() > x1.ub())
99 if((x2 &= y).is_empty())
103 else if(x1.lb() > x2.ub() || y.lb() > x2.ub())
105 if((x1 &= y).is_empty())
109 else if(y.ub() < x1.lb() || y.ub() < x2.lb())
120 x1 = Interval(x1.lb(),y.ub());
123 x2 = Interval(x2.lb(),y.ub());
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:62
Interval max(const Interval &x, const Interval &y)
Returns .
Definition codac2_Interval_operations_impl.h:274
Interval chi(const Interval &x, const Interval &y, const Interval &z)
Return if , if , else.
Definition codac2_Interval_operations_impl.h:299