21 template<
typename X1,
typename P>
22 static std::string str(
const X1& x1,
const P& p)
24 return "mod(" + x1->str() +
"," + p->str() +
")";
27 template<
typename X1,
typename P>
28 static std::pair<Index,Index> output_shape([[maybe_unused]]
const X1& s1, [[maybe_unused]]
const P& p)
33 static Interval fwd(
const Interval& x1,
const Interval& p);
34 static ScalarType fwd_natural(
const ScalarType& x1,
const ScalarType& p);
35 static ScalarType fwd_centered(
const ScalarType& x1,
const ScalarType& p);
36 static void bwd(
const Interval& y, Interval& x1, Interval& p);
38 static void fwd_bwd(Interval& x1, Interval& x2,
double p);
39 static void fwd_bwd(Interval& x1, Interval& x2, Interval& p);
45 mod(
const ScalarExpr& x1,
const ScalarExpr& p)
47 return { std::make_shared<AnalyticOperationExpr<ModOp,ScalarType,ScalarType,ScalarType>>(x1,p) };
54 Interval x2, x1_(x1), p_(p);
55 ModOp::fwd_bwd(x2,x1_,p_);
59 inline ScalarType ModOp::fwd_natural(
const ScalarType& x1,
const ScalarType& p)
63 x1.def_domain && p.def_domain
67 inline ScalarType ModOp::fwd_centered(
const ScalarType& x1,
const ScalarType& p)
69 if(centered_form_not_available_for_args(x1,p))
70 return fwd_natural(x1,p);
76 x1.def_domain && p.def_domain
83 ModOp::fwd_bwd(y_,x1,p);
92 assert_release(p > 0. &&
"Modulo needs a strictly positive period p.");
94 if(!(x1.diam() > p || y.diam() > p))
96 Interval r = (y-x1)/p;
107 if(ir.is_degenerated())
108 SubOp::bwd(ir*p,y,x1);
110 else if(ir.diam() == 1.)
112 Interval y_1 = y; Interval y_2 = y;
113 Interval x1_1 = x1; Interval x1_2 = x1;
114 SubOp::bwd(Interval(ir.lb()*p),y_1,x1_1);
115 SubOp::bwd(Interval(ir.ub()*p),y_2,x1_2);
122 assert_release_constexpr(
false &&
"Modulo diameter error.");
130 assert_release(p.is_degenerated() &&
"ModOp::fwd_bwd(y,x1,p) (with y and x1 intervals) not implemented yet");
131 ModOp::fwd_bwd(y, x1, p.mid());
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:49
Definition codac2_OctaSym.h:21
Interval integer(const Interval &x)
Returns the largest integer interval included in .
Definition codac2_Interval_operations_impl.h:284
Eigen::Matrix< Interval,-1,-1 > IntervalMatrix
Alias for a dynamic-size matrix of intervals.
Definition codac2_IntervalMatrix.h:25