18 template <
typename Element>
20 dbsize_t num_rows, dbsize_t num_cols)
29 template <
typename Element>
36 dbsize_t nrows = this->num_rows / 2;
37 dbsize_t ncols = this->num_cols / 2;
45 template <
typename Element>
49 this->num_cols * this->num_rows *
sizeof(Element));
52 template <
typename Element>
57 Element * dst = this->data;
58 const Element * src1 = sub1.first();
59 const Element * src2 = sub2.first();
61 size_t nc_bytes = sub1.num_cols *
sizeof(Element);
63 for(
unsigned int row = 0; row < sub1.num_rows; ++row) {
64 XOR_unequal((
unsigned char*) dst,
65 (
const unsigned char*) src1,
66 (
const unsigned char*) src2, nc_bytes);
69 src1 += sub1.matrix.num_cols;
70 src2 += sub2.matrix.num_cols;
74 template <
typename Element>
77 const Element *src = other.first();
78 Element *dst = this->data;
79 for(
unsigned int row = 0; row < other.num_rows; ++row) {
80 memcpy((
void *) dst, (
const void *) src,
81 other.num_cols *
sizeof(Element));
82 dst += this->num_cols;
83 src += other.matrix.num_cols;
87 template <
typename Element>
91 for(
unsigned int r = 0; r < this->num_rows; ++r) {
92 for(
unsigned int c = 0; c < this->num_cols; ++c) {
93 std::cerr <<
" " << hex <<
94 (int) *(this->data + r * this->num_cols + c);
98 std::cerr <<
"]" << endl;
103 template <
typename Element>
105 dbsize_t row, dbsize_t col,
106 dbsize_t num_rows, dbsize_t num_cols)
115 template <
typename Element>
118 Element *dst = this->first();
119 Element *src = m.data;
121 size_t nc_bytes = this->num_cols *
sizeof(Element);
123 for(
unsigned int row = 0; row < this->num_rows; ++row) {
124 XOR_equal((
unsigned char *)dst, (
const unsigned char*)src,
126 dst += this->matrix.num_cols;
132 template <
typename Element>
135 Element *data = this->matrix.data;
136 dbsize_t num_cols = this->matrix.num_cols;
139 for(dbsize_t r = this->row; r < this->num_rows + this->row; ++r) {
140 for(dbsize_t c = this->col; c < this->num_cols + this->col; ++c) {
141 std::cerr <<
" " << hex << (int) *(data + r * num_cols + c);
145 std::cerr <<
"]" << endl;
148 template <
typename Element>
152 return this->matrix.data +
153 this->matrix.num_cols * (this->row + row) + (this->col + col);
156 template <
typename Element>
160 return this->matrix.data +
161 this->matrix.num_cols * this->row + this->col;
164 template <
typename Element>
166 dbsize_t row, dbsize_t col, dbsize_t num_cols)
168 SubMatrix<Element>(matrix, row, col, 1, num_cols)
171 template <
typename Element>
178 template <
typename Element>
180 dbsize_t row, dbsize_t col, dbsize_t num_rows)
182 SubMatrix<Element>(matrix, row, col, num_rows, 1)
185 template <
typename Element>
192 template <
typename Element>
194 dbsize_t row, dbsize_t col)
196 SubMatrix<Element>(matrix, row, col, 1, 1),
197 Row<Element>(matrix, row, col, 1),
198 Col<Element>(matrix, row, col, 1)
201 template <
typename Element>
213 const GF28_Element *row = row_a.first();
214 const GF28_Element *block = mat_b.first();
216 GF28_Element *oc_start = this->first();
217 GF28_Element *oc_end = this->
get(mat_b.num_cols & ~7);
219 const GF28_Element *multrow;
220 const GF28_Element *blockc;
223 for (
unsigned int j = 0; j < row_a.num_cols; ++j) {
224 multrow = GF28_mult_table[row[j]];
228 while (oc < oc_end) {
229 uint64_t accum = (uint64_t) multrow[*(blockc++)];
230 accum |= (uint64_t) multrow[*(blockc++)] << 8;
231 accum |= (uint64_t) multrow[*(blockc++)] << 16;
232 accum |= (uint64_t) multrow[*(blockc++)] << 24;
233 accum |= (uint64_t) multrow[*(blockc++)] << 32;
234 accum |= (uint64_t) multrow[*(blockc++)] << 40;
235 accum |= (uint64_t) multrow[*(blockc++)] << 48;
236 accum |= (uint64_t) multrow[*(blockc++)] << 56;
237 *((uint64_t *) oc) ^= accum;
240 for (
unsigned int c = 0; c < (mat_b.num_cols & 7); ++c) {
241 *(oc++) ^= multrow[*(blockc++)];
244 block += mat_b.matrix.num_cols;
253 const GF216_Element *row = row_a.first();
254 const GF216_Element *block = mat_b.first();
257 GF216_Element *oc_start = this->first();
258 GF216_Element *oc_end = this->
get(mat_b.num_cols & ~3);
259 for (dbsize_t j = 0; j < row_a.num_cols; ++j) {
260 GF216_Element inpv_j = row[j];
262 const GF216_Element *blockc = block;
263 GF216_Element log_j = GF216_log_table[inpv_j];
264 const GF216_Element *start = GF216_exp_table + log_j;
266 GF216_Element block_c;
269 block_c = *(blockc++);
271 GF216_Element log_c = GF216_log_table[block_c];
272 accum |= (uint64_t) start[log_c];
274 block_c = *(blockc++);
276 GF216_Element log_c = GF216_log_table[block_c];
277 accum |= (uint64_t) start[log_c] << 16;
279 block_c = *(blockc++);
281 GF216_Element log_c = GF216_log_table[block_c];
282 accum |= (uint64_t) start[log_c] << 32;
284 block_c = *(blockc++);
286 GF216_Element log_c = GF216_log_table[block_c];
287 accum |= (uint64_t) start[log_c] << 48;
289 *((uint64_t *) oc) ^= accum;
292 for (dbsize_t c = 0; c < (mat_b.num_cols & 3); ++c, ++oc) {
293 block_c = *(blockc++);
295 GF216_Element log_c = GF216_log_table[block_c];
300 block += mat_b.matrix.num_cols;
304 template <
typename GF2E_Element>
310 for(r = 0; r < mat_a.num_rows; ++r) {
311 for(c = 0; c < mat_a.num_cols; ++c) {
313 multiply_GF2E(*mat_a.get(r,c), *col_b.get(c));
318 template <
typename GF2E_Element>
323 GF2E_Element *acc = this->first();
325 const GF2E_Element *a_ptr = row_a.first();
326 const GF2E_Element *b_ptr = col_b.first();
327 const GF2E_Element *a_end = row_a.get(row_a.num_cols);
329 while(a_ptr < a_end) {
330 *acc ^= multiply_GF2E(*(a_ptr++), *b_ptr);
331 b_ptr += col_b.matrix.num_cols;
340 const GF28_Element *row_start = row_b.first();
342 const GF28_Element *multcol;
343 const GF28_Element *row;
344 GF28_Element *oc, *oc_end;
346 for (dbsize_t r = 0; r < col_a.num_rows; ++r) {
347 multcol = GF28_mult_table[*col_a.get(r)];
350 oc_end = this->
get(r,row_b.num_cols);
354 *(oc++) ^= multcol[*(row++)];
363 const GF216_Element *row;
364 const GF216_Element *row_start = row_b.first();
365 GF216_Element row_elem;
367 GF216_Element col_elem;
369 const GF216_Element *start_c;
371 GF216_Element *oc, *oc_end;
373 for (dbsize_t r = 0; r < col_a.num_rows; ++r) {
374 col_elem = *col_a.get(r);
378 oc_end = this->
get(r,row_b.num_cols);
380 log_c = GF216_log_table[col_elem];
381 start_c = GF216_exp_table + log_c;
388 *oc ^= start_c[GF216_log_table[row_elem]];
401 const GF28_Element *mult = GF28_mult_table[*elem_b.first()];
403 const GF28_Element *col = col_a.first();
404 GF28_Element *oc, *oc_end;
407 oc_end = this->
get(col_a.num_rows);
411 oc += this->matrix.num_cols;
412 col += col_a.matrix.num_cols;
421 GF216_Element b = *elem_b.first();
424 const GF216_Element log_mult = GF216_log_table[b];
425 const GF216_Element *start_mult = GF216_exp_table + log_mult;
427 const GF216_Element *col = col_a.first();
428 GF216_Element *oc, *oc_end;
431 oc_end = this->
get(col_a.num_rows);
435 *oc ^= start_mult[GF216_log_table[*col]];
437 oc += this->matrix.num_cols;
438 col += col_a.matrix.num_cols;
443 template <
typename GF2E_Element>
448 *this->first() ^= multiply_GF2E(*elem_a.first(), *elem_b.first());
Definition: old_matrix.h:28
Definition: old_matrix.h:33
Definition: old_matrix.h:29
Definition: old_matrix.h:30
Definition: old_matrix.h:27