7 template <
class T,
int Dim0,
int Dim1,
int Dim2,
int Dim3,
int Current_Dim0,
8 int Current_Dim1,
int Current_Dim2,
int Current_Dim3>
20 template <
class T,
int Dim0,
int Dim1,
int Dim2,
int Dim3,
int Current_Dim1,
21 int Current_Dim2,
int Current_Dim3>
33 template <
class T,
int Dim0,
int Dim1,
int Dim2,
int Dim3,
int Current_Dim2,
46 template <
class T,
int Dim0,
int Dim1,
int Dim2,
int Dim3,
int Current_Dim3>
57 template <
class T,
int Dim0,
int Dim1,
int Dim2,
int Dim3>
65 template <
class T,
int Tensor_Dim0,
int Tensor_Dim1,
int Tensor_Dim2,
67 class Tensor4<T *, Tensor_Dim0, Tensor_Dim1, Tensor_Dim2, Tensor_Dim3>
73 data[Tensor_Dim0][Tensor_Dim1][Tensor_Dim2][Tensor_Dim3];
76 Tensor4(T *d0000, T *d0001, T *d0010, T *d0011, T *d0100, T *d0101,
77 T *d0110, T *d0111, T *d1000, T *d1001, T *d1010, T *d1011,
78 T *d1100, T *d1101, T *d1110, T *d1111,
const int i = 1)
83 data, d0000, d0001, d0010, d0011, d0100, d0101, d0110, d0111, d1000,
84 d1001, d1010, d1011, d1100, d1101, d1110, d1111);
87 Tensor4(T *d0000, T *d0001, T *d0002, T *d0010, T *d0011, T *d0012,
88 T *d0020, T *d0021, T *d0022, T *d0100, T *d0101, T *d0102,
89 T *d0110, T *d0111, T *d0112, T *d0120, T *d0121, T *d0122,
90 T *d0200, T *d0201, T *d0202, T *d0210, T *d0211, T *d0212,
91 T *d0220, T *d0221, T *d0222, T *d1000, T *d1001, T *d1002,
92 T *d1010, T *d1011, T *d1012, T *d1020, T *d1021, T *d1022,
93 T *d1100, T *d1101, T *d1102, T *d1110, T *d1111, T *d1112,
94 T *d1120, T *d1121, T *d1122, T *d1200, T *d1201, T *d1202,
95 T *d1210, T *d1211, T *d1212, T *d1220, T *d1221, T *d1222,
96 T *d2000, T *d2001, T *d2002, T *d2010, T *d2011, T *d2012,
97 T *d2020, T *d2021, T *d2022, T *d2100, T *d2101, T *d2102,
98 T *d2110, T *d2111, T *d2112, T *d2120, T *d2121, T *d2122,
99 T *d2200, T *d2201, T *d2202, T *d2210, T *d2211, T *d2212,
100 T *d2220, T *d2221, T *d2222,
const int i = 1)
105 data, d0000, d0001, d0002, d0010, d0011, d0012, d0020, d0021, d0022,
106 d0100, d0101, d0102, d0110, d0111, d0112, d0120, d0121, d0122, d0200,
107 d0201, d0202, d0210, d0211, d0212, d0220, d0221, d0222, d1000, d1001,
108 d1002, d1010, d1011, d1012, d1020, d1021, d1022, d1100, d1101, d1102,
109 d1110, d1111, d1112, d1120, d1121, d1122, d1200, d1201, d1202, d1210,
110 d1211, d1212, d1220, d1221, d1222, d2000, d2001, d2002, d2010, d2011,
111 d2012, d2020, d2021, d2022, d2100, d2101, d2102, d2110, d2111, d2112,
112 d2120, d2121, d2122, d2200, d2201, d2202, d2210, d2211, d2212, d2220,
119 for (
int i = 0;
i != Tensor_Dim0; ++
i)
121 for (
int j = 0;
j != Tensor_Dim1; ++
j)
123 for (
int k = 0;
k != Tensor_Dim2; ++
k)
125 for (
int l = 0;
l != Tensor_Dim3; ++
l)
127 data[
i][
j][
k][
l] = &
d[s];
141 T &
operator()(
const int N1,
const int N2,
const int N3,
const int N4)
144 if (N1 >= Tensor_Dim0 || N1 < 0 || N2 >= Tensor_Dim1 || N2 < 0 || N3 >= Tensor_Dim2 || N3 < 0 || N4 >= Tensor_Dim3 || N4 < 0)
147 s <<
"Bad index in Tensor4<T," << Tensor_Dim0 <<
"," << Tensor_Dim1
148 <<
"," << Tensor_Dim2 <<
"," << Tensor_Dim3 <<
">.operator(" << N1
149 <<
"," << N2 <<
"," << N3 <<
"," << N4 <<
") const" << std::endl;
150 throw std::runtime_error(s.str());
153 return *data[N1][N2][N3][N4];
156 T
operator()(
const int N1,
const int N2,
const int N3,
const int N4)
const
159 if (N1 >= Tensor_Dim0 || N1 < 0 || N2 >= Tensor_Dim1 || N2 < 0 || N3 >= Tensor_Dim2 || N3 < 0 || N4 >= Tensor_Dim3 || N4 < 0)
162 s <<
"Bad index in Tensor4<T," << Tensor_Dim0 <<
"," << Tensor_Dim1
163 <<
"," << Tensor_Dim2 <<
"," << Tensor_Dim3 <<
">.operator(" << N1
164 <<
"," << N2 <<
"," << N3 <<
"," << N4 <<
") const" << std::endl;
165 throw std::runtime_error(s.str());
168 return *data[N1][N2][N3][N4];
176 template <
char i,
char j,
char k,
char l,
int Dim0,
int Dim1,
int Dim2,
180 Dim0, Dim1, Dim2, Dim3,
i,
j,
k,
l>
186 Dim0, Dim1, Dim2, Dim3,
i,
j,
k,
l>(*this);
189 template <
char i,
char j,
char k,
char l,
int Dim0,
int Dim1,
int Dim2,
193 T, Dim0, Dim1, Dim2, Dim3,
i,
j,
k,
l>
199 T, Dim0, Dim1, Dim2, Dim3,
i,
j,
k,
l>(*this);
205 template <
int Current_Dim0,
int Current_Dim1,
int Current_Dim2,
211 data[Current_Dim0 - 1][Current_Dim1 - 1][Current_Dim2 - 1]
212 [Current_Dim3 - 1] += inc;
222 T *
ptr(
const int N1,
const int N2,
const int N3,
const int N4)
const
225 if (N1 >= Tensor_Dim0 || N1 < 0 || N2 >= Tensor_Dim1 || N2 < 0 ||
226 N3 >= Tensor_Dim2 || N3 < 0 || N4 >= Tensor_Dim3 || N4 < 0)
229 s <<
"Bad index in Tensor4<T*," << Tensor_Dim0 <<
"," << Tensor_Dim1
230 <<
"," << Tensor_Dim2 <<
"," << Tensor_Dim3 <<
">.ptr(" << N1 <<
","
231 << N2 <<
"," << N3 <<
"," << N4 <<
")" << std::endl;
232 throw std::out_of_range(s.str());
235 return data[N1][N2][N3][N4];
238 T *restrict &
ptr(
const int N1,
const int N2,
const int N3,
const int N4)
241 if (N1 >= Tensor_Dim0 || N1 < 0 || N2 >= Tensor_Dim1 || N2 < 0 ||
242 N3 >= Tensor_Dim2 || N3 < 0 || N4 >= Tensor_Dim3 || N4 < 0)
245 s <<
"Bad index in Tensor4<T*," << Tensor_Dim0 <<
"," << Tensor_Dim1
246 <<
"," << Tensor_Dim2 <<
"," << Tensor_Dim3 <<
">.ptr(" << N1 <<
","
247 << N2 <<
"," << N3 <<
"," << N4 <<
")" << std::endl;
248 throw std::out_of_range(s.str());
251 return data[N1][N2][N3][N4];
257 Tensor_Dim2, Tensor_Dim3> &) =
delete;
260 template <
class T,
int Tensor_Dim0,
int Tensor_Dim1,
int Tensor_Dim2,
261 int Tensor_Dim3,
int I>
263 Tensor_Dim3> :
public Tensor4<T *, Tensor_Dim0, Tensor_Dim1,
264 Tensor_Dim2, Tensor_Dim3>
269 :
Tensor4<T *, Tensor_Dim0, Tensor_Dim1, Tensor_Dim2, Tensor_Dim3>(
272 template <
class...
U>
274 :
Tensor4<T *, Tensor_Dim0, Tensor_Dim1, Tensor_Dim2, Tensor_Dim3>(
280 template <
int Current_Dim0,
int Current_Dim1,
int Current_Dim2,
287 Tensor4<T *, Tensor_Dim0, Tensor_Dim1, Tensor_Dim2,
288 Tensor_Dim3>::data[Current_Dim0 - 1][Current_Dim1 - 1]
289 [Current_Dim2 - 1][Current_Dim3 - 1] +=
I;