Go to the documentation of this file.
26 #ifndef TILEDARRAY_TENSOR_OPERATORS_H__INCLUDED
27 #define TILEDARRAY_TENSOR_OPERATORS_H__INCLUDED
43 template <
typename T1,
typename T2,
44 typename std::enable_if<
45 detail::is_tensor<T1, T2>::value ||
46 detail::is_tensor_of_tensor<T1, T2>::value>::type* =
nullptr>
47 inline auto operator+(
const T1& left,
const T2& right) {
48 return add(left, right);
59 template <
typename T1,
typename T2,
60 typename std::enable_if<
61 detail::is_tensor<T1, T2>::value ||
62 detail::is_tensor_of_tensor<T1, T2>::value>::type* =
nullptr>
63 inline auto operator-(
const T1& left,
const T2& right) {
64 return subt(left, right);
75 template <
typename T1,
typename T2,
76 typename std::enable_if<
77 detail::is_tensor<T1, T2>::value ||
78 detail::is_tensor_of_tensor<T1, T2>::value>::type* =
nullptr>
79 inline auto operator*(
const T1& left,
const T2& right) {
80 return mult(left, right);
91 template <
typename T,
typename N,
94 detail::is_numeric_v<N>>::type* =
nullptr>
95 inline auto operator*(
const T& left, N right) {
96 return scale(left, right);
106 template <
typename N,
typename T,
107 typename std::enable_if<
108 detail::is_numeric_v<N> &&
111 inline auto operator*(N left,
const T& right) {
112 return scale(right, left);
120 template <typename T, typename std::enable_if<detail::is_tensor<T>::value ||
121 detail::is_tensor_of_tensor<
122 T>::value>::type* =
nullptr>
123 inline auto operator-(
const T& arg) -> decltype(arg.neg()) {
132 template <typename T, typename std::enable_if<detail::is_tensor<T>::value ||
133 detail::is_tensor_of_tensor<
134 T>::value>::type* =
nullptr>
147 template <
typename T1,
typename T2,
148 typename std::enable_if<
149 detail::is_tensor<T1, T2>::value ||
150 detail::is_tensor_of_tensor<T1, T2>::value>::type* =
nullptr>
152 return add_to(left, right);
163 template <
typename T1,
typename T2,
164 typename std::enable_if<
165 detail::is_tensor<T1, T2>::value ||
166 detail::is_tensor_of_tensor<T1, T2>::value>::type* =
nullptr>
168 return sub_to(left, right);
179 template <
typename T1,
typename T2,
180 typename std::enable_if<
181 detail::is_tensor<T1, T2>::value ||
182 detail::is_tensor_of_tensor<T1, T2>::value>::type* =
nullptr>
195 template <
typename T,
typename N,
198 detail::is_numeric_v<N>>::type* =
nullptr>
199 inline auto operator+=(T& left, N right) {
200 return add_to(left, right);
211 template <
typename T,
typename N,
214 detail::is_numeric_v<N>>::type* =
nullptr>
215 inline auto operator-=(T& left, N right) {
227 template <
typename T,
typename N,
230 detail::is_numeric_v<N>>::type* =
nullptr>
231 inline auto operator*=(T& left, N right) {
237 #endif // TILEDARRAY_TENSOR_OPERATORS_H__INCLUDED
decltype(auto) subt(const Tile< Left > &left, const Tile< Right > &right)
Subtract tile arguments.
std::enable_if<!TiledArray::detail::is_permutation_v< Perm >, TiledArray::Range >::type permute(const TiledArray::Range &r, const Perm &p)
auto operator+(const T1 &left, const T2 &right)
Tensor plus operator.
Tile< Result > & scale_to(Tile< Result > &result, const Scalar factor)
Scale to the result tile.
Permutation of a sequence of objects indexed by base-0 indices.
Tile< Result > & mult_to(Tile< Result > &result, const Tile< Arg > &arg)
Multiply to the result tile.
decltype(auto) add(const Tile< Left > &left, const Tile< Right > &right)
Add tile arguments.
std::array< T, N > operator*(const Permutation &, const std::array< T, N > &)
Permute a std::array.
decltype(auto) neg(const Tile< Arg > &arg)
Negate the tile argument.
auto operator-=(T1 &left, const T2 &right)
Tensor minus operator.
Tile< Result > & add_to(Tile< Result > &result, const Tile< Arg > &arg)
Add to the result tile.
auto operator+=(T1 &left, const T2 &right)
Tensor plus operator.
decltype(auto) mult(const Tile< Left > &left, const Tile< Right > &right)
Multiplication tile arguments.
Permutation operator-(const Permutation &perm)
Inverse permutation operator.
static constexpr bool value
decltype(auto) scale(const Tile< Arg > &arg, const Scalar factor)
Scalar the tile argument.
std::array< T, N > & operator*=(std::array< T, N > &, const Permutation &)
In-place permute a std::array.
Tile< Result > & subt_to(Tile< Result > &result, const Tile< Arg > &arg)
Subtract from the result tile.
static constexpr bool value