21 template<
typename... X>
22 static std::string str(
const X&... x)
24 std::string s = ((
"\t" + x->str() +
",\n") + ...);
25 s.pop_back(); s.pop_back();
26 return "[\n" + s +
"\n]";
29 template<
typename X1,
typename... X>
30 static std::pair<Index,Index> output_shape(
const X1& s1, [[maybe_unused]]
const X&... s)
32 auto shape1=s1->output_shape();
33 assert_release(shape1.second==1);
34 return { shape1.first, 1+
sizeof...(X) };
37 static inline void set_col_i(IntervalMatrix& m,
const IntervalVector& x, Index i)
39 assert(i >= 0 && i < m.cols());
40 assert_release(x.size() == m.rows());
44 template<
typename X1,
typename... X>
45 requires ((X1::ColsAtCompileTime == 1) && ((X::ColsAtCompileTime == 1) && ...))
46 static inline IntervalMatrix fwd(
const X1& x1,
const X&... x)
48 IntervalMatrix m(x1.size(), 1+
sizeof...(X));
50 MatrixOp::set_col_i(m, x1, i++);
51 (MatrixOp::set_col_i(m, x, i++), ...);
55 template<
typename... X>
56 requires (std::is_base_of_v<VectorType,X> && ...)
57 static inline MatrixType fwd_natural(
const X&... x)
60 MatrixOp::fwd(x.a...),
65 static inline void fill_diff_matrix(IntervalMatrix &d,
66 const IntervalMatrix &dax, Index &l) {
67 d.middleRows(l,dax.rows())=dax;
72 template<
typename X1,
typename... X>
73 requires (std::is_base_of_v<VectorType,X1>
74 && (std::is_base_of_v<VectorType,X> && ...))
75 static inline MatrixType fwd_centered(
const X1& x1,
const X&... x)
77 if (centered_form_not_available_for_args(x1,x...))
78 return fwd_natural(x1,x...);
80 IntervalMatrix d(x1.a.size()*(1+
sizeof...(X)),x1.da.cols());
82 d.topRows(x1.da.rows()) = x1.da;
84 ( MatrixOp::fill_diff_matrix(d,x.da,l) , ...);
88 MatrixOp::fwd(x1.m,x.m...),
89 MatrixOp::fwd(x1.a,x.a...),
91 (x1.def_domain && (x.def_domain && ...))
95 template<
typename... X>
96 requires (std::is_base_of_v<IntervalVector,X> && ...)
97 static inline void bwd(
const IntervalMatrix& y, X&... x)
99 throw std::runtime_error(
"MatrixOp not fully implemented yet");
101 ((x &= y.col(i++)), ...);
110 template<
typename... X>
112 mat(
const std::shared_ptr<AnalyticExpr<X>>&... x)
114 return { std::make_shared<AnalyticOperationExpr<MatrixOp,MatrixType,X...>>(
115 AnalyticOperationExpr<MatrixOp,MatrixType,X...>(x...)) };