void coding_theory_domain::twisted_tensor_product_codes( int *&H_subfield, int &m, int &n, finite_field *F, finite_field *f, int f_construction_A, int f_hyperoval, int f_construction_B, int verbose_level) { int f_v = (verbose_level >= 1); int f_vv = (verbose_level >= 2); int index; int exponents[9]; int *M; //int *H_subfield; int *C; int *C_inv; int q = f->q; int q2; int Q; //int m, n; int r; int beta, beta_q; int f_elements_exponential = TRUE; const char *symbol_for_print = "\\alpha"; const char *symbol_for_print_subfield = "\\omega"; if (f_v) { cout << "twisted_tensor_product_codes" << endl; cout << "f_construction_A=" << f_construction_A << endl; cout << "f_hyperoval=" << f_hyperoval << endl; cout << "f_construction_B=" << f_construction_B << endl; } q2 = q * q; Q = 0; if (f_construction_A) { Q = q2; } else if (f_construction_B) { Q = q2 * q; } index = (Q - 1) / (q - 1); if (Q != F->q) { cout << "twisted_tensor_product_codes Q != F->q" << endl; exit(1); } if (f_vv) { cout << "q = " << q << endl; cout << "Q = " << Q << endl; cout << "index = " << index << endl; } #if 0 F.init_override_polynomial(Q, override_poly_Q, verbose_level - 2); if (f_vv) { cout << "field of order " << Q << " initialized" << endl; } f.init_override_polynomial(q, override_poly_q, verbose_level - 2); if (f_vv) { cout << "field of order " << q << " initialized" << endl; cout << "index = " << index << endl; } #endif F->compute_subfields(verbose_level - 2); create_matrix_M( M, F, f, m, n, beta, r, exponents, f_construction_A, f_hyperoval, f_construction_B, f_elements_exponential, symbol_for_print, verbose_level - 2); beta_q = F->power(beta, q); if (f_vv) { cout << "twisted_tensor_product_codes after create_matrix_M" << endl; cout << "m = " << m << endl; cout << "n = " << n << endl; cout << "Q = " << Q << endl; cout << "q2 = " << q2 << endl; cout << "beta = " << beta << endl; cout << "beta_q = " << beta_q << endl; cout << "Exponents: "; int_vec_print(cout, exponents, m); cout << endl; } if (f_vv) { cout << "twisted_tensor_product_codes: M:" << endl; print_integer_matrix_width(cout, M, m, n, n, 2); F->latex_matrix(cout, f_elements_exponential, symbol_for_print, M, m, n); } #if 0 for (j = 0; j < n; j++) { PG_element_normalize(F, M + j, n, m); } cout << "column normalized M:" << endl; print_integer_matrix_width(cout, M, m, n, n, 2); #endif C = NEW_int(m * m); C_inv = NEW_int(m * m); H_subfield = NEW_int(m * n); create_matrix_H_subfield(F, f, H_subfield, C, C_inv, M, m, n, beta, beta_q, f_elements_exponential, symbol_for_print, symbol_for_print_subfield, f_construction_A, f_hyperoval, f_construction_B, verbose_level - 2); if (f_v) { cout << "twisted_tensor_product_codes: after create_matrix_H_subfield" << endl; cout << "H_subfield:" << endl; print_integer_matrix_width(cout, H_subfield, m, n, n, 2); f->latex_matrix(cout, f_elements_exponential, symbol_for_print_subfield, H_subfield, m, n); } FREE_int(M); FREE_int(C); FREE_int(C_inv); }
void coding_theory_domain::make_tensor_code_9_dimensional(int q, const char *override_poly_Q, const char *override_poly, int f_hyperoval, int *&code, int &length, int verbose_level) { finite_field F; finite_field f; rank_checker rc; int exponents[9]; int *M; int *C; int *C_inv; int *H; int *H_subfield; int index, Q, i, j, t, m, n, r, beta, beta_q; int f_v = (verbose_level >= 1); int f_vv = (verbose_level >= 2); if (f_v) { cout << "make_tensor_code_9_dimensional q=" << q << endl; } //q = 2; override_poly_Q = ""; override_poly = ""; int f_hyperoval = FALSE; //q = 3; override_poly_Q = ""; override_poly = ""; int f_hyperoval = FALSE; //q = 4; override_poly_Q = "19"; override_poly = "7"; int f_hyperoval = FALSE; // F_256 generated by X^8 + X^4 + X^3 + X^2 + 1 // F_16 generated by X^4+X+1 = 19 // F_4 generated by X^2+X+1 = 7 //q = 5; override_poly_Q = "47"; override_poly = ""; int f_hyperoval = FALSE; // F_625 generated by X^4 + X^3 + 3X + 2 // F_25 generated by X^2 + 4X + 2 = 47 //q = 7; override_poly_Q = ""; override_poly = ""; int f_hyperoval = FALSE; //q = 8; override_poly_Q = "97"; override_poly = "11"; int f_hyperoval = TRUE; // F_4096 generated by x^12+x^6+x^4+x+1 // F_64 generated by X^6+X^5+1 = 97 // F_8 generated by X^3+X+1 = 11 //q = 9; override_poly_Q = ""; override_poly = "17"; int f_hyperoval = FALSE; beta = q; Q = q * q; m = 9; if (f_hyperoval) { n = Q + 2; } else { n = Q + 1; } r = 5; if (q == 4) r = 7; if (q == 3) r = 9; exponents[0] = 0; exponents[1] = q + 1; exponents[2] = 2 * q + 2; exponents[3] = q; exponents[4] = 1; exponents[5] = 2 * q; exponents[6] = 2; exponents[7] = 2 * q + 1; exponents[8] = q + 2; //exponents[0] = 0; //exponents[1] = q; //exponents[2] = 2 * q; //exponents[3] = 1; //exponents[4] = q + 1; //exponents[5] = 2 * q + 1; //exponents[6] = 2; //exponents[7] = q + 2; //exponents[8] = 2 * q + 2; index = (Q - 1) / (q - 1); cout << "q = " << q << " override polynomial = " << override_poly << endl; cout << "Q = " << Q << endl; F.init_override_polynomial(Q, override_poly_Q, verbose_level); cout << "field of order " << Q << " initialized" << endl; beta_q = F.power(beta, q); f.init_override_polynomial(q, override_poly, verbose_level); cout << "field of order " << q << " initialized" << endl; cout << "n = " << n << endl; cout << "index = " << index << endl; cout << "beta = " << beta << endl; cout << "beta_q = " << beta_q << endl; F.compute_subfields(verbose_level - 3); M = NEW_int(m * n); C = NEW_int(m * m); C_inv = NEW_int(m * m); H = NEW_int(m * n); H_subfield = NEW_int(m * n); rc.init(&f, m, n, r + 1); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { M[i * n + j] = 0; } } for (i = 0; i < m; i++) { for (j = 0; j < m; j++) { C[i * m + j] = 0; } } for (t = 0; t < Q; t++) { for (i = 0; i < m; i++) { M[i * n + t] = F.power(t, exponents[i]); } } { M[2 * n + Q] = 1; if (f_hyperoval) M[1 * n + Q + 1] = 1; int nb_C_coeffs = 15; int k, aa; int C_coeffs[] = { 0, 0, 1, 1, 1, 1, 2, 2, 1, 3, 3, 1, 3, 4, 1, 4, 3, beta_q, 4, 4, beta, 5, 5, 1, 5, 6, 1, 6, 5, beta_q, 6, 6, beta, 7, 7, 1, 7, 8, 1, 8, 7, beta_q, 8, 8, beta, }; for (k = 0; k < nb_C_coeffs; k++) { i = C_coeffs[k * 3 + 0]; j = C_coeffs[k * 3 + 1]; aa = C_coeffs[k * 3 + 2]; C[i * m + j] = aa; } } cout << "M:" << endl; print_integer_matrix_width(cout, M, m, n, n, 2); { int *all_one, *col_sum; all_one = NEW_int(n); col_sum = NEW_int(m); for (i = 0; i < n; i++) all_one[i] = 1; F.mult_matrix_matrix(M, all_one, col_sum, m, n, 1, 0 /* verbose_level */); cout << "col_sum:" << endl; print_integer_matrix_width(cout, col_sum, m, 1, 1, 2); FREE_int(all_one); FREE_int(col_sum); } #if 0 for (j = 0; j < n; j++) { PG_element_normalize(F, M + j, n, m); } cout << "column normalized M:" << endl; print_integer_matrix_width(cout, M, m, n, n, 2); #endif cout << "C:" << endl; print_integer_matrix_width(cout, C, m, m, m, 2); F.invert_matrix(C, C_inv, m); cout << "C_inv:" << endl; print_integer_matrix_width(cout, C_inv, m, m, m, 2); { int *AA; AA = NEW_int(m * m); F.mult_matrix_matrix(C, C_inv, AA, m, m, m, 0 /* verbose_level */); cout << "C * C_inv:" << endl; print_integer_matrix_width(cout, AA, m, m, m, 2); FREE_int(AA); } F.mult_matrix_matrix(C, M, H, m, m, n, 0 /* verbose_level */); cout << "H = C * M:" << endl; print_integer_matrix_width(cout, H, m, n, n, 2); #if 0 rk = F.Gauss_int(M, FALSE /* f_special */, TRUE /* f_complete */, base_cols, FALSE /* f_P */, NULL, m /* m */, n /* n */, 0 /* Pn */, FALSE, FALSE); cout << "has rank " << rk << endl; #endif if (f_vv) { cout << "before field reduction:" << endl; print_integer_matrix_width(cout, H, m, n, n, 2); cout << endl; f.print_integer_matrix_zech(cout, H, m, n); cout << endl; } F.retract_int_vec(f, 2, H, H_subfield, m * n, 0 /* verbose_level */); //field_reduction(F, f, m, n, H, H_subfield, TRUE, TRUE); if (f_vv) { cout << "after field reduction:" << endl; print_integer_matrix_width(cout, H_subfield, m, n, n, 2); cout << endl; f.print_integer_matrix_zech(cout, H_subfield, m, n); cout << endl; } cout << "H_subfield:" << endl; print_integer_matrix_width(cout, H_subfield, m, n, n, 2); code = H_subfield; length = n; FREE_int(M); FREE_int(C); FREE_int(C_inv); FREE_int(H); }
void action_on_bricks::compute_image_linear_action(INT *Elt, INT i, INT &j, INT verbose_level) { //verbose_level = 3; // !!! INT f_v = (verbose_level >= 1); //INT f_vv = (verbose_level >= 2); INT v[3], w[3], rk_v, rk_w; INT vv[3], ww[3], rk_vv, rk_ww; if (f_v) { cout << "action_on_bricks::compute_image i = " << i << endl; } if (i < 0 || i >= degree) { cout << "action_on_bricks::compute_image i = " << i << " out of range" << endl; exit(1); } B->unrank_coordinates(i, v[0], v[1], w[0], w[1], 0); v[2] = 1; w[2] = 1; if (f_v) { cout << "action_on_bricks::compute_image v="; INT_vec_print(cout, v, 3); cout << endl; cout << "action_on_bricks::compute_image w="; INT_vec_print(cout, w, 3); cout << endl; } PG_element_rank_modified(*B->F, v, 1, 3, rk_v); PG_element_rank_modified(*B->F, w, 1, 3, rk_w); if (f_v) { cout << "action_on_bricks::compute_image rk_v=" << rk_v << endl; cout << "action_on_bricks::compute_image rk_w=" << rk_w << endl; cout << "action_on_bricks::compute_image A=" << endl; A->element_print_quick(Elt, cout); } rk_vv = A->image_of(Elt, rk_v); rk_ww = A->image_of(Elt, rk_w); if (f_v) { cout << "action_on_bricks::compute_image rk_vv=" << rk_vv << endl; cout << "action_on_bricks::compute_image rk_ww=" << rk_ww << endl; } PG_element_unrank_modified(*B->F, vv, 1, 3, rk_vv); PG_element_unrank_modified(*B->F, ww, 1, 3, rk_ww); if (f_v) { cout << "action_on_bricks::compute_image vv="; INT_vec_print(cout, vv, 3); cout << endl; cout << "action_on_bricks::compute_image ww="; INT_vec_print(cout, ww, 3); cout << endl; } if (vv[2] == 0) { cout << "action_on_bricks::compute_image vv[2] == 0" << endl; exit(1); } if (ww[2] == 0) { cout << "action_on_bricks::compute_image ww[2] == 0" << endl; exit(1); } PG_element_normalize(*B->F, vv, 1, 3); PG_element_normalize(*B->F, ww, 1, 3); if (f_v) { cout << "action_on_bricks::compute_image after normalize vv="; INT_vec_print(cout, vv, 3); cout << endl; cout << "action_on_bricks::compute_image after normalize ww="; INT_vec_print(cout, ww, 3); cout << endl; } j = B->rank_coordinates(vv[0], vv[1], ww[0], ww[1], 0); if (j < 0 || j >= degree) { cout << "action_on_bricks::compute_image j = " << j << " out of range" << endl; exit(1); } }