26 #ifndef TILEDARRAY_SRC_TILEDARRAY_TILE_INTERFACE_SCALE_H__INCLUDED
27 #define TILEDARRAY_SRC_TILEDARRAY_TILE_INTERFACE_SCALE_H__INCLUDED
29 #include "../permutation.h"
30 #include "../type_traits.h"
41 template <
typename Arg,
typename Scalar,
42 std::enable_if_t<TiledArray::detail::is_numeric_v<Scalar> &&
43 !TiledArray::detail::is_array_v<Arg>>* =
nullptr>
44 inline auto scale(
const Arg& arg,
const Scalar factor) {
45 return arg.scale(factor);
57 typename Arg,
typename Scalar,
typename Perm,
58 std::enable_if_t<TiledArray::detail::is_numeric_v<Scalar> &&
59 TiledArray::detail::is_permutation_v<Perm>>* =
nullptr>
60 inline auto scale(
const Arg& arg,
const Scalar factor,
const Perm& perm) {
61 return arg.scale(factor, perm);
71 template <
typename Result,
typename Scalar,
72 std::enable_if_t<TiledArray::detail::is_numeric_v<Scalar>>* =
nullptr>
73 inline Result&
scale_to(Result& result,
const Scalar factor) {
74 return result.scale_to(factor);
77 namespace tile_interface {
79 template <
typename... T>
82 template <
typename... T>
85 template <
typename Arg,
typename Scalar,
typename Enabler =
void>
90 template <
typename Arg,
typename Scalar>
92 typename std::enable_if<TiledArray::detail::is_type<
93 result_of_scale_t<Arg, Scalar>>::value>
::type> {
97 template <
typename Result,
typename Arg,
typename Scalar,
98 typename Enabler =
void>
101 static_assert(TiledArray::detail::is_numeric_v<Scalar>,
102 "Cannot scale tiles by a non-scalar type");
111 return scale(arg, factor);
114 template <
typename Perm,
typename = std::enable_if_t<
115 TiledArray::detail::is_permutation_v<Perm>>>
117 const Perm& perm)
const {
119 return scale(arg, factor, perm);
123 template <
typename Result,
typename Arg,
typename Scalar>
125 typename std::enable_if<!std::is_same<
126 Result, result_of_scale_t<Arg, Scalar>>::value>::type> {
128 static_assert(TiledArray::detail::is_numeric_v<Scalar>,
129 "Cannot scale tiles by a non-scalar type");
139 return cast(
scale(arg, factor));
142 template <
typename Perm,
typename = std::enable_if_t<
143 TiledArray::detail::is_permutation_v<Perm>>>
145 const Perm& perm)
const {
148 return cast(
scale(arg, factor, perm));
152 template <
typename Result,
typename Arg,
typename Scalar,
153 typename Enabler =
void>
156 static_assert(TiledArray::detail::is_numeric_v<Scalar>,
157 "Cannot scale tiles by a non-scalar type");
169 template <
typename Result,
typename Arg,
typename Scalar>
171 typename std::enable_if<!std::is_same<
172 Result, result_of_scale_t<Arg, Scalar>>::value>::type> {
174 static_assert(TiledArray::detail::is_numeric_v<Scalar>,
175 "Cannot scale tiles by a non-scalar type");
197 template <
typename Arg,
typename Scalar>
207 template <
typename Result,
typename Arg,
typename Scalar>
212 #endif // TILEDARRAY_SRC_TILEDARRAY_TILE_INTERFACE_SCALE_H__INCLUDED