Go to the documentation of this file.
26 #ifndef TILEDARRAY_TILE_OP_SHIFT_H__INCLUDED
27 #define TILEDARRAY_TILE_OP_SHIFT_H__INCLUDED
29 #include "../tile_interface/permute.h"
30 #include "../tile_interface/shift.h"
45 template <
typename Result,
typename Arg,
bool Consumable>
54 Consumable && std::is_same<result_type, argument_type>::value;
57 std::vector<long> range_shift_;
62 template <
typename Perm,
typename = std::enable_if_t<
63 TiledArray::detail::is_permutation_v<Perm>>>
76 template <
bool C,
typename =
void>
79 return shift(arg, range_shift_);
82 template <bool C, typename = typename std::enable_if<C>::type>
89 template <bool C, typename = typename std::enable_if<C>::type>
108 Shift(
const std::vector<long>& range_shift) : range_shift_(range_shift) {}
115 template <
typename Perm,
typename = std::enable_if_t<
116 TiledArray::detail::is_permutation_v<Perm>>>
118 return eval(arg, perm);
126 template <
typename A>
128 return Shift_::template eval<is_consumable>(std::forward<A>(arg));
136 template <
typename A>
138 constexpr
bool can_consume =
140 std::is_same<result_type, argument_type>::value;
141 return Shift_::template eval<can_consume>(arg);
154 template <
typename Result,
typename Arg,
typename Scalar,
bool Consumable>
164 Consumable && std::is_same<result_type, argument_type>::value;
167 std::vector<long> range_shift_;
174 template <
typename Perm,
typename = std::enable_if_t<
175 TiledArray::detail::is_permutation_v<Perm>>>
180 return shift_to(result, range_shift_);
188 typename std::enable_if<!C, result_type>::type
eval(
193 return shift_to(result, range_shift_);
218 : range_shift_(range_shift), factor_(factor) {}
225 template <
typename Perm,
typename = std::enable_if_t<
226 TiledArray::detail::is_permutation_v<Perm>>>
228 return eval(arg, perm);
236 template <
typename A>
238 return ScalShift_::template eval<is_consumable>(std::forward<A>(arg));
246 constexpr
bool can_consume =
248 std::is_same<result_type, argument_type>::value;
249 return ScalShift_::template eval<can_consume>(arg);
257 #endif // TILEDARRAY_TILE_OP_SHIFT_H__INCLUDED
Arg argument_type
The argument type.
Tile< Arg > & shift_to(Tile< Arg > &arg, const Index &range_shift)
Shift the range of arg in place.
ScalShift< Result, Arg, Scalar, Consumable > ScalShift_
This object type.
Tile< Result > & scale_to(Tile< Result > &result, const Scalar factor)
Scale to the result tile.
Consumable tile type trait.
std::enable_if< C, result_type >::type eval(argument_type &arg) const
std::enable_if<!C, result_type >::type eval(const argument_type &arg) const
void permute(InputOp &&input_op, OutputOp &&output_op, Result &result, const Perm &perm, const Arg0 &arg0, const Args &... args)
Construct a permuted tensor copy.
detail::ShiftWrapper< T > shift(T &tensor)
Shift a tensor from one range to another.
Scalar scalar_type
The scaling factor type.
Shift & operator=(const Shift_ &)=default
result_type operator()(A &&arg) const
Consuming shift operation.
Result result_type
The result tile type.
Shift(const std::vector< long > &range_shift)
Default constructor.
ScalShift(ScalShift_ &&)=default
ScalShift(const ScalShift_ &)=default
result_type operator()(const argument_type &arg, const Perm &perm) const
Shift and permute operator.
ScalShift_ & operator=(ScalShift_ &&)=default
Shift(const Shift_ &)=default
Shift the range of tile in place.
result_type operator()(A &&arg) const
Consuming shift operation.
static constexpr bool is_consumable
Indicates whether it is possible to consume the left tile.
decltype(auto) scale(const Tile< Arg > &arg, const Scalar factor)
Scalar the tile argument.
result_type consume(A &arg) const
Explicit consuming shift operation.
result_type eval(const argument_type &arg, const Perm &perm) const
Shift< Result, Arg, Consumable > Shift_
This object type.
ScalShift(const std::vector< long > &range_shift, const scalar_type factor)
Default constructor.
Arg argument_type
The argument type.
result_type consume(argument_type &arg) const
Explicit consuming shift operation.
static constexpr bool is_consumable
result_type operator()(const argument_type &arg, const Perm &perm) const
Shift and permute operator.
Result result_type
The result tile type.
ScalShift_ & operator=(const ScalShift_ &)=default
Shift & operator=(Shift_ &&)=default