26 #ifndef TILEDARRAY_TILE_OP_MULT_H__INCLUDED
27 #define TILEDARRAY_TILE_OP_MULT_H__INCLUDED
55 template <
typename Result,
typename Left,
typename Right,
bool LeftConsumable,
72 LeftConsumable && std::is_same<result_type, left_type>::value;
75 RightConsumable && std::is_same<result_type, right_type>::value;
85 template <
typename Perm,
typename = std::enable_if_t<
86 TiledArray::detail::is_permutation_v<Perm>>>
88 const Perm& perm)
const {
91 return mult(first, second, perm);
94 return binary(first, second, element_op_, perm);
98 template <
typename Perm,
typename = std::enable_if_t<
99 TiledArray::detail::is_permutation_v<Perm>>>
101 const Perm& perm)
const {
106 template <
typename Perm,
typename = std::enable_if_t<
107 TiledArray::detail::is_permutation_v<Perm>>>
117 template <
bool LC,
bool RC,
118 typename std::enable_if<!(LC || RC)>::type* =
nullptr>
122 return mult(first, second);
125 return binary(first, second, element_op_);
129 template <bool LC, bool RC, typename std::enable_if<LC>::type* =
nullptr>
136 template <
bool LC,
bool RC,
137 typename std::enable_if<!LC && RC>::type* =
nullptr>
144 template <bool LC, bool RC, typename std::enable_if<!RC>::type* =
nullptr>
150 template <bool LC, bool RC, typename std::enable_if<RC>::type* =
nullptr>
156 template <bool LC, bool RC, typename std::enable_if<!LC>::type* =
nullptr>
162 template <bool LC, bool RC, typename std::enable_if<LC>::type* =
nullptr>
176 template <
typename ElementOp,
177 typename = std::enable_if_t<
178 !std::is_same_v<std::remove_reference_t<ElementOp>,
Mult_> &&
179 std::is_invocable_r_v<
182 explicit Mult(ElementOp&& op) : element_op_(std::forward<ElementOp>(op)) {}
194 typename L,
typename R,
typename Perm,
195 typename = std::enable_if_t<TiledArray::detail::is_permutation_v<Perm>>>
197 return eval(std::forward<L>(left), std::forward<R>(right), perm);
208 template <
typename L,
typename R>
210 return Mult_::template eval<left_is_consumable, right_is_consumable>(
211 std::forward<L>(left), std::forward<R>(right));
221 template <
typename R>
223 constexpr
bool can_consume_left =
225 std::is_same<result_type, left_type>::value;
226 constexpr
bool can_consume_right =
228 return Mult_::template eval<can_consume_left, can_consume_right>(
229 left, std::forward<R>(right));
239 template <
typename L>
241 constexpr
bool can_consume_right =
243 std::is_same<result_type, right_type>::value;
244 constexpr
bool can_consume_left =
246 return Mult_::template eval<can_consume_left, can_consume_right>(
247 std::forward<L>(left), right);
267 template <
typename Result,
typename Left,
typename Right,
typename Scalar,
268 bool LeftConsumable,
bool RightConsumable>
271 typedef ScalMult<Result, Left, Right, Scalar, LeftConsumable,
281 LeftConsumable && std::is_same<result_type, left_type>::value;
284 RightConsumable && std::is_same<result_type, right_type>::value;
293 template <
typename Perm,
typename = std::enable_if_t<
294 TiledArray::detail::is_permutation_v<Perm>>>
296 const Perm& perm)
const {
298 return mult(first, second, factor_, perm);
301 template <
typename Perm,
typename = std::enable_if_t<
302 TiledArray::detail::is_permutation_v<Perm>>>
304 const Perm& perm)
const {
309 template <
typename Perm,
typename = std::enable_if_t<
310 TiledArray::detail::is_permutation_v<Perm>>>
320 template <
bool LC,
bool RC,
321 typename std::enable_if<!(LC || RC)>::type* =
nullptr>
324 return mult(first, second, factor_);
327 template <bool LC, bool RC, typename std::enable_if<LC>::type* =
nullptr>
330 return mult_to(first, second, factor_);
333 template <
bool LC,
bool RC,
334 typename std::enable_if<!LC && RC>::type* =
nullptr>
337 return mult_to(second, first, factor_);
340 template <bool LC, bool RC, typename std::enable_if<!RC>::type* =
nullptr>
346 template <bool LC, bool RC, typename std::enable_if<RC>::type* =
nullptr>
352 template <bool LC, bool RC, typename std::enable_if<!LC>::type* =
nullptr>
358 template <bool LC, bool RC, typename std::enable_if<LC>::type* =
nullptr>
375 explicit ScalMult(
const Scalar factor) : factor_(factor) {}
387 typename L,
typename R,
typename Perm,
388 typename = std::enable_if_t<TiledArray::detail::is_permutation_v<Perm>>>
390 return eval(std::forward<L>(left), std::forward<R>(right), perm);
401 template <
typename L,
typename R>
403 return ScalMult_::template eval<left_is_consumable, right_is_consumable>(
404 std::forward<L>(left), std::forward<R>(right));
414 template <
typename R>
416 constexpr
bool can_consume_left =
418 std::is_same<result_type, left_type>::value;
419 constexpr
bool can_consume_right =
421 return ScalMult_::template eval<can_consume_left, can_consume_right>(
422 left, std::forward<R>(right));
433 template <
typename L>
435 constexpr
bool can_consume_right =
437 std::is_same<result_type, right_type>::value;
438 constexpr
bool can_consume_left =
440 return ScalMult_::template eval<can_consume_left, can_consume_right>(
441 std::forward<L>(left), right);
449 #endif // TILEDARRAY_TILE_OP_MULT_H__INCLUDED