7 #ifndef NIHU_INTEGRAL_OPERATOR_EXPRESSION_HPP_INCLUDED
8 #define NIHU_INTEGRAL_OPERATOR_EXPRESSION_HPP_INCLUDED
17 #include <type_traits>
27 template <
class Derived>
32 template <
class Derived>
39 :
public std::is_base_of<
40 integral_operator_expression<typename std::decay<C>::type>,
41 typename std::decay<C>::type> {};
47 template <
class LhsDerived,
class RhsDerived>
50 template <
class LhsDerived,
class RhsDerived>
52 :
public std::integral_constant<bool,
53 is_local_operator<typename std::decay<LhsDerived>::type>::value &&
54 is_local_operator<typename std::decay<RhsDerived>::type>::value> {};
59 template <
class LhsDerived,
class RhsDerived>
62 template <
class LhsDerived,
class RhsDerived>
64 :
public std::integral_constant<bool,
65 is_local_operator<typename std::decay<LhsDerived>::type>::value &&
66 is_local_operator<typename std::decay<RhsDerived>::type>::value> {};
71 template <
class LhsDerived,
class Scalar>
74 template <
class LhsDerived,
class Scalar>
81 template <
class LhsDerived,
class RhsDerived>
84 template <
class LhsDerived,
class RhsDerived>
86 :
public std::integral_constant<bool,
87 is_local_operator<typename std::decay<LhsDerived>::type>::value &&
88 is_local_operator<typename std::decay<RhsDerived>::type>::value> {};
90 template <
class Derived>
94 typedef Derived derived_t;
97 typedef typename traits_t::trial_input_t trial_input_t;
98 typedef typename traits_t::test_input_t test_input_t;
99 typedef typename traits_t::result_t result_t;
104 return *(
static_cast<derived_t const *
>(
this));
110 return *(
static_cast<derived_t *
>(
this));
116 size_t rows(test_input_t
const &ti)
const
124 size_t cols(trial_input_t
const &ti)
const
133 result_t
operator()(test_input_t
const &tsi, trial_input_t
const &tri)
const
143 template <
class Lhs,
class Rhs,
typename std::enable_if<
144 is_integral_operator_expression<Lhs>::value &
145 is_integral_operator_expression<Rhs>::value,
int>::type = 0>
149 std::forward<Lhs>(lhs), std::forward<Rhs>(rhs));
157 template <
class Lhs,
class Rhs,
typename std::enable_if<
158 is_integral_operator_expression<Lhs>::value &
159 is_integral_operator_expression<Rhs>::value,
int>::type = 0>
163 std::forward<Lhs>(lhs), std::forward<Rhs>(rhs));
171 template <
class Lhs,
class Scalar,
172 typename std::enable_if<is_integral_operator_expression<Lhs>::value,
int>::type = 0>
176 std::forward<Lhs>(lhs), std::forward<Scalar>(c));
183 template <
class Scalar,
class Rhs,
184 typename std::enable_if<is_integral_operator_expression<Rhs>::value,
int>::type = 0>
185 integral_operator_scaled<Rhs, Scalar>
186 operator *(Scalar &&c, Rhs &&rhs)
189 std::forward<Rhs>(rhs), std::forward<Scalar>(c));
196 template <
class Lhs,
class Rhs>
199 typedef typename std::decay<Lhs>::type lhs_derived_t;
209 template <
class Lhs,
class Rhs>
212 typedef typename std::decay<Lhs>::type lhs_derived_t;
219 template <
class Lhs,
class Rhs>
222 ,
public fmm_operator<typename std::decay<Lhs>::type::fmm_tag>
226 typedef typename base_t::test_input_t test_input_t;
227 typedef typename base_t::trial_input_t trial_input_t;
228 typedef typename base_t::result_t result_t;
231 : m_lhs(std::forward<Lhs>(lhs))
232 , m_rhs(std::forward<Rhs>(rhs))
236 size_t rows(test_input_t
const &ti)
const
238 return m_lhs.rows(ti);
241 size_t cols(trial_input_t
const &ti)
const
243 return m_lhs.cols(ti);
246 result_t operator()(test_input_t
const &tsi, trial_input_t
const &tri)
const
248 return m_lhs(tsi, tri) + m_rhs(tsi, tri);
257 template <
class Lhs,
class Rhs>
258 class integral_operator_diff
259 :
public integral_operator_expression<integral_operator_diff<Lhs, Rhs> >
260 ,
public fmm_operator<typename std::decay<Lhs>::type::fmm_tag>
263 typedef integral_operator_expression<integral_operator_diff<Lhs, Rhs> > base_t;
264 typedef typename base_t::test_input_t test_input_t;
265 typedef typename base_t::trial_input_t trial_input_t;
266 typedef typename base_t::result_t result_t;
268 integral_operator_diff(Lhs &&lhs, Rhs &&rhs)
269 : m_lhs(std::forward<Lhs>(lhs))
270 , m_rhs(std::forward<Rhs>(rhs))
274 size_t rows(test_input_t
const &ti)
const
276 return m_lhs.rows(ti);
279 size_t cols(trial_input_t
const &ti)
const
281 return m_lhs.cols(ti);
284 result_t operator()(test_input_t
const &tsi, trial_input_t
const &tri)
const
286 return m_lhs(tsi, tri) - m_rhs(tsi, tri);
298 template <
class Lhs,
class Scalar>
301 typedef typename std::decay<Lhs>::type lhs_derived_t;
302 typedef typename std::decay<Scalar>::type scalar_t;
318 template <
class Lhs,
class Scalar>
321 ,
public fmm_operator<typename std::decay<Lhs>::type::fmm_tag>
325 typedef typename base_t::test_input_t test_input_t;
326 typedef typename base_t::trial_input_t trial_input_t;
327 typedef typename base_t::result_t result_t;
330 : m_lhs(std::forward<Lhs>(lhs))
331 , m_c(std::forward<Scalar>(c))
335 size_t rows(test_input_t
const &ti)
const
337 return m_lhs.rows(ti);
340 size_t cols(trial_input_t
const &ti)
const
342 return m_lhs.cols(ti);
345 result_t operator()(test_input_t
const &tsi, trial_input_t
const &tri)
const
347 return m_lhs(tsi, tri) * m_c;
359 template <
class Lhs,
class Rhs>
362 typedef typename std::decay<Lhs>::type lhs_derived_t;
363 typedef typename std::decay<Rhs>::type rhs_derived_t;
367 typedef typename scalar<typename lhs_derived_t::result_t>::type scalar_t;
368 typedef Eigen::Matrix<scalar_t, lhs_rows, lhs_cols + rhs_cols> result_t;
374 template <
class Lhs,
class Rhs>
377 ,
public fmm_operator<typename std::decay<Lhs>::type::fmm_tag>
381 typedef typename base_t::test_input_t test_input_t;
382 typedef typename base_t::trial_input_t trial_input_t;
383 typedef typename base_t::result_t result_t;
386 : m_lhs(std::forward<Lhs>(lhs))
387 , m_rhs(std::forward<Rhs>(rhs))
391 size_t rows(test_input_t
const &ti)
const
393 return m_lhs.rows(ti);
396 size_t cols(trial_input_t
const &ti)
const
398 return m_lhs.cols(ti) + m_rhs.cols(ti);
401 result_t operator()(test_input_t
const &tsi, trial_input_t
const &tri)
const
403 result_t res(rows(tsi), cols(tri));
404 res.leftCols(m_lhs.cols(tri)) = m_lhs(tsi, tri);
405 res.rightCols(m_rhs.cols(tri)) = m_rhs(tsi, tri);
414 template <
class Lhs,
class Rhs>
415 auto src_concatenate(Lhs &&lhs, Rhs &&rhs)
417 return integral_operator_src_concatenated<Lhs, Rhs>(std::forward<Lhs>(lhs), std::forward<Rhs>(rhs));