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,
const X2& s2) {
62 auto shape1=s1->output_shape();
63 assert_release(shape1 == s2->output_shape());
67 static Interval fwd(
const Interval& x1,
const Interval& x2);
68 static ScalarType fwd_natural(
const ScalarType& x1,
const ScalarType& x2);
69 static ScalarType fwd_centered(
const ScalarType& x1,
const ScalarType& x2);
70 static void bwd(
const Interval& y, Interval& x1, Interval& x2);
72 static IntervalVector fwd(
const IntervalVector& x1,
const IntervalVector& x2);
73 static VectorType fwd_natural(
const VectorType& x1,
const VectorType& x2);
74 static VectorType fwd_centered(
const VectorType& x1,
const VectorType& x2);
75 static void bwd(
const IntervalVector& y, IntervalVector& x1, IntervalVector& x2);
77 static IntervalMatrix fwd(
const IntervalMatrix& x1,
const IntervalMatrix& x2);
78 static MatrixType fwd_natural(
const MatrixType& x1,
const MatrixType& x2);
79 static MatrixType fwd_centered(
const MatrixType& x1,
const MatrixType& x2);
80 static void bwd(
const IntervalMatrix& y, IntervalMatrix& x1, IntervalMatrix& x2);
89 return { std::make_shared<AnalyticOperationExpr<AddOp,ScalarType,ScalarType>>(x1) };
95 return { std::make_shared<AnalyticOperationExpr<AddOp,VectorType,VectorType>>(x1) };
101 return { std::make_shared<AnalyticOperationExpr<AddOp,MatrixType,MatrixType>>(x1) };
111 return { std::make_shared<AnalyticOperationExpr<AddOp,ScalarType,ScalarType,ScalarType>>(x1,x2) };
117 return { std::make_shared<AnalyticOperationExpr<AddOp,VectorType,VectorType,VectorType>>(x1,x2) };
123 return { std::make_shared<AnalyticOperationExpr<AddOp,MatrixType,MatrixType,MatrixType>>(x1,x2) };
133 inline ScalarType AddOp::fwd_natural(
const ScalarType& x1)
141 inline ScalarType AddOp::fwd_centered(
const ScalarType& x1)
151 inline void AddOp::bwd([[maybe_unused]]
const Interval& y, [[maybe_unused]]
Interval& x1)
154 inline std::pair<Index,Index> AddOp::output_shape([[maybe_unused]]
const std::pair<Index,Index>& s1)
159 inline IntervalVector AddOp::fwd(
const IntervalVector& x1)
164 inline VectorType AddOp::fwd_natural(
const VectorType& x1)
172 inline VectorType AddOp::fwd_centered(
const VectorType& x1)
182 inline void AddOp::bwd([[maybe_unused]]
const IntervalVector& y, [[maybe_unused]] IntervalVector& x1)
184 assert(y.size() == x1.size());
187 inline IntervalMatrix AddOp::fwd(
const IntervalMatrix& x1)
192 inline MatrixType AddOp::fwd_natural(
const MatrixType& x1)
200 inline MatrixType AddOp::fwd_centered(
const MatrixType& x1)
202 if(centered_form_not_available_for_args(x1))
203 return fwd_natural(x1);
213 inline void AddOp::bwd([[maybe_unused]]
const IntervalMatrix& y, [[maybe_unused]] IntervalMatrix& x1)
215 assert(y.size() == x1.size());
223 inline ScalarType AddOp::fwd_natural(
const ScalarType& x1,
const ScalarType& x2)
227 x1.def_domain && x2.def_domain
231 inline ScalarType AddOp::fwd_centered(
const ScalarType& x1,
const ScalarType& x2)
233 if(centered_form_not_available_for_args(x1,x2))
234 return fwd_natural(x1,x2);
236 assert(x1.da.size() == x2.da.size());
241 x1.def_domain && x2.def_domain
247 if((x1 &= y-x2).is_empty())
250 else if((x2 &= y-x1).is_empty())
254 inline IntervalVector AddOp::fwd(
const IntervalVector& x1,
const IntervalVector& x2)
256 assert(x1.size() == x2.size());
260 inline VectorType AddOp::fwd_natural(
const VectorType& x1,
const VectorType& x2)
264 x1.def_domain && x2.def_domain
268 inline VectorType AddOp::fwd_centered(
const VectorType& x1,
const VectorType& x2)
270 if(centered_form_not_available_for_args(x1,x2))
271 return fwd_natural(x1,x2);
273 assert(x1.da.rows() == x2.da.rows() && x1.da.cols() == x2.da.cols());
278 x1.def_domain && x2.def_domain
282 inline void AddOp::bwd(
const IntervalVector& y, IntervalVector& x1, IntervalVector& x2)
284 assert(y.size() == x1.size() && y.size() == x2.size());
285 for(Index i = 0 ; i < y.size() ; i++)
286 AddOp::bwd(y[i], x1[i], x2[i]);
289 inline IntervalMatrix AddOp::fwd(
const IntervalMatrix& x1,
const IntervalMatrix& x2)
291 assert(x1.cols() == x2.cols() && x1.rows() == x2.rows());
295 inline MatrixType AddOp::fwd_natural(
const MatrixType& x1,
const MatrixType& x2)
299 x1.def_domain && x2.def_domain
303 inline MatrixType AddOp::fwd_centered(
const MatrixType& x1,
const MatrixType& x2)
305 if(centered_form_not_available_for_args(x1,x2))
306 return fwd_natural(x1,x2);
312 x1.def_domain && x2.def_domain
316 inline void AddOp::bwd(
const IntervalMatrix& y, IntervalMatrix& x1, IntervalMatrix& x2)
318 assert(y.cols() == x1.cols() && y.rows() == x1.rows()
319 && y.cols() == x2.cols() && y.rows() == x2.rows());
320 for(Index i = 0 ; i < y.size() ; i++)
321 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.