20 template <
typename GF2E_Element>
27 dbsize_t nrows = this->num_rows / 2;
28 dbsize_t ncols = this->num_cols / 2;
36 template <
typename GF2E_Element>
40 this->num_cols * this->num_rows *
sizeof(GF2E_Element));
43 template <
typename GF2E_Element>
49 GF2E_Element * dst = this->data;
50 const GF2E_Element * src1 = sub1.first();
51 const GF2E_Element * src2 = sub2.first();
53 size_t nc_bytes = sub1.num_cols *
sizeof(GF2E_Element);
55 for(
unsigned int row = 0; row < sub1.num_rows; ++row) {
56 XOR_memblocks((
unsigned char*) dst,
57 (
const unsigned char*) src1,
58 (
const unsigned char*) src2, nc_bytes);
61 src1 += sub1.matrix.num_cols;
62 src2 += sub2.matrix.num_cols;
66 template <
typename GF2E_Element>
70 const GF2E_Element *src = other.first();
71 GF2E_Element *dst = this->data;
72 for(
unsigned int row = 0; row < other.num_rows; ++row) {
73 memcpy((
void *) dst, (
const void *) src,
74 other.num_cols *
sizeof(GF2E_Element));
75 dst += this->num_cols;
76 src += other.matrix.num_cols;
80 template <
typename GF2E_Element>
85 for(
unsigned int r = 0; r < m.num_rows; ++r) {
86 for(
unsigned int c = 0; c < m.num_cols; ++c) {
88 (int) *(m.data + r * m.num_cols + c);
96 template <
typename GF2E_Element>
100 GF2E_Element *dst = this->first();
101 GF2E_Element *src = m.data;
103 size_t nc_bytes = this->num_cols *
sizeof(GF2E_Element);
105 for(
unsigned int row = 0; row < this->num_rows; ++row) {
106 XOR_equal((
unsigned char *)dst, (
const unsigned char*)src,
108 dst += this->matrix.num_cols;
114 template <
typename GF2E_Element>
118 GF2E_Element *data = m.matrix.data;
119 dbsize_t num_cols = m.matrix.num_cols;
122 for(dbsize_t r = m.row; r < m.num_rows + m.row; ++r) {
123 for(dbsize_t c = m.col; c < m.num_cols + m.col; ++c) {
124 os <<
" " << hex << (int) *(data + r * num_cols + c);
132 template <
typename GF2E_Element>
134 get(dbsize_t row, dbsize_t col)
const
136 return this->matrix.data +
137 this->matrix.num_cols * (this->row + row) + (this->col + col);
140 template <
typename GF2E_Element>
144 return this->matrix.data +
145 this->matrix.num_cols * this->row + this->col;
148 template <
typename GF2E_Element>
155 template <
typename GF2E_Element>
161 template <
typename GF2E_Element>
173 const GF28_Element *row = row_a.first();
174 const GF28_Element *block = mat_b.first();
176 GF28_Element *oc_start = this->first();
177 GF28_Element *oc_end = this->
get(mat_b.num_cols & ~7);
179 const GF28_Element *multrow;
180 const GF28_Element *blockc;
183 for (
unsigned int j = 0; j < row_a.num_cols; ++j) {
184 multrow = GF28_mult_table[row[j]];
188 while (oc < oc_end) {
189 uint64_t accum = (uint64_t) multrow[*(blockc++)];
190 accum |= (uint64_t) multrow[*(blockc++)] << 8;
191 accum |= (uint64_t) multrow[*(blockc++)] << 16;
192 accum |= (uint64_t) multrow[*(blockc++)] << 24;
193 accum |= (uint64_t) multrow[*(blockc++)] << 32;
194 accum |= (uint64_t) multrow[*(blockc++)] << 40;
195 accum |= (uint64_t) multrow[*(blockc++)] << 48;
196 accum |= (uint64_t) multrow[*(blockc++)] << 56;
197 *((uint64_t *) oc) ^= accum;
200 for (
unsigned int c = 0; c < (mat_b.num_cols & 7); ++c) {
201 *(oc++) ^= multrow[*(blockc++)];
204 block += mat_b.matrix.num_cols;
213 const GF216_Element *row = row_a.first();
214 const GF216_Element *block = mat_b.first();
217 GF216_Element *oc_start = this->first();
218 GF216_Element *oc_end = this->
get(mat_b.num_cols & ~3);
219 for (dbsize_t j = 0; j < row_a.num_cols; ++j) {
220 GF216_Element inpv_j = row[j];
222 const GF216_Element *blockc = block;
223 GF216_Element log_j = GF216_log_table[inpv_j];
224 const GF216_Element *start = GF216_exp_table + log_j;
226 GF216_Element block_c;
229 block_c = *(blockc++);
231 GF216_Element log_c = GF216_log_table[block_c];
232 accum |= (uint64_t) start[log_c];
234 block_c = *(blockc++);
236 GF216_Element log_c = GF216_log_table[block_c];
237 accum |= (uint64_t) start[log_c] << 16;
239 block_c = *(blockc++);
241 GF216_Element log_c = GF216_log_table[block_c];
242 accum |= (uint64_t) start[log_c] << 32;
244 block_c = *(blockc++);
246 GF216_Element log_c = GF216_log_table[block_c];
247 accum |= (uint64_t) start[log_c] << 48;
249 *((uint64_t *) oc) ^= accum;
252 for (dbsize_t c = 0; c < (mat_b.num_cols & 3); ++c, ++oc) {
253 block_c = *(blockc++);
255 GF216_Element log_c = GF216_log_table[block_c];
260 block += mat_b.matrix.num_cols;
264 template <
typename GF2E_Element>
270 for(r = 0; r < mat_a.num_rows; ++r) {
271 GF2E_Element *res =
get(r);
272 for(c = 0; c < mat_a.num_cols; ++c) {
274 multiply_GF2E(*mat_a.get(r,c), *col_b.get(c));
279 template <
typename GF2E_Element>
284 GF2E_Element *acc = this->first();
286 const GF2E_Element *a_ptr = row_a.first();
287 const GF2E_Element *b_ptr = col_b.first();
288 const GF2E_Element *a_end = row_a.get(row_a.num_cols);
290 while(a_ptr < a_end) {
291 *acc ^= multiply_GF2E(*(a_ptr++), *b_ptr);
292 b_ptr += col_b.matrix.num_cols;
301 const GF28_Element *row_start = row_b.first();
303 const GF28_Element *multcol;
304 const GF28_Element *row;
305 GF28_Element *oc, *oc_end;
307 for (dbsize_t r = 0; r < col_a.num_rows; ++r) {
308 multcol = GF28_mult_table[*col_a.get(r)];
311 oc_end = this->
get(r,row_b.num_cols);
315 *(oc++) ^= multcol[*(row++)];
325 const GF216_Element *row;
326 const GF216_Element *row_start = row_b.first();
327 GF216_Element row_elem;
329 GF216_Element col_elem;
331 const GF216_Element *start_c;
333 GF216_Element *oc, *oc_end;
335 for (dbsize_t r = 0; r < col_a.num_rows; ++r) {
336 col_elem = *col_a.get(r);
340 oc_end = this->
get(r,row_b.num_cols);
342 log_c = GF216_log_table[col_elem];
343 start_c = GF216_exp_table + log_c;
350 *oc ^= start_c[GF216_log_table[row_elem]];
364 const GF28_Element *mult = GF28_mult_table[*elem_b.first()];
366 const GF28_Element *col = col_a.first();
367 GF28_Element *oc, *oc_end;
370 oc_end = this->
get(col_a.num_rows);
374 oc += this->matrix.num_cols;
375 col += col_a.matrix.num_cols;
384 GF216_Element b = *elem_b.first();
387 const GF216_Element log_mult = GF216_log_table[b];
388 const GF216_Element *start_mult = GF216_exp_table + log_mult;
390 const GF216_Element *col = col_a.first();
391 GF216_Element *oc, *oc_end;
394 oc_end = this->
get(col_a.num_rows);
398 *oc ^= start_mult[GF216_log_table[*col]];
401 oc += this->matrix.num_cols;
402 col += col_a.matrix.num_cols;
407 template <
typename GF2E_Element>
412 *this->first() ^= multiply_GF2E(*elem_a.first(), *elem_b.first());
std::ostream & operator<<(std::ostream &os, PercyMode mode)
Prints a PercyMode string to a stream.
Definition: gf2e_matrix.h:110
Definition: old_matrix.h:28
Definition: gf2e_matrix.h:129
Definition: gf2e_matrix.h:95
Definition: old_matrix.h:33
Definition: old_matrix.h:29
Definition: gf2e_matrix.h:31
Definition: old_matrix.h:30
Definition: old_matrix.h:27
Definition: gf2e_matrix.h:61