Tatooine
operator_overloads.h
Go to the documentation of this file.
1#ifndef TATOOINE_EINSTEIN_NOTATION_OPERATOR_OVERLOADS_H
2#define TATOOINE_EINSTEIN_NOTATION_OPERATOR_OVERLOADS_H
3//==============================================================================
10//==============================================================================
12//==============================================================================
13template <typename TensorLHS, index... IndicesLHS, typename TensorRHS,
14 index... IndicesRHS>
18 indexed_dynamic_tensor<TensorLHS, IndicesLHS...>,
19 indexed_dynamic_tensor<TensorRHS, IndicesRHS...>>{lhs, rhs};
20}
21// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
22template <typename TensorLHS, index... IndicesLHS, typename TensorRHS,
23 index... IndicesRHS>
26 return contract(lhs, rhs);
27}
28// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
29template <typename TensorLHS, index... IndicesLHS, typename TensorRHS,
30 index... IndicesRHS>
34 indexed_static_tensor<TensorLHS, IndicesLHS...>,
35 indexed_static_tensor<TensorRHS, IndicesRHS...>>{lhs, rhs};
36}
37// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
38template <typename TensorLHS, index... IndicesLHS, typename TensorRHS,
39 index... IndicesRHS>
42 return contract(lhs, rhs);
43}
44// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
45template <typename... IndexedTensorLHS, typename TensorRHS, index... IndicesRHS,
46 std::size_t... LHSSeq>
49 std::index_sequence<LHSSeq...> /*lhs_seq*/) {
51 IndexedTensorLHS..., indexed_static_tensor<TensorRHS, IndicesRHS...>>{
52 lhs.template at<LHSSeq>()..., rhs};
53}
54// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
55template <typename... IndexedTensorLHS, typename TensorRHS, index... IndicesRHS>
58 return contract(lhs, rhs,
59 std::make_index_sequence<sizeof...(IndexedTensorLHS)>{});
60}
61// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
62template <typename... IndexedTensorLHS, typename TensorRHS, index... IndicesRHS>
65 return contract(lhs, rhs);
66}
67// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
68template <index... IndicesLHS, typename TensorLHS, typename... IndexedTensorRHS,
69 std::size_t... RHSSeq>
72 std::index_sequence<RHSSeq...> /*rhs_seq*/) {
74 indexed_static_tensor<TensorLHS, IndicesLHS...>, IndexedTensorRHS...>{
75 lhs, rhs.template at<RHSSeq>()...};
76}
77// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
78template <index... IndicesLHS, typename TensorLHS, typename... IndexedTensorRHS>
81 return contract(lhs, rhs,
82 std::make_index_sequence<sizeof...(IndexedTensorRHS)>{});
83}
84// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
85template <typename TensorLHS, index... IndicesLHS, typename... IndexedTensorRHS>
88 return contract(lhs, rhs);
89}
90//------------------------------------------------------------------------------
91template <typename TensorLHS, index... IndicesLHS, typename TensorRHS,
92 index... IndicesRHS>
96 contracted_static_tensor<indexed_static_tensor<TensorLHS, IndicesLHS...>>{
97 lhs},
98 contracted_static_tensor<indexed_static_tensor<TensorRHS, IndicesRHS...>>{
99 rhs}};
100}
101//------------------------------------------------------------------------------
102template <typename... IndexedTensorLHS, typename TensorRHS, index... IndicesRHS>
106 lhs,
107 contracted_static_tensor<indexed_static_tensor<TensorRHS, IndicesRHS...>>{
108 rhs}};
109}
110//------------------------------------------------------------------------------
111template <typename TensorLHS, index... IndicesLHS, typename... TensorsRHS>
115 contracted_static_tensor<indexed_static_tensor<TensorLHS, IndicesLHS...>>{
116 lhs},
117 rhs};
118}
119//------------------------------------------------------------------------------
120template <typename... TensorsLHS, typename... TensorsRHS>
123 return added_contracted_static_tensor{lhs, rhs};
124}
125//------------------------------------------------------------------------------
126template <typename... ContractedTensorsLHS, typename... TensorsRHS,
127 std::size_t... Seq>
130 std::index_sequence<Seq...>) {
131 return added_contracted_static_tensor{lhs.template at<Seq>()..., rhs};
132}
133//------------------------------------------------------------------------------
134template <typename... TensorsLHS, typename... ContractedTensorsRHS,
135 std::size_t... Seq>
138 std::index_sequence<Seq...>) {
139 return added_contracted_static_tensor{lhs, rhs.template at<Seq>()...};
140}
141//------------------------------------------------------------------------------
142template <typename... ContractedTensorsLHS, typename... ContractedTensorsRHS,
143 std::size_t... Seq0, std::size_t... Seq1>
146 std::index_sequence<Seq0...>, std::index_sequence<Seq1...>) {
147 return added_contracted_static_tensor{lhs.template at<Seq0>()...,
148 rhs.template at<Seq1>()...};
149}
150//------------------------------------------------------------------------------
151template <typename... ContractedTensorsLHS, typename... TensorsRHS>
154 return add(lhs, rhs,
155 std::make_index_sequence<sizeof...(ContractedTensorsLHS)>{});
156}
157//------------------------------------------------------------------------------
158template <typename... TensorsLHS, typename... ContractedTensorsRHS>
161 return add(lhs, rhs,
162 std::make_index_sequence<sizeof...(ContractedTensorsRHS)>{});
163}
164//------------------------------------------------------------------------------
165template <typename... ContractedTensorsLHS, typename... ContractedTensorsRHS>
168 return add(lhs, rhs,
169 std::make_index_sequence<sizeof...(ContractedTensorsLHS)>{},
170 std::make_index_sequence<sizeof...(ContractedTensorsRHS)>{});
171}
172//------------------------------------------------------------------------------
173template <typename... ContractedTensorsLHS, typename... TensorsRHS>
176 return add(lhs, rhs);
177}
178//------------------------------------------------------------------------------
179template <typename... TensorsLHS, typename... ContractedTensorsRHS>
182 return add(lhs, rhs);
183}
184//------------------------------------------------------------------------------
185template <typename... ContractedTensorsLHS, typename... ContractedTensorsRHS>
188 return add(lhs, rhs);
189}
190//==============================================================================
191} // namespace tatooine::einstein_notation
192//==============================================================================
193#endif
Definition: added_contracted_dynamic_tensor.h:4
auto add(added_contracted_static_tensor< ContractedTensorsLHS... > lhs, contracted_static_tensor< TensorsRHS... > rhs, std::index_sequence< Seq... >)
Definition: operator_overloads.h:128
auto constexpr contract(indexed_dynamic_tensor< TensorLHS, IndicesLHS... > lhs, indexed_dynamic_tensor< TensorRHS, IndicesRHS... > rhs)
Definition: operator_overloads.h:15
auto operator+(indexed_static_tensor< TensorLHS, IndicesLHS... > lhs, indexed_static_tensor< TensorRHS, IndicesRHS... > rhs)
Definition: operator_overloads.h:93
auto operator*(indexed_dynamic_tensor< TensorLHS, IndicesLHS... > lhs, indexed_dynamic_tensor< TensorRHS, IndicesRHS... > rhs)
Definition: operator_overloads.h:24
auto constexpr index(handle< Child, Int > const h)
Definition: handle.h:119
Definition: added_contracted_static_tensor.h:7
Definition: contracted_dynamic_tensor.h:9
Definition: contracted_static_tensor.h:9
Definition: indexed_dynamic_tensor.h:28
Definition: indexed_static_tensor.h:22