18 template<
int shape_dim_,
int cell_dim_>
19 struct StructIndexCoding;
23 struct StructIndexCoding<1, 0>
27 static Index encode(
const Index v[],
const Index [])
32 static void decode(Index v[],
const Index i,
const Index [])
40 struct StructIndexCoding<2, 0>
46 static Index encode(
const Index v[],
const Index n[])
48 return v[0] + (n[0] +
Index(1)) * v[1];
51 static void decode(Index v[],
const Index i,
const Index n[])
53 v[0] = i % (n[0] +
Index(1));
54 v[1] = i / (n[0] +
Index(1));
60 struct StructIndexCoding<3, 0>
68 static Index encode(
const Index v[],
const Index n[])
70 return v[0] + (n[0] +
Index(1)) * (v[1] + (n[1] +
Index(1)) * v[2]);
73 static void decode(Index v[],
const Index i,
const Index n[])
75 v[0] = i % ((n[0] +
Index(1)) * (n[1] +
Index(1)));
76 v[1] = (i / (n[0] +
Index(1))) % (n[1] +
Index(1));
77 v[2] = i / ((n[0] +
Index(1)) * (n[1] +
Index(1)));
83 struct StructIndexCoding<1, 1>
87 static Index encode(
const Index v[],
const Index [])
92 static void decode(Index v[],
const Index i,
const Index [])
100 struct StructIndexCoding<2, 1>
107 static Index encode(
const Index v[],
const Index n[])
110 return v[0] + n[0] * v[1];
112 return v[1] + n[1] * v[0] + n[0]*(n[1]+
Index(1));
115 static void decode(Index v[],
const Index i,
const Index n[])
117 if(i < n[0] * (n[1] +
Index(1)))
127 const Index j = (i - n[0] * (n[1] +
Index(1)));
139 struct StructIndexCoding<2, 2>
145 static Index encode(
const Index v[],
const Index n[])
147 return v[0] + n[0] * v[1];
150 static void decode(Index v[],
const Index i,
const Index n[])
161 struct StructIndexCoding<3, 3>
169 static Index encode(
const Index v[],
const Index n[])
171 return v[0] + n[0] * (v[1] + n[1] * v[2]);
174 static void decode(Index v[],
const Index i,
const Index n[])
176 v[0] = i % (n[0] * n[1]);
177 v[1] = (i / n[0]) % (n[1]);
178 v[2] = i / (n[0] * n[1]);
std::size_t encode(void *buf, const T_ *src, const std::size_t buf_size, const std::size_t count, const Pack::Type pack_type, bool swap_bytes, double tolerance)
Encodes an array into a packed buffer.
std::size_t decode(T_ *dst, void *buf, const std::size_t count, const std::size_t buf_size, const Pack::Type pack_type, bool swap_bytes)
Decodes an array from a packed buffer.
std::uint64_t Index
Index data type.