11 template <
class T,
int Tensor_Dim0,
int Tensor_Dim1,
int Tensor_Dim2>
14 T
data[Tensor_Dim0][Tensor_Dim1][Tensor_Dim2];
19 static_assert(
sizeof...(
d) ==
sizeof(
data) /
sizeof(T),
20 "Incorrect number of Arguments. Constructor should "
21 "initialize the entire Tensor");
32 if(N1 >= Tensor_Dim0 || N1 < 0 || N2 >= Tensor_Dim1 || N2 < 0
33 || N3 >= Tensor_Dim2 || N3 < 0)
36 s <<
"Bad index in Tensor3<T," << Tensor_Dim0 <<
"," << Tensor_Dim1
37 <<
"," << Tensor_Dim2 <<
">.operator(" << N1 <<
"," << N2 <<
","
38 << N3 <<
")" << std::endl;
39 throw std::out_of_range(s.str());
42 return data[N1][N2][N3];
45 T
operator()(
const int N1,
const int N2,
const int N3)
const
48 if(N1 >= Tensor_Dim0 || N1 < 0 || N2 >= Tensor_Dim1 || N2 < 0
49 || N3 >= Tensor_Dim2 || N3 < 0)
52 s <<
"Bad index in Tensor3<T," << Tensor_Dim0 <<
"," << Tensor_Dim1
53 <<
"," << Tensor_Dim2 <<
">.operator(" << N1 <<
"," << N2 <<
","
54 << N3 <<
") const" << std::endl;
55 throw std::out_of_range(s.str());
58 return data[N1][N2][N3];
64 template <
char i,
char j,
char k,
int Dim0,
int Dim1,
int Dim2>
66 (Tensor_Dim0 >= Dim0 && Tensor_Dim1 >= Dim1 && Tensor_Dim2 >= Dim2),
73 Dim0, Dim1, Dim2,
i,
j,
k>(*this);
76 template <
char i,
char j,
char k,
int Dim0,
int Dim1,
int Dim2>
78 (Tensor_Dim0 >= Dim0 && Tensor_Dim1 >= Dim1 && Tensor_Dim2 >= Dim2),
80 Dim0, Dim1, Dim2,
i,
j,
k>>::
type
86 Dim2,
i,
j,
k>(*this);
96 template <
char i,
char j,
int Dim>
98 (Tensor_Dim0 >= Dim && Tensor_Dim1 >= Dim && Tensor_Dim2 >= Dim),
113 template <
char i,
char j,
int Dim>
115 (Tensor_Dim0 >= Dim && Tensor_Dim1 >= Dim && Tensor_Dim2 >= Dim),
130 template <
char i,
char j,
int Dim,
int Dim2>
132 (Tensor_Dim0 >= Dim && Tensor_Dim1 >= Dim && Tensor_Dim2 >= Dim2),
153 template <
char i,
char j,
int N,
int Dim1,
int Dim2>
155 (Tensor_Dim0 >
N && Tensor_Dim1 >= Dim1 && Tensor_Dim2 >= Dim2),
158 T, Dim1, Dim2,
i,
j>>::
type
166 template <
char i,
char j,
int N,
int Dim1,
int Dim2>
168 (Tensor_Dim0 >
N && Tensor_Dim1 >= Dim1 && Tensor_Dim2 >= Dim2),
172 T, Dim1, Dim2,
i,
j>>::
type
183 template <
char i,
char j,
int N,
int Dim0,
int Dim2>
185 (Tensor_Dim0 >= Dim0 && Tensor_Dim1 >
N && Tensor_Dim2 >= Dim2),
188 T, Dim0, Dim2,
i,
j>>::
type
196 template <
char i,
char j,
int N,
int Dim0,
int Dim2>
198 (Tensor_Dim0 >= Dim0 && Tensor_Dim1 >
N && Tensor_Dim2 >= Dim2),
202 T, Dim0, Dim2,
i,
j>>::
type
213 template <
char i,
char j,
int N,
int Dim>
215 (Tensor_Dim0 >= Dim && Tensor_Dim1 >= Dim && Tensor_Dim2 >
N),
227 template <
char i,
char j,
int N,
int Dim>
229 (Tensor_Dim0 >= Dim && Tensor_Dim1 >= Dim && Tensor_Dim2 >
N),
249 template <
char i,
int N1,
int N2,
int Dim>
251 (Tensor_Dim0 >= Dim && Tensor_Dim1 > N1 && Tensor_Dim2 > N2),
263 template <
char i,
int N1,
int N2,
int Dim>
265 (Tensor_Dim0 >= Dim && Tensor_Dim1 > N1 && Tensor_Dim2 > N2),
282 template <
char i,
int N0,
int N2,
int Dim>
284 (Tensor_Dim0 > N0 && Tensor_Dim1 >= Dim && Tensor_Dim2 > N2),
296 template <
char i,
int N0,
int N2,
int Dim>
298 (Tensor_Dim0 > N0 && Tensor_Dim1 >= Dim && Tensor_Dim2 > N2),
313 template <
char i,
int N0,
int N1,
int Dim>
315 (Tensor_Dim0 > N0 && Tensor_Dim1 > N1 && Tensor_Dim2 >= Dim),
327 template <
char i,
int N0,
int N1,
int Dim>
329 (Tensor_Dim0 > N0 && Tensor_Dim1 > N1 && Tensor_Dim2 >= Dim),
349 template <
char i,
char j,
int Dim1,
int Dim2>
351 (Tensor_Dim1 >= Dim1 && Tensor_Dim2 >= Dim2),
354 T, Dim1, Dim2,
i,
j>>::
type
360 TensorExpr(*
this,
N));
365 template <
char i,
char j,
int Dim0,
int Dim2>
367 (Tensor_Dim0 >= Dim0 && Tensor_Dim2 >= Dim2),
370 T, Dim0, Dim2,
i,
j>>::
type
376 TensorExpr(*
this,
N));
381 template <
char i,
char j,
int Dim>
383 (Tensor_Dim0 >= Dim && Tensor_Dim1 >= Dim),
393 TensorExpr(*
this,
N));
401 template <
char i,
int Dim>
403 (Tensor_Dim0 >= Dim),
418 template <
char i,
int Dim>
420 (Tensor_Dim1 >= Dim),
433 template <
char i,
int Dim>
435 (Tensor_Dim2 >= Dim),
453 template <
class T,
int Tensor_Dim0,
int Tensor_Dim1,
int Tensor_Dim2>
457 const int &
i,
const int &
j)
460 for(
int k = 0;
k + 1 < Tensor_Dim2; ++
k)
462 os <<
t(
i,
j,
k) <<
',';
466 os <<
t(
i,
j, Tensor_Dim2 - 1);
472 template <
class T,
int Tensor_Dim0,
int Tensor_Dim1,
int Tensor_Dim2>
479 for(
int j = 0;
j + 1 < Tensor_Dim1; ++
j)
493 template <
class T,
int Tensor_Dim0,
int Tensor_Dim1,
int Tensor_Dim2>
499 for(
int i = 0;
i + 1 < Tensor_Dim0; ++
i)
522 template <
class T,
int Tensor_Dim0,
int Tensor_Dim1,
int Tensor_Dim2>
526 const int &
i,
const int &
j)
530 for(
int k = 0;
k + 1 < Tensor_Dim2; ++
k)
532 is >>
t(
i,
j,
k) >>
c;
536 is >>
t(
i,
j, Tensor_Dim2 - 1);
542 template <
class T,
int Tensor_Dim0,
int Tensor_Dim1,
int Tensor_Dim2>
550 for(
int j = 0;
j + 1 < Tensor_Dim1; ++
j)
564 template <
class T,
int Tensor_Dim0,
int Tensor_Dim1,
int Tensor_Dim2>
571 for(
int i = 0;
i + 1 < Tensor_Dim0; ++
i)