Exemplo n.º 1
0
void tdo_scheme::exit_partition_stack()
{
	if (the_row_scheme) {
		FREE_int(the_row_scheme);
		the_row_scheme = NULL;
		}
	if (the_col_scheme) {
		FREE_int(the_col_scheme);
		the_col_scheme = NULL;
		}
	if (the_extra_row_scheme) {
		FREE_int(the_extra_row_scheme);
		the_extra_row_scheme = NULL;
		}
	if (the_extra_col_scheme) {
		FREE_int(the_extra_col_scheme);
		the_extra_col_scheme = NULL;
		}
	free_partition(ROW);
	free_partition(COL);
	//if (extra_row_level >= 0)
		free_partition(EXTRA_ROW);
	//if (extra_col_level >= 0)
		free_partition(EXTRA_COL);
	free_partition(LAMBDA);

}
Exemplo n.º 2
0
void blt_set_invariants::freeself()
{
	if (the_set_in_orthogonal) {
		FREE_int(the_set_in_orthogonal);
	}
	if (the_set_in_PG) {
		FREE_int(the_set_in_PG);
	}
}
Exemplo n.º 3
0
vector_hashing::~vector_hashing()
{
	if (vector_data) {
		FREE_int(vector_data);
		vector_data = NULL;
		}
	if (H) {
		FREE_int(H);
		H = NULL;
		}
	if (H_sorted) {
		FREE_int(H_sorted);
		H_sorted = NULL;
		}
	if (perm) {
		FREE_int(perm);
		perm = NULL;
		}
	if (perm_inv) {
		FREE_int(perm_inv);
		perm_inv = NULL;
		}
	if (type_first) {
		FREE_int(type_first);
		type_first = NULL;
		}
	if (type_len) {
		FREE_int(type_len);
		type_len = NULL;
		}
	if (type_value) {
		FREE_int(type_value);
		type_value = NULL;
		}
}
Exemplo n.º 4
0
void partial_derivative::freeself()
{
	if (mapping) {
		FREE_int(mapping);
	}
	null();
}
Exemplo n.º 5
0
void flag_orbit_node::freeself()
{
	if (fusion_elt) {
		FREE_int(fusion_elt);
		}
	if (gens) {
		FREE_OBJECT(gens);
		}
	null();
}
Exemplo n.º 6
0
void tdo_scheme::init_part_and_entries(int *Part, int *Entries, INT verbose_level)
{
	int i;
	INT f_v = (verbose_level >= 1);
	
	for (part_length = 0; ; part_length++) {
		if (Part[part_length] == -1)
			break;
		}
	if (f_v) {
		cout << "partition of length " << part_length << endl;
		}
	
	for (nb_entries = 0; ; nb_entries++) {
		if (Entries[4 * nb_entries + 0] == -1)
			break;
		}
	if (f_v) {
		cout << "nb_entries = " << nb_entries << endl;
		}

	if (part) {
		FREE_int(part);
		}
	if (entries) {
		FREE_int(entries);
		}
	part = NEW_int(part_length + 1);
	for (i = 0; i <= part_length; i++) {
		part[i] = Part[i];
		}
	entries = NEW_int(4 * nb_entries + 1);
	for (i = 0; i <= 4 * nb_entries; i++) {
		entries[i] = Entries[i];
		}
}
Exemplo n.º 7
0
tdo_scheme::~tdo_scheme()
{
	INT i;
	
	if (part) {
		FREE_int(part);
		part = NULL;
		}
	if (entries) {
		FREE_int(entries);
		entries = NULL;
		}
	for (i = 0; i < NUMBER_OF_SCHEMES; i++) {
		free_partition(i);
		}
	if (the_row_scheme) {
		FREE_int(the_row_scheme);
		the_row_scheme = NULL;
		}
	if (the_col_scheme) {
		FREE_int(the_col_scheme);
		the_col_scheme = NULL;
		}
	if (the_extra_row_scheme) {
		FREE_int(the_extra_row_scheme);
		the_extra_row_scheme = NULL;
		}
	if (the_extra_col_scheme) {
		FREE_int(the_extra_col_scheme);
		the_extra_col_scheme = NULL;
		}
	if (the_row_scheme_cur) {
		FREE_INT(the_row_scheme_cur);
		the_row_scheme_cur = NULL;
		}
	if (the_col_scheme_cur) {
		FREE_INT(the_col_scheme_cur);
		the_col_scheme_cur = NULL;
		}
	if (the_extra_row_scheme_cur) {
		FREE_INT(the_extra_row_scheme_cur);
		the_extra_row_scheme_cur = NULL;
		}
	if (the_extra_col_scheme_cur) {
		FREE_INT(the_extra_col_scheme_cur);
		the_extra_col_scheme_cur = NULL;
		}
	if (P) {
		delete P;
		P = NULL;
		}
}
Exemplo n.º 8
0
void blt_set_invariants::latex(ostream &ost, int verbose_level)
{
	int f_v = (verbose_level >= 1);
	sorting Sorting;

	if (f_v) {
		cout << "blt_set_invariants::latex" << endl;
	}



	int a, i, j;
	ost << "Plane intersection type is ";
	for (i = highest_intersection_number; i >= 0; i--) {

		a = intersection_type[i];
		if (a == 0)
			continue;
		ost << "$" << i;
		if (a > 9) {
			ost << "^{" << a << "}";
			}
		else if (a > 1) {
			ost << "^" << a;
			}
		ost << "$ ";
		}
	ost << "\\\\" << endl;
	ost << "Plane invariant is ";

	if (nb_planes < 10) {
		ost << "$$";
		ost << "\\left[" << endl;
		ost << "\\begin{array}{*{" << nb_planes << "}{c}}" << endl;
		for (i = 0; i < nb_planes; i++) {
			for (j = 0; j < nb_planes; j++) {
				ost << intersection_matrix[i * nb_planes + j];
				if (j < nb_planes - 1) {
					ost << " & ";
					}
				}
			ost << "\\\\" << endl;
			}
		ost << "\\end{array}" << endl;
		ost << "\\right]" << endl;
		ost << "$$" << endl;
		}
	else {
		ost << "too big (" << nb_planes << " planes)\\\\" << endl;
		}

	int f_enter_math = FALSE;
	int f_print_subscripts = TRUE;

	ost << "$$" << endl;
	D2->print_row_decomposition_tex(
		ost, f_enter_math, f_print_subscripts, verbose_level - 1);
	ost << "\\quad" << endl;
	D2->print_column_decomposition_tex(
		ost, f_enter_math, f_print_subscripts, verbose_level - 1);
	ost << "$$" << endl;
	D2->Stack->print_classes_tex(ost);

	if (Sos3->nb_sets) {
		ost << "$$" << endl;

		D3->print_row_decomposition_tex(
			ost, f_enter_math, f_print_subscripts, verbose_level - 1);
		ost << "$$" << endl;
		ost << "$$" << endl;
		D3->print_column_decomposition_tex(
			ost, f_enter_math, f_print_subscripts, verbose_level - 1);
		ost << "$$" << endl;
		D3->Stack->print_classes_tex(ost);

		int t, fst_col, fst, len, u, a;

		fst_col = D3->Stack->startCell[1];
		for (t = 0; t < D3->Stack->ht; t++) {
			if (!D3->Stack->is_col_class(t)) {
				continue;
				}
			ost << "Column cell " << t << ":\\\\" << endl;
			len = D3->Stack->cellSize[t];
			fst = D3->Stack->startCell[t];
			int *Cell;
			Cell = NEW_int(len);
			for (u = 0; u < len; u++) {
				a = D3->Stack->pointList[fst + u] - fst_col;
				Cell[u] = a;
				}
			Sorting.int_vec_heapsort(Cell, len);
#if 0
			for (u = 0; u < len; u++) {
				a = Cell[u];
				b = Sos3_idx[h][a];
				f << a << " (rank = ";
				R[h][b].print_not_scientific(f);
				f << ") = ";
				G->unrank_longinteger(R[h][b], 0 /* verbose_level */);
				f << "$\\left[" << endl;
				f << "\\begin{array}{*{" << 5 << "}{c}}" << endl;
				for (i = 0; i < 3; i++) {
					for (j = 0; j < 5; j++) {
						c = G->M[i * 5 + j];
						f << c;
						if (j < 4) {
							f << "&";
							}
						}
					f << "\\\\" << endl;
					}
				f << "\\end{array}" << endl;
				f << "\\right]$\\\\" << endl;
				}
#endif
			FREE_int(Cell);
			}
		}

	int tt, u, v;
	tt = (set_size + 3) / 4;

	ost << "The points by ranks:\\\\" << endl;
	ost << "\\begin{center}" << endl;

	for (u = 0; u < 4; u++) {
		ost << "\\begin{tabular}[t]{|c|c|}" << endl;
		ost << "\\hline" << endl;
		ost << "$i$ & Rank \\\\" << endl;
		ost << "\\hline" << endl;
		for (i = 0; i < tt; i++) {
			v = u * tt + i;
			if (v < set_size) {
				ost << "$" << v << "$ & $" << the_set_in_orthogonal[v]
					<< "$ \\\\" << endl;
				}
			}
		ost << "\\hline" << endl;
		ost << "\\end{tabular}" << endl;
		}
	ost << "\\end{center}" << endl;

	ost << "The points:\\\\" << endl;
	int v5[5];
	for (i = 0; i < set_size; i++) {
		D->O->unrank_point(
				v5, 1, the_set_in_orthogonal[i], 0 /* verbose_level */);
		//Grass->unrank_int(data[i], 0/*verbose_level - 4*/);
		if ((i % 4) == 0) {
			if (i) {
				ost << "$$" << endl;
				}
			ost << "$$" << endl;
			}
		//f << "\\left[" << endl;
		//f << "\\begin{array}{c}" << endl;
		ost << "P_{" << i /*data[i]*/ << "}=";
		int_vec_print(ost, v5, 5);
#if 0
		for (u = 0; u < 5; u++) {
			for (v = 0; v < n; v++) {
				f << Grass->M[u * n + v];
				}
			ost << "\\\\" << endl;
			}
#endif
		//f << "\\end{array}" << endl;
		//f << "\\right]" << endl;
		}
	ost << "$$" << endl;


	if (f_v) {
		cout << "blt_set_invariants::latex done" << endl;
	}
}
Exemplo n.º 9
0
void tdo_scheme::init_partition_stack(int verbose_level)
{
	int k, at, f, c, l, i;
	int f_v = (verbose_level >= 1);
	int f_vv = (verbose_level >= 2);
	int f_vvv = (verbose_level >= 3);
	
	if (f_v) {
		cout << "tdo_scheme::init_partition_stack" << endl;
		}
	if (f_vv) {
		cout << "part_length=" << part_length << endl;
		cout << "row_level=" << row_level << endl;
		cout << "col_level=" << col_level << endl;
		cout << "verbose_level=" << verbose_level << endl;
		}
	mn = part[0];
	m = part[1];
	n = mn - m;
	if (part_length < 2) {
		cout << "part_length < 2" << endl;
		exit(1);
		}
	if (f_vvv) {
		cout << "init_partition_stack: m=" << m << " n=" << n << endl;
		int_vec_print(part, part_length + 1);
		cout << endl;
		}
	
	P = new partitionstack;
	P->allocate(m + n, 0 /* verbose_level */);
	//PB.init_partition_backtrack_basic(m, n, verbose_level - 10);
	if (f_vvv) {
		cout << "after PB.init_partition_backtrack_basic" << endl;
		}

	//partitionstack &P = PB.P;

	if (f_vvv) {
		cout << "initial partition stack: " << endl;
		P->print(cout);
		}
	for (k = 1; k < part_length; k++) {
		at = part[k];
		c = P->cellNumber[at];
		f = P->startCell[c];
		l = P->cellSize[c];
		if (f_vvv) {
			cout << "part[" << k << "]=" << at << endl;
			cout << "P->cellNumber[at]=" << c << endl;
			cout << "P->startCell[c]=" << f << endl;
			cout << "P->cellSize[c]=" << l << endl;
			cout << "f + l - at=" << f + l - at << endl;
			}
		P->subset_continguous(at, f + l - at);
		P->split_cell(FALSE);
		if (f_vvv) {
			cout << "after splitting at " << at << endl;
			P->print(cout);
			}
		if (P->ht == row_level) {
			l = P->ht;
			if (the_row_scheme) {
				FREE_int(the_row_scheme);
				the_row_scheme = NULL;
				}
			the_row_scheme = NEW_int(l * l);
			for (i = 0; i < l * l; i++) {
				the_row_scheme[i] = -1;
				}
			get_partition(ROW, l, verbose_level - 3);
			get_row_or_col_scheme(ROW, l, verbose_level - 3);
			}
			
		if (P->ht == col_level) {
			l = P->ht;
			if (the_col_scheme) {
				FREE_int(the_col_scheme);
				the_col_scheme = NULL;
				}
			the_col_scheme = NEW_int(l * l);
			for (i = 0; i < l * l; i++) {
				the_col_scheme[i] = -1;
				}
			get_partition(COL, l, verbose_level - 3);	
			get_row_or_col_scheme(COL, l, verbose_level - 3);
			}
			
		if (P->ht == extra_row_level) {
			l = P->ht;
			if (the_extra_row_scheme) {
				FREE_int(the_extra_row_scheme);
				the_extra_row_scheme = NULL;
				}
			the_extra_row_scheme = NEW_int(l * l);
			for (i = 0; i < l * l; i++) {
				the_extra_row_scheme[i] = -1;
				}
			get_partition(EXTRA_ROW, l, verbose_level - 3);
			get_row_or_col_scheme(EXTRA_ROW, l, verbose_level - 3);	
			}
			
		if (P->ht == extra_col_level) {
			l = P->ht;
			if (the_extra_col_scheme) {
				FREE_int(the_extra_col_scheme);
				the_extra_col_scheme = NULL;
				}
			the_extra_col_scheme = NEW_int(l * l);
			for (i = 0; i < l * l; i++) {
				the_extra_col_scheme[i] = -1;
				}
			get_partition(EXTRA_COL, l, verbose_level - 3);
			get_row_or_col_scheme(EXTRA_COL, l, verbose_level - 3);	
			}
			
		if (P->ht == lambda_level) {
			l = P->ht;
			get_partition(LAMBDA, l, verbose_level - 3);
			}
			
		} // next k
	
	if (f_vvv) {
		cout << "before complete_partition_info" << endl;
		}
	if (row_level >= 2) {
		complete_partition_info(ROW, 0/*verbose_level*/);
		}
	if (col_level >= 2) {
		complete_partition_info(COL, 0/*verbose_level*/);
		}
	if (extra_row_level >= 2) {
		complete_partition_info(EXTRA_ROW, 0/*verbose_level*/);
		}
	if (extra_col_level >= 2 && extra_col_level < part_length) {
		complete_partition_info(EXTRA_COL, 0/*verbose_level*/);
		}
	complete_partition_info(LAMBDA, 0/*verbose_level*/);
	
	if (f_vv) {
		if (row_level >= 2) {
			print_scheme(ROW, FALSE);
			}
		if (col_level >= 2) {
			print_scheme(COL, FALSE);
			}
		if (extra_row_level >= 2) {
			print_scheme(EXTRA_ROW, FALSE);
			}
		if (extra_col_level >= 2) {
			print_scheme(EXTRA_COL, FALSE);
			}
		print_scheme(LAMBDA, FALSE);
		}
}
Exemplo n.º 10
0
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);

}
Exemplo n.º 11
0
void coding_theory_domain::make_tensor_code_9dimensional_as_point_set(
	finite_field *F,
	int *&the_set, int &length,
	int verbose_level)
{
	int f_v = (verbose_level >= 1);
	int f_hyperoval = FALSE;
	const char *override_poly = "";
	const char *override_poly_Q = "";
	int i, t, q;
	int *code;

	if (f_v) {
		cout << "make_tensor_code_9dimensional_as_point_set" << endl;
		}
	q = F->q;
	if (q == 2) {
		override_poly_Q = ""; override_poly = ""; f_hyperoval = FALSE;
		}
	else if (q == 3) {
		override_poly_Q = ""; override_poly = ""; f_hyperoval = FALSE;
		}
	else if (q == 4) {
		override_poly_Q = "19"; override_poly = "7"; 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
		}
	else if (q == 5) {
		override_poly_Q = "47"; override_poly = ""; f_hyperoval = FALSE;
		// F_625  generated by X^4 + X^3 + 3X + 2
		// F_25  generated by X^2 + 4X + 2  = 47
		}
	else if (q == 7) {
		override_poly_Q = ""; override_poly = ""; f_hyperoval = FALSE;
		}
	else if (q == 8) {
		override_poly_Q = "97"; override_poly = "11"; 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
		}
	else if (q == 9) {
		override_poly_Q = ""; override_poly = "17"; f_hyperoval = FALSE;
		}
	make_tensor_code_9_dimensional(q, override_poly_Q, override_poly,
		f_hyperoval, code, length, verbose_level - 1);

	the_set = NEW_int(length);

	int pt[9], rk;

	for (t = 0; t < length; t++) {
		for (i = 0; i < 9; i++) {
			pt[i] = code[i * length + t];
			}
		F->PG_element_rank_modified(pt, 1, 9, rk);
		the_set[t] = rk;
		}
	FREE_int(code);
	if (f_v) {
		cout << "make_tensor_code_9dimensional_as_point_set done" << endl;
		cout << "created the set: ";
		int_vec_print(cout, the_set, length);
		cout << endl;
		}
}
Exemplo n.º 12
0
void coding_theory_domain::create_matrix_H_subfield(
	finite_field *F, finite_field*f,
	int *H_subfield, int *C, int *C_inv, int *M,
	int m, int n, int beta, int beta_q,
	int f_elements_exponential, const char *symbol_for_print,
	const char *symbol_for_print_subfield,
	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 i, j;
	int q;
	//int *C;
	//int *C_inv;
	int *H;
	int *AA;

	q = f->q;

	// matrix C is zero:
	H = NEW_int(m * n);
	AA = NEW_int(m * m);
	for (i = 0; i < m; i++) {
		for (j = 0; j < m; j++) {
			C[i * m + j] = 0;
			}
		}


	if (f_construction_A) {
		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;
			}
		}
	else if (f_construction_B) {
		int nb_C_coeffs = 20;
		int k, aa;
		int C_coeffs[] = {
			0, 0, 1,
			1, 1, 1,
			2, 2, 1,
			2, 3, 1,
			2, 4, 1,
			3, 2, beta,
			3, 3, beta_q,
			3, 4, F->beta_trinomial(q, beta, 1, 0, 0),
			4, 2, F->beta_trinomial(q, beta, 0, 0, 2),
			4, 3, F->beta_trinomial(q, beta, 0, 2, 0),
			4, 4, F->beta_trinomial(q, beta, 2, 0, 0),
			5, 5, 1,
			5, 6, 1,
			5, 7, 1,
			6, 5, F->beta_trinomial(q, beta, 0, 1, 1),
			6, 6, F->beta_trinomial(q, beta, 1, 1, 0),
			6, 7, F->beta_trinomial(q, beta, 1, 0, 1),
			7, 5, F->beta_trinomial(q, beta, 0, 2, 2),
			7, 6, F->beta_trinomial(q, beta, 2, 2, 0),
			7, 7, F->beta_trinomial(q, beta, 2, 0, 2),
			};
		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;
			}
		}


	if (f_v) {
		cout << "matrix C:" << endl;
		print_integer_matrix_width(cout, C, m, m, m, 2);
		F->latex_matrix(cout, f_elements_exponential,
				symbol_for_print, C, m, m);
		}


	F->invert_matrix(C, C_inv, m);

	if (f_vv) {
		cout << "C_inv:" << endl;
		print_integer_matrix_width(cout, C_inv, m, m, m, 2);
		}

	F->mult_matrix_matrix(C, C_inv, AA, m, m, m,
			0 /* verbose_level */);

	if (f_vv) {
		cout << "C * C_inv:" << endl;
		print_integer_matrix_width(cout, AA, m, m, m, 2);
		}


	F->mult_matrix_matrix(C, M, H, m, m, n,
			0 /* verbose_level */);

	if (f_v) {
		cout << "H = C * M:" << endl;
		print_integer_matrix_width(cout, H, m, n, n, 2);
		F->latex_matrix(cout, f_elements_exponential,
				symbol_for_print, H, m, n);
		}


#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 */,
		verbose_level - 2);
	cout << "has rank " << rk << endl;
#endif

	tt_field_reduction(*F, *f, m, n, H, H_subfield, verbose_level - 2);

	if (f_v) {
		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(H);
	FREE_int(AA);
}
Exemplo n.º 13
0
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);

}
Exemplo n.º 14
0
void coding_theory_domain::create_matrix_M(
	int *&M,
	finite_field *F, finite_field *f,
	int &m, int &n, int &beta, int &r, int *exponents,
	int f_construction_A, int f_hyperoval, int f_construction_B,
	int f_elements_exponential, const char *symbol_for_print,
	int verbose_level)
// int exponents[9]
{
	int f_v = (verbose_level >= 1);
	//int f_vv = (verbose_level >= 2);
	int i, j, t, q, Q, q2;

	q = f->q;
	q2 = q * q;


	if (f_construction_A) {

#if 0
		//q = 2; override_poly_Q = ""; override_poly = "";
		//q = 3; override_poly_Q = ""; override_poly = "";
		q = 4; override_poly_Q = "19"; override_poly = "7";
			// 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 = "";
			// 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 = "";
		//q = 8; override_poly_Q = "97"; override_poly = "11";
			// 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";
#endif
		Q = q2;
		beta = 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;
		// 3 orbits of length 1: 0, q+1, 2q+2
		exponents[0] = 0;
		exponents[1] = q + 1;
		exponents[2] = 2 * q + 2;
		//orbit (q,1)
		exponents[3] = q;
		exponents[4] = 1;
		// orbit (2q, 2)
		exponents[5] = 2 * q;
		exponents[6] = 2;
		// orbit (2q+1, q+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;
		}
	else if (f_construction_B) {

#if 0
		//q = 2; override_poly_Q = ""; override_poly = ""; r = 9;
		//q = 3; override_poly_Q = ""; override_poly = ""; r = 5;
		q = 4; override_poly_Q = ""; override_poly = "7"; r = 4;
			// F_4096  generated by X^8 + X^4 + X^3 + X^2 + 1 = 4096
		//q = 5; override_poly_Q = ""; override_poly = ""; r = 4;
		//q = 7; override_poly_Q = ""; override_poly = ""; r = 4;
#endif

		beta = q;
		Q = q2 * q;
		m = 8;
		n = Q + 1;

		exponents[0] = 0;
		exponents[1] = q2 + q + 1;
		exponents[2] = 1;
		exponents[3] = q;
		exponents[4] = q2;
		exponents[5] = q + 1;
		exponents[6] = q2 + q;
		exponents[7] = q2 + 1;
		//exponents[0] = 0;
		//exponents[1] = q;
		//exponents[2] = 1;
		//exponents[3] = q + 1;
		//exponents[4] = q2;
		//exponents[5] = q2 + q;
		//exponents[6] = q2 + 1;
		//exponents[7] = q2 + q + 1;
		}
	else {
		cout << "create_matrix_M(): please specify the construction using option -A or -B" << endl;
		exit(1);
		}


	// create matrix M:
	M = NEW_int(m * n);
	for (i = 0; i < m; i++) {
		for (j = 0; j < n; j++) {
			M[i * n + j] = 0;
			}
		}
	for (t = 0; t < Q; t++) {
		for (i = 0; i < m; i++) {
			M[i * n + t] = F->power(t, exponents[i]);
			}
		}
	if (f_construction_A) {
		M[2 * n + Q] = 1;
		if (f_hyperoval)
			M[1 * n + Q + 1] = 1;
		}
	else if (f_construction_B) {
		M[1 * n + Q] = 1;
		}

	if (f_v) {
		cout << "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 (f_v) {
		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 << "overall col_sum:" << endl;
		print_integer_matrix_width(cout, col_sum, m, 1, 1, 2);
		FREE_int(all_one);
		FREE_int(col_sum);
		}


}