15 T
data[(Tensor_Dim * (Tensor_Dim + 1)) / 2];
20 static_assert(
sizeof...(
d) ==
sizeof(
data) /
sizeof(T),
21 "Incorrect number of Arguments. Constructor should "
22 "initialize the entire Tensor");
33 if(N1 >= Tensor_Dim || N1 < 0 || N2 >= Tensor_Dim || N2 < 0)
36 s <<
"Bad index in Tensor2_symmetric<T," << Tensor_Dim
37 <<
">.operator(" << N1 <<
"," << N2 <<
")" << std::endl;
38 throw std::out_of_range(s.str());
41 return N1 > N2 ?
data[N1 + (N2 * (2 * Tensor_Dim - N2 - 1)) / 2]
42 :
data[N2 + (N1 * (2 * Tensor_Dim - N1 - 1)) / 2];
48 if(N1 >= Tensor_Dim || N1 < 0 || N2 >= Tensor_Dim || N2 < 0)
51 s <<
"Bad index in Tensor2_symmetric<T," << Tensor_Dim
52 <<
">.operator(" << N1 <<
"," << N2 <<
") const" << std::endl;
53 throw std::out_of_range(s.str());
56 return N1 > N2 ?
data[N1 + (N2 * (2 * Tensor_Dim - N2 - 1)) / 2]
57 :
data[N2 + (N1 * (2 * Tensor_Dim - N1 - 1)) / 2];
60 template <
int N1,
int N2>
63 static_assert(N1 < Tensor_Dim,
"Bad index");
64 static_assert(N2 < Tensor_Dim,
"Bad index");
66 if constexpr (N1 > N2)
67 return data[N1 + (N2 * (2 * Tensor_Dim - N2 - 1)) / 2];
69 return data[N2 + (N1 * (2 * Tensor_Dim - N1 - 1)) / 2];
72 template <
int N1,
int N2>
75 static_assert(N1 < Tensor_Dim,
"Bad index");
76 static_assert(N2 < Tensor_Dim,
"Bad index");
78 if constexpr (N1 > N2)
79 return data[N1 + (N2 * (2 * Tensor_Dim - N2 - 1)) / 2];
81 return data[N2 + (N1 * (2 * Tensor_Dim - N1 - 1)) / 2];
92 template <
char i,
char j,
int Dim0,
int Dim1>
94 (Tensor_Dim >= Dim0 && Tensor_Dim >= Dim1),
102 template <
char i,
char j,
int Dim0,
int Dim1>
103 typename std::enable_if<(Tensor_Dim >= Dim0 && Tensor_Dim >= Dim1),
105 T, Dim0, Dim1,
i,
j>>::
type
115 template <
char i,
char j,
int Dim>
125 template <
char i,
char j,
int Dim>
143 template <
char i,
int N,
int Dim>
145 (Tensor_Dim >= Dim && Tensor_Dim >
N),
155 template <
char i,
int N,
int Dim>
157 (Tensor_Dim >= Dim && Tensor_Dim >
N),
167 template <
char i,
int N,
int Dim>
169 (Tensor_Dim >
N && Tensor_Dim >= Dim),
179 template <
char i,
int N,
int Dim>
181 (Tensor_Dim >
N && Tensor_Dim >= Dim),
193 template <
char i,
int Dim>
205 template <
char i,
int Dim>
222 template <
char i,
int Dim>
229 template <
char i,
int Dim>
239 return data[
N - 1 + ((
N - 1) * (2 * Tensor_Dim -
N)) / 2]
252 template <
class T,
int Tensor_Dim>
258 for(
int j =
i;
j + 1 < Tensor_Dim; ++
j)
260 os <<
t(
i,
j) <<
',';
264 os <<
t(
i, Tensor_Dim - 1);
270 template <
class T,
int Tensor_Dim>
274 for (
int i = 0;
i + 1 < Tensor_Dim; ++
i) {
278 if (Tensor_Dim > 0) {
288 template <
class T,
int Tensor_Dim>
296 for(
int j =
i;
j + 1 < Tensor_Dim; ++
j)
302 is >>
t(
i, Tensor_Dim - 1);
308 template <
class T,
int Tensor_Dim>
313 for (
int i = 0;
i + 1 < Tensor_Dim; ++
i) {
317 if (Tensor_Dim > 0) {