25 static std::string str(
const X1& x1)
31 static std::pair<Index,Index> output_shape(
const X1& s1) {
32 return s1->output_shape();
35 static Interval fwd(
const Interval& x1);
36 static ScalarType fwd_natural(
const ScalarType& x1);
37 static ScalarType fwd_centered(
const ScalarType& x1);
38 static void bwd(
const Interval& y, Interval& x1);
40 static IntervalVector fwd(
const IntervalVector& x1);
41 static VectorType fwd_natural(
const VectorType& x1);
42 static VectorType fwd_centered(
const VectorType& x1);
43 static void bwd(
const IntervalVector& y, IntervalVector& x1);
45 static IntervalMatrix fwd(
const IntervalMatrix& x1);
46 static MatrixType fwd_natural(
const MatrixType& x1);
47 static MatrixType fwd_centered(
const MatrixType& x1);
48 static void bwd(
const IntervalMatrix& y, IntervalMatrix& x1);
50 static std::pair<Index,Index> output_shape(
const std::pair<Index,Index> &s1);
54 template<
typename X1,
typename X2>
55 static std::string str(
const X1& x1,
const X2& x2)
57 return x1->str() +
"+" + x2->str();
60 template<
typename X1,
typename X2>
61 static std::pair<Index,Index> output_shape(
const X1& s1, [[maybe_unused]]
const X2& s2)
63 auto shape1 = s1->output_shape();
64 assert(shape1 == s2->output_shape());
68 static Interval fwd(
const Interval& x1,
const Interval& x2);
69 static ScalarType fwd_natural(
const ScalarType& x1,
const ScalarType& x2);
70 static ScalarType fwd_centered(
const ScalarType& x1,
const ScalarType& x2);
71 static void bwd(
const Interval& y, Interval& x1, Interval& x2);
73 static IntervalVector fwd(
const IntervalVector& x1,
const IntervalVector& x2);
74 static VectorType fwd_natural(
const VectorType& x1,
const VectorType& x2);
75 static VectorType fwd_centered(
const VectorType& x1,
const VectorType& x2);
76 static void bwd(
const IntervalVector& y, IntervalVector& x1, IntervalVector& x2);
78 static IntervalMatrix fwd(
const IntervalMatrix& x1,
const IntervalMatrix& x2);
79 static MatrixType fwd_natural(
const MatrixType& x1,
const MatrixType& x2);
80 static MatrixType fwd_centered(
const MatrixType& x1,
const MatrixType& x2);
81 static void bwd(
const IntervalMatrix& y, IntervalMatrix& x1, IntervalMatrix& x2);
90 return { std::make_shared<AnalyticOperationExpr<AddOp,ScalarType,ScalarType>>(x1) };
96 return { std::make_shared<AnalyticOperationExpr<AddOp,VectorType,VectorType>>(x1) };
102 return { std::make_shared<AnalyticOperationExpr<AddOp,MatrixType,MatrixType>>(x1) };
112 return { std::make_shared<AnalyticOperationExpr<AddOp,ScalarType,ScalarType,ScalarType>>(x1,x2) };
118 return { std::make_shared<AnalyticOperationExpr<AddOp,VectorType,VectorType,VectorType>>(x1,x2) };
124 return { std::make_shared<AnalyticOperationExpr<AddOp,MatrixType,MatrixType,MatrixType>>(x1,x2) };
134 inline ScalarType AddOp::fwd_natural(
const ScalarType& x1)
142 inline ScalarType AddOp::fwd_centered(
const ScalarType& x1)
152 inline void AddOp::bwd([[maybe_unused]]
const Interval& y, [[maybe_unused]]
Interval& x1)
155 inline std::pair<Index,Index> AddOp::output_shape([[maybe_unused]]
const std::pair<Index,Index>& s1)
160 inline IntervalVector AddOp::fwd(
const IntervalVector& x1)
165 inline VectorType AddOp::fwd_natural(
const VectorType& x1)
173 inline VectorType AddOp::fwd_centered(
const VectorType& x1)
183 inline void AddOp::bwd([[maybe_unused]]
const IntervalVector& y, [[maybe_unused]] IntervalVector& x1)
185 assert(y.size() == x1.size());
188 inline IntervalMatrix AddOp::fwd(
const IntervalMatrix& x1)
193 inline MatrixType AddOp::fwd_natural(
const MatrixType& x1)
201 inline MatrixType AddOp::fwd_centered(
const MatrixType& x1)
203 if(centered_form_not_available_for_args(x1))
204 return fwd_natural(x1);
214 inline void AddOp::bwd([[maybe_unused]]
const IntervalMatrix& y, [[maybe_unused]] IntervalMatrix& x1)
216 assert(y.size() == x1.size());
224 inline ScalarType AddOp::fwd_natural(
const ScalarType& x1,
const ScalarType& x2)
228 x1.def_domain && x2.def_domain
232 inline ScalarType AddOp::fwd_centered(
const ScalarType& x1,
const ScalarType& x2)
234 if(centered_form_not_available_for_args(x1,x2))
235 return fwd_natural(x1,x2);
237 assert(x1.da.size() == x2.da.size());
242 x1.def_domain && x2.def_domain
248 if((x1 &= y-x2).is_empty())
251 else if((x2 &= y-x1).is_empty())
255 inline IntervalVector AddOp::fwd(
const IntervalVector& x1,
const IntervalVector& x2)
257 assert(x1.size() == x2.size());
261 inline VectorType AddOp::fwd_natural(
const VectorType& x1,
const VectorType& x2)
265 x1.def_domain && x2.def_domain
269 inline VectorType AddOp::fwd_centered(
const VectorType& x1,
const VectorType& x2)
271 if(centered_form_not_available_for_args(x1,x2))
272 return fwd_natural(x1,x2);
274 assert(x1.da.rows() == x2.da.rows() && x1.da.cols() == x2.da.cols());
279 x1.def_domain && x2.def_domain
283 inline void AddOp::bwd(
const IntervalVector& y, IntervalVector& x1, IntervalVector& x2)
285 assert(y.size() == x1.size() && y.size() == x2.size());
286 for(Index i = 0 ; i < y.size() ; i++)
287 AddOp::bwd(y[i], x1[i], x2[i]);
290 inline IntervalMatrix AddOp::fwd(
const IntervalMatrix& x1,
const IntervalMatrix& x2)
292 assert(x1.cols() == x2.cols() && x1.rows() == x2.rows());
296 inline MatrixType AddOp::fwd_natural(
const MatrixType& x1,
const MatrixType& x2)
300 x1.def_domain && x2.def_domain
304 inline MatrixType AddOp::fwd_centered(
const MatrixType& x1,
const MatrixType& x2)
306 if(centered_form_not_available_for_args(x1,x2))
307 return fwd_natural(x1,x2);
313 x1.def_domain && x2.def_domain
317 inline void AddOp::bwd(
const IntervalMatrix& y, IntervalMatrix& x1, IntervalMatrix& x2)
319 assert(y.cols() == x1.cols() && y.rows() == x1.rows()
320 && y.cols() == x2.cols() && y.rows() == x2.rows());
321 for(Index i = 0 ; i < y.size() ; i++)
322 AddOp::bwd(*(y.data()+i), *(x1.data()+i), *(x2.data()+i));
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:62
Ellipsoid operator+(const Ellipsoid &e1, const Ellipsoid &e2)
Compute the Minkowski sum of two ellipsoids.