6 template <
class T,
int Dim0,
int Dim1,
int Dim2,
int Current_Dim0,
7 int Current_Dim1,
int Current_Dim2>
18 template <
class T,
int Dim0,
int Dim1,
int Dim2,
int Current_Dim1,
28 template <
class T,
int Dim0,
int Dim1,
int Dim2,
int Current_Dim2>
37 template <
class T,
int Dim0,
int Dim1,
int Dim2>
44 template <
class T,
int Tensor_Dim0,
int Tensor_Dim1,
int Tensor_Dim2>
45 class Tensor3<T *, Tensor_Dim0, Tensor_Dim1, Tensor_Dim2> {
49 mutable T *restrict data[Tensor_Dim0][Tensor_Dim1][Tensor_Dim2];
55 Tensor3(T *d000, T *d001, T *d010, T *d011, T *d100, T *d101, T *d110,
59 data, d000, d001, d010, d011, d100, d101, d110, d111);
63 Tensor3(T *d000, T *d001, T *d002, T *d010, T *d011, T *d012, T *d020,
64 T *d021, T *d022, T *d100, T *d101, T *d102, T *d110, T *d111,
65 T *d112, T *d120, T *d121, T *d122, T *d200, T *d201, T *d202,
66 T *d210, T *d211, T *d212, T *d220, T *d221, T *d222,
const int i)
69 data, d000, d001, d002, d010, d011, d012, d020, d021, d022, d100, d101,
70 d102, d110, d111, d112, d120, d121, d122, d200, d201, d202, d210, d211,
71 d212, d220, d221, d222);
75 Tensor3(T *d000, T *d001, T *d002, T *d003, T *d010, T *d011, T *d012,
76 T *d013, T *d020, T *d021, T *d022, T *d023, T *d030, T *d031,
79 T *d100, T *d101, T *d102, T *d103, T *d110, T *d111, T *d112,
80 T *d113, T *d120, T *d121, T *d122, T *d123, T *d130, T *d131,
83 T *d200, T *d201, T *d202, T *d203, T *d210, T *d211, T *d212,
84 T *d213, T *d220, T *d221, T *d222, T *d223, T *d230, T *d231,
87 T *d300, T *d301, T *d302, T *d303, T *d310, T *d311, T *d312,
88 T *d313, T *d320, T *d321, T *d322, T *d323, T *d330, T *d331,
89 T *d332, T *d333,
const int i)
92 data, d000, d001, d002, d003, d010, d011, d012, d013, d020, d021, d022,
93 d023, d030, d031, d032, d033,
95 d100, d101, d102, d103, d110, d111, d112, d113, d120, d121, d122, d123,
96 d130, d131, d132, d133,
98 d200, d201, d202, d203, d210, d211, d212, d213, d220, d221, d222, d223,
99 d230, d231, d232, d233,
101 d300, d301, d302, d303, d310, d311, d312, d313, d320, d321, d322, d323,
102 d330, d331, d332, d333);
109 Tensor3(std::array<U *, Tensor_Dim0 * Tensor_Dim1 * Tensor_Dim2> &
a,
113 for (
int i = 0;
i != Tensor_Dim0; ++
i) {
114 for (
int j = 0;
j != Tensor_Dim1; ++
j) {
115 for (
int k = 0;
k != Tensor_Dim2; ++
k, ++
l) {
116 data[
i][
j][
k] =
a[
l];
127 if (N1 >= Tensor_Dim0 || N1 < 0 || N2 >= Tensor_Dim1 || N2 < 0 ||
128 N3 >= Tensor_Dim2 || N3 < 0) {
130 s <<
"Bad index in Tensor3<T," << Tensor_Dim0 <<
"," << Tensor_Dim1 <<
","
131 << Tensor_Dim2 <<
">.operator(" << N1 <<
"," << N2 <<
"," << N3 <<
")"
133 throw std::runtime_error(s.str());
136 return *data[N1][N2][N3];
139 T
operator()(
const int N1,
const int N2,
const int N3)
const {
141 if (N1 >= Tensor_Dim0 || N1 < 0 || N2 >= Tensor_Dim1 || N2 < 0 ||
142 N3 >= Tensor_Dim2 || N3 < 0) {
144 s <<
"Bad index in Tensor3<T," << Tensor_Dim0 <<
"," << Tensor_Dim1 <<
","
145 << Tensor_Dim2 <<
">.operator(" << N1 <<
"," << N2 <<
"," << N3
146 <<
") const" << std::endl;
147 throw std::runtime_error(s.str());
150 return *data[N1][N2][N3];
156 template <
char i,
char j,
char k,
int Dim0,
int Dim1,
int Dim2>
161 Dim0, Dim1, Dim2,
i,
j,
k>(*this);
164 template <
char i,
char j,
char k,
int Dim0,
int Dim1,
int Dim2>
166 Dim0, Dim1, Dim2,
i,
j,
k>
171 Dim1, Dim2,
i,
j,
k>(*this);
177 template <
int Current_Dim0,
int Current_Dim1,
int Current_Dim2>
181 data[Current_Dim0 - 1][Current_Dim1 - 1][Current_Dim2 - 1] += inc;
196 template <
class T,
int Tensor_Dim0,
int Tensor_Dim1,
int Tensor_Dim2,
int I>
204 template <
class...
U>
206 :
Tensor3<T *, Tensor_Dim0, Tensor_Dim1, Tensor_Dim2>{
d...} {}
209 Tensor3(std::array<U *, Tensor_Dim0 * Tensor_Dim1 * Tensor_Dim2> &
a)
210 :
Tensor3<T *, Tensor_Dim0, Tensor_Dim1, Tensor_Dim2>(
a) {}
215 template <
int Current_Dim0,
int Current_Dim1,
int Current_Dim2>
219 Tensor3<T *, Tensor_Dim0, Tensor_Dim1,
220 Tensor_Dim2>::data[Current_Dim0 - 1][Current_Dim1 - 1]
221 [Current_Dim2 - 1] +=
I;