コード例 #1
0
void grassmann_embedded::unrank_INT(INT *subspace_basis, INT rk, INT verbose_level)
// subspace_basis is k x big_n
{
	INT f_v = (verbose_level >= 1);
	
	if (f_v) {
		cout << "grassmann_embedded::unrank_INT" << endl;
		cout << "rk=" << rk << endl;
		cout << "calling G->unrank_INT" << endl;
		}
	G->unrank_INT(rk, verbose_level);
	if (f_v) {
		cout << "grassmann_embedded::unrank_INT coefficient matrix:" << endl;
		print_integer_matrix_width(cout, G->M, k, n, n, F->log10_of_q);
		}
	if (f_v) {
		cout << "grassmann_embedded::rank_INT subspace_basis:" << endl;
		print_integer_matrix_width(cout, M, n, big_n, big_n, F->log10_of_q);
		}
	F->mult_matrix_matrix(G->M, M, subspace_basis, k, n, big_n);
	if (f_v) {
		cout << "grassmann_embedded::unrank_INT subspace_basis:" << endl;
		print_integer_matrix_width(cout, subspace_basis, k, big_n, big_n, F->log10_of_q);
		}
}
コード例 #2
0
ファイル: unusual.C プロジェクト: SALAM2016/orbiter
void unusual_model::convert_from_usual(INT n, INT *usual_coordinates, INT *unusual_coordinates, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	INT i, j, a, b, c, aa, bb;
	INT *tmp;
	
	tmp = NEW_INT(n * 4);
	if (f_v) {
		cout << "convert_from_usual:" << endl;
		print_integer_matrix_width(cout, usual_coordinates, n, 5, 5, 2);
		}
	if (q == 0) {
		cout << "q=" << q << " is zero" << endl;
		exit(1);
		}
	for (i = 0; i < n; i++) {
		f.mult_matrix(usual_coordinates + i * 5 + 1, hyperbolic_basis, tmp + i * 4, 1, 4, 4);
		}
	if (f_v) {
		cout << "tmp:" << endl;
		print_integer_matrix_width(cout, tmp, n, 4, 4, 2);
		}
	
	for (i = 0; i < n; i++) {
		for (j = 0; j < 2; j++) {
			a = tmp[i * 4 + j * 2 + 0];
			b = tmp[i * 4 + j * 2 + 1];
			//c = b * q + a;
			c = pair_embedding[a * q + b];
			aa = components[c * 2 + 0];
			bb = components[c * 2 + 1];
			if (aa != a) {
				cout << "aa=" << aa << " not equal to a=" << a << endl;
				cout << "a=" << a << " b=" << b << " c=" << c << endl;
				cout << "a * q + b = " << a * q + b << endl;
				cout << "q=" << q << endl;
				cout << "aa=" << aa << endl;
				cout << "bb=" << bb << endl;
				exit(1);
				}
			if (bb != b) {
				cout << "bb=" << bb << " not equal to b=" << b << endl;
				cout << "a=" << a << " b=" << b << " c=" << c << endl;
				cout << "a * q + b = " << a * q + b << endl;
				cout << "aa=" << aa << endl;
				cout << "bb=" << bb << endl;
				exit(1);
				}
			unusual_coordinates[i * 3 + j] = c;
			}
		unusual_coordinates[i * 3 + 2] = usual_coordinates[i * 5 + 0];
		}
	if (f_v) {
		cout << "unusual_coordinates:" << endl;
		print_integer_matrix_width(cout, unusual_coordinates, n, 3, 3, 2);
		}
	FREE_INT(tmp);
}
コード例 #3
0
INT action_on_grassmannian::compute_image_INT_embedded(action *A, INT *Elt, 
	INT i, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	INT f_vv = (verbose_level >= 2);
	INT j, h;
	
	if (f_v) {
		cout << "action_on_grassmannian::compute_image_INT_embedded i = " << i << endl;
		cout << "calling GE->unrank_INT" << endl;
		}
	GE->unrank_INT(subspace_basis, i, verbose_level - 1);
	if (f_vv) {
		cout << "action_on_grassmannian::compute_image_INT_embedded subspace_basis:" << endl;
		cout << "k=" << k << endl;
		cout << "big_n=" << big_n << endl;
		print_integer_matrix_width(cout, subspace_basis, k, big_n, big_n, F->log10_of_q);
		}
	for (h = 0; h < k; h++) {
		A->element_image_of_low_level(
			subspace_basis + h * big_n, subspace_basis2 + h * big_n, Elt, verbose_level - 1);
		}
	
	//A->element_image_of_low_level(subspace_basis, subspace_basis2, Elt, verbose_level - 1);
#if 0
	F->mult_matrix_matrix(subspace_basis, Elt, subspace_basis2, k, big_n, big_n);
	if (f_vv) {
		cout << "action_on_grassmannian::compute_image_INT_embedded after mult_matrix_matrix:" << endl;
		print_integer_matrix_width(cout, subspace_basis2, k, big_n, big_n, F->log10_of_q);
		}
	
	if (M->f_semilinear) {
		f = Elt[big_n * big_n];
		if (f_v) {
			cout << "f_semilinear is TRUE, f=" << f << endl;
			}
		F->vector_frobenius_power_in_place(subspace_basis2, k * big_n, f);
		}
#endif
	
	if (f_vv) {
		cout << "action_on_grassmannian::compute_image_INT_embedded subspace_basis after the action:" << endl;
		print_integer_matrix_width(cout, subspace_basis2, k, big_n, big_n, F->log10_of_q);
		}
	j = GE->rank_INT(subspace_basis2, verbose_level - 1);
	if (f_v) {
		cout << "action_on_grassmannian::compute_image_INT_embedded image of " << i << " is " << j << endl;
		}
	return j;
}
コード例 #4
0
INT action_on_subspaces::compute_image_INT(action *A, INT *Elt,
	INT i, INT verbose_level)
{
    INT k;
	INT f_v = (verbose_level >= 1);
	INT f_vv = (verbose_level >= 2);
	INT h, j;

	if (f_v) {
		cout << "action_on_subspaces::compute_image_INT_ordinary i = " << i << endl;
		cout << "using action " << A->label << endl;
		}

	S->unrank_INT(i, verbose_level - 1);
    k=S->unrank_k(i,verbose_level-1);
	if (f_vv) {
		cout << "action_on_subspaces::compute_image_INT_ordinary after S->unrank_INT" << endl;
		print_integer_matrix_width(cout, S->G[k]->M, k, S->n, S->n, M->GFq->log10_of_q);
		}
	for (h = 0; h < k; h++) {
		A->element_image_of_low_level(S->G[k]->M + h * n, M1 + h * n, Elt, verbose_level - 1);
		}
    INT_vec_copy(M1, S->G[k]->M, k * n);
	j = S->rank_INT(k,verbose_level - 1);
	if (f_v) {
		cout << "action_on_subspaces::compute_image_INT_ordinary image of " << i << " is " << j << endl;
		}
	return j;
}
コード例 #5
0
ファイル: unusual.C プロジェクト: SALAM2016/orbiter
void unusual_model::convert_from_ranks(INT n, INT *ranks, INT *unusual_coordinates, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	INT *usual;
	INT i;
	
	if (f_v) {
		cout << "unusual_model::convert_from_ranks" << endl;
		}
	if (f_v) {
		cout << "ranks:" << endl;
		INT_vec_print(cout, ranks, n);
		cout << endl;
		}
	
	usual = NEW_INT(n * 5);
	for (i = 0; i < n; i++) {
		Q_unrank(f, usual + 5 * i, 1, 4, ranks[i]);
		}
	

	convert_from_usual(n, usual, unusual_coordinates, verbose_level - 1);

	if (f_v) {
		cout << "unusual_coordinates:" << endl;
		print_integer_matrix_width(cout, unusual_coordinates, n, 3, 3, 2);
		}


	FREE_INT(usual);
}
コード例 #6
0
void action_on_grassmannian::compute_image_longinteger(action *A, INT *Elt, 
	longinteger_object &i, longinteger_object &j, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	INT f_vv = (verbose_level >= 2);
	INT h;
	
	if (f_v) {
		cout << "action_on_grassmannian::compute_image_longinteger i = " << i << endl;
		}
	G->unrank_longinteger(i, 0/*verbose_level - 1*/);
	if (f_vv) {
		cout << "after G->unrank_longinteger" << endl;
		print_integer_matrix_width(cout, G->M, G->k, G->n, G->n, F->log10_of_q);
		}
	for (h = 0; h < k; h++) {
		A->element_image_of_low_level(G->M + h * n, M1 + h * n, Elt, verbose_level - 1);
		}
	//A->element_image_of_low_level(G->M, M1, Elt, verbose_level - 1);
#if 0
	F->mult_matrix_matrix(G->M, Elt, M1, k, n, n);
	
	if (M->f_semilinear) {
		f = Elt[n * n];
		F->vector_frobenius_power_in_place(M1, k * n, f);
		}
#endif
	if (f_vv) {
		cout << "after element_image_of_low_level" << endl;
		print_integer_matrix_width(cout, M1, G->k, G->n, G->n, F->log10_of_q);
		}
	
	INT_vec_copy(M1, G->M, k * n);
#if 0
	for (h = 0; h < k * n; h++) {
		G->M[h] = M1[h];
		}
#endif
	G->rank_longinteger(j, 0/*verbose_level - 1*/);
	if (f_v) {
		cout << "action_on_grassmannian::compute_image_longinteger image of " << i << " is " << j << endl;
		}
}
コード例 #7
0
ファイル: unusual.C プロジェクト: SALAM2016/orbiter
void unusual_model::create_Linear_BLT_set(INT *BLT, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	//INT f_vv = (verbose_level >= 2);
	INT i, minus_one;
	INT *norm_table, nb = 0;
	INT *Table;
	
	if (f_v) {
		cout << "unusual_model::create_Linear_BLT_set" << endl;
		}
	minus_one = F.negate(1);

	norm_table = NEW_INT(qq);
	for (i = 0; i < qq; i++) {
		if (F.N2(i) == minus_one) {
			norm_table[nb++] = i;
			}
		}
	if (f_v) {
		cout << nb << " norm -1 elements reduced:" << endl;
		INT_vec_print(cout, norm_table, nb);
		cout << endl;
		}
	if (nb != q + 1) {
		cout << "nb != q + 1" << endl;
		exit(1);
		}
	Table = NEW_INT((q + 1) * 3);

	for (i = 0; i < nb; i++) {
		Table[i * 3 + 0] = norm_table[i];
		Table[i * 3 + 1] = 0;
		Table[i * 3 + 2] = 1;
		}
	if (f_v) {
		cout << "Table:" << endl;
		print_integer_matrix_width(cout, Table, q + 1, 3, 3, 2);
		}
	
	convert_to_ranks(q + 1, Table, BLT, verbose_level);
	
	if (f_v) {
		cout << "Linear BLT set:" << endl;
		INT_vec_print(cout, BLT, q + 1);
		cout << endl;
		}
	FREE_INT(norm_table);
	FREE_INT(Table);
}
コード例 #8
0
ファイル: unusual.C プロジェクト: SALAM2016/orbiter
void unusual_model::transform_matrix_usual_to_unusual(orthogonal *O, 
	INT *M5, INT *M4, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	INT f_vv = (verbose_level >= 2);
	//INT f_vvv = (verbose_level >= 3);
	
	INT *M4_tmp1, *M4_tmp2; //, *M5;
	INT i, j, a;
	
	M4_tmp1 = NEW_INT(4 * 4);
	M4_tmp2 = NEW_INT(4 * 4);
	//M5 = NEW_INT(5 * 5);
	
	if (f_v) {
		cout << "unusual_model::transform_matrix_usual_to_unusual" << endl;
		}
#if 0
	if (f_vv) {
		A->print(cout, Elt);
		}
	for (i = 0; i < 25; i++) {
		M5[i] = Elt[i];
		}
#endif
	if (M5[0] != 1) {
		a = f.inverse(M5[0]);
		for (i = 0; i < 25; i++) {
			M5[i] = f.mult(a, M5[i]);
			}
		}
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 4; j++) {
			a = M5[(i + 1) * 5 + j + 1];
			M4_tmp2[i * 4 + j] = a;
			}
		}

	f.mult_matrix(hyperbolic_basis_inverse, M4_tmp2, M4_tmp1, 4, 4, 4);
	f.mult_matrix(M4_tmp1, hyperbolic_basis, M4, 4, 4, 4);

	if (f_vv) {
		cout << "transformation matrix in unusual model" << endl;
		print_integer_matrix_width(cout, M4, 4, 4, 4, 3);
		}
	FREE_INT(M4_tmp1);
	FREE_INT(M4_tmp2);
	//FREE_INT(M5);
}
コード例 #9
0
ファイル: unusual.C プロジェクト: SALAM2016/orbiter
void unusual_model::convert_to_usual(INT n, INT *unusual_coordinates, INT *usual_coordinates, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	INT i, j, a, b, c;
	INT *tmp;
	
	tmp = NEW_INT(n * 4);
	if (f_v) {
		cout << "convert_to_usual:" << endl;
		print_integer_matrix_width(cout, unusual_coordinates, n, 3, 3, 2);
		}
	for (i = 0; i < n; i++) {
		for (j = 0; j < 2; j++) {
			c = unusual_coordinates[i * 3 + j];
			a = components[c * 2 + 0];
			b = components[c * 2 + 1];
			//a = c % q;
			//b = (c - a) / q;
			tmp[i * 4 + j * 2 + 0] = a;
			tmp[i * 4 + j * 2 + 1] = b;
			}
		}
	if (f_v) {
		cout << "tmp:" << endl;
		print_integer_matrix_width(cout, tmp, n, 4, 4, 2);
		}
	for (i = 0; i < n; i++) {
		f.mult_matrix(tmp + i * 4, hyperbolic_basis_inverse, usual_coordinates + i * 5 + 1, 1, 4, 4);
		usual_coordinates[i * 5 + 0] = unusual_coordinates[i * 3 + 2];
		}
	if (f_v) {
		cout << "usual_coordinates:" << endl;
		print_integer_matrix_width(cout, usual_coordinates, n, 5, 5, 2);
		}
	FREE_INT(tmp);
}
コード例 #10
0
void action_on_grassmannian::init_embedding(INT big_n, INT *ambient_space, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	
	if (f_v) {
		cout << "action_on_grassmannian::init_embedding" << endl;
		cout << "big_n=" << big_n << endl;
		cout << "ambient space:" << endl;
		print_integer_matrix_width(cout, ambient_space, n, big_n, big_n, F->log10_of_q);
		}
	action_on_grassmannian::big_n = big_n;
	f_embedding = TRUE;
	GE = new grassmann_embedded;
	GE->init(big_n, n, G, ambient_space, verbose_level);
	subspace_basis = NEW_INT(n * big_n);
	subspace_basis2 = NEW_INT(n * big_n);
}
コード例 #11
0
INT action_on_grassmannian::compute_image_INT_ordinary(action *A, INT *Elt, 
	INT i, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	INT f_vv = (verbose_level >= 2);
	INT h, j;
	
	if (f_v) {
		cout << "action_on_grassmannian::compute_image_INT_ordinary i = " << i << endl;
		cout << "A->low_level_point_size=" << A->low_level_point_size << endl;
		cout << "using action " << A->label << endl;
		}
	G->unrank_INT(i, verbose_level - 1);
	if (f_vv) {
		cout << "action_on_grassmannian::compute_image_INT_ordinary after G->unrank_INT" << endl;
		print_integer_matrix_width(cout, G->M, G->k, G->n, G->n, M->GFq->log10_of_q);
		}
	for (h = 0; h < k; h++) {
		A->element_image_of_low_level(G->M + h * n, M1 + h * n, Elt, verbose_level - 1);
		}
#if 0
	F->mult_matrix_matrix(G->M, Elt, M1, k, n, n);
	
	if (M->f_semilinear) {
		f = Elt[n * n];
		F->vector_frobenius_power_in_place(M1, k * n, f);
		}
#endif
	
	INT_vec_copy(M1, G->M, k * n);
#if 0
	for (h = 0; h < k * n; h++) {
		G->M[h] = M1[h];
		}
#endif
	j = G->rank_INT(verbose_level - 1);
	if (f_v) {
		cout << "action_on_grassmannian::compute_image_INT_ordinary image of " << i << " is " << j << endl;
		}
	return j;
}
コード例 #12
0
void action_by_representation::compute_image_INT_low_level(
	action &A, INT *Elt, INT *input, INT *output, INT verbose_level)
{
	INT *x = input;
	INT *xA = output;
	INT f_v = (verbose_level >= 1);
	INT f_vv = (verbose_level >= 2);
	INT i, f;
	
	if (f_v) {
		cout << "action_by_representation::compute_image_INT_low_level" << endl;
		}
	if (f_vv) {
		cout << "action_by_representation::compute_image_INT_low_level: x=";
		INT_vec_print(cout, x, dimension);
		cout << endl;
		}
	INT a, b, c, d;

	a = Elt[0];
	b = Elt[1];
	c = Elt[2];
	d = Elt[3];

	INT AA[9];
	INT two;

	two = F->add(1, 1);
	AA[0] = F->mult(a, a);
	AA[2] = F->mult(b, b);
	AA[6] = F->mult(c, c);
	AA[8] = F->mult(d, d);
	AA[1] = F->mult(a, b);
	AA[7] = F->mult(c, d);
	AA[3] = F->product3(two, a, c);
	AA[5] = F->product3(two, b, d);
	AA[4] = F->add(F->mult(a, d), F->mult(b, c));

	if (f_v) {
		cout << "A=" << endl;
		print_integer_matrix_width(cout, AA, 3, 3, 3, F->log10_of_q);
		}
	F->mult_matrix(x, AA, xA, 1, 3, 3);
	if (f_vv) {
		cout << "action_by_representation::compute_image_INT_low_level: xA=";
		INT_vec_print(cout, xA, dimension);
		cout << endl;
		}
	if (M->f_semilinear) {
		f = Elt[n * n];
		for (i = 0; i < dimension; i++) {
			xA[i] = F->frobenius_power(xA[i], f);
			}
		if (f_vv) {
			cout << "after " << f << " field automorphisms: xA=";
			INT_vec_print(cout, xA, dimension);
			cout << endl;
			}
		}
	if (f_v) {
		cout << "action_by_representation::compute_image_INT_low_level done" << endl;
		}
}
コード例 #13
0
ファイル: conic.C プロジェクト: SALAM2016/orbiter
void conic(INT q, INT *six_coeffs, INT xmax, INT ymax, INT f_do_stabilizer, INT verbose_level) 
{
	const BYTE *override_poly = NULL;
	finite_field F;
	projective_space *P;
	action *A;
	INT n = 3;
	//INT f_with_group = TRUE;
	
	INT v[3];
	//INT w[3];

	//F.init(q), verbose_level - 2);
	F.init_override_polynomial(q, override_poly, verbose_level);

	P = new projective_space;
	cout << "before P->init" << endl;
	P->init(n - 1, &F, 
		FALSE /* f_init_incidence_structure */, 
		verbose_level/*MINIMUM(2, verbose_level)*/);

	cout << "after P->init" << endl;
	A = new action;
	A->init_general_linear_group(n, &F, FALSE /* f_semilinear */, TRUE /* f_basis */, verbose_level - 2);
	
	INT variety[100];
	INT variety_size = 0;
	INT a, i, j, h;

	for (i = 0; i < P->N_points; i++) {
		P->unrank_point(v, i);
		a = F.evaluate_conic_form(six_coeffs, v);
		cout << i << " : ";
		INT_vec_print(cout, v, 3);
		cout << " : " << a << endl;
		if (a == 0) {
			variety[variety_size++] = i;
			}
		}
	cout << "the size of the variety is " << variety_size << endl;
	cout << "the variety is:" << endl;
	INT_vec_print(cout, variety, variety_size);
	cout << endl;
	for (i = 0; i < variety_size; i++) {
		P->unrank_point(v, variety[i]);
		a = F.evaluate_conic_form(six_coeffs, v);
		cout << i << " : ";
		INT_vec_print(cout, v, 3);
		cout << " : " << a << endl;
		}
	
#if 0
	INT pts[] = {2, 22, 6, 18, 10};
	find_collinear_triple(P, pts, 5);
	
	INT five_pts[] = {3, 6, 7, 28, 30};
#endif
	//INT six_coeffs[6];
	INT five_pts[5];
	five_pts[0] = variety[0];
	five_pts[1] = variety[1];
	five_pts[2] = variety[2];
	five_pts[3] = variety[3];
	five_pts[4] = variety[4];
	
	P->determine_conic_in_plane(five_pts, 5, six_coeffs, verbose_level);

	INT points[1000];
	INT tangents[1000];
	INT *exterior_points;
	INT *secants;
	INT nb_secants, nb_exterior_points;
	INT nb_points;
	//INT v[3];
	
	P->conic_points(five_pts, six_coeffs, points, nb_points, verbose_level);
	cout << "the " << nb_points << " conic points are: ";
	INT_vec_print(cout, points, nb_points);
	cout << endl;
	for (i = 0; i < nb_points; i++) {
		P->unrank_point(v, points[i]);
		cout << i << " : " << points[i] << " : ";
		INT_vec_print(cout, v, 3);
		cout << endl;
		}


	strong_generators *Aut_gens;


	if (f_do_stabilizer) {
		// computing stabilizer:

		cout << "computing stabilizer" << endl;
	
		set_stabilizer_compute STAB;
		sims *Stab;
		INT nb_backtrack_nodes;
	
		cout << "computing stabilizer of conic:" << endl;
		STAB.init(A, variety, variety_size /* points, nb_points*/ , verbose_level);
		STAB.compute_set_stabilizer(t0, nb_backtrack_nodes, Aut_gens, verbose_level + 10);
		longinteger_object go, go2;
		Stab = Aut_gens->create_sims(verbose_level - 1);
		Stab->group_order(go);
		cout << "computing stabilizer of conic done, found a group of order " << go << endl;

		delete Stab;
		}
	else {
		Aut_gens = NULL;
		}
	{
	BYTE fname[1000];
	{
	mp_graphics *G;
	INT f_include_line_at_infinity = TRUE;

	sprintf(fname, "conic_%ld", q);
	draw_beginning(fname, G, xmax, ymax, verbose_level);

	//variety_size = 0;
	draw_grid_(*G, q, f_include_line_at_infinity, verbose_level);
	draw_points(*G, P, /*variety + 3, 5*/ variety, variety_size /*points, nb_points*/, verbose_level);
	draw_end(fname, G, xmax, ymax, verbose_level);
	}
	if (f_do_stabilizer) {
		prepare_latex(fname, P, points, nb_points, Aut_gens, verbose_level);
		}
	}
		
	delete Aut_gens;
	return;
	
	P->find_tangent_lines_to_conic(six_coeffs, 
		points, nb_points, 
		tangents, verbose_level);

	cout << "the " << nb_points << " tangent lines are: ";
	INT_vec_print(cout, tangents, nb_points);
	cout << endl;

	nb_exterior_points = (nb_points * (nb_points - 1)) >> 1;
	nb_secants = nb_exterior_points;
	exterior_points = NEW_INT(nb_exterior_points);
	h = 0;
	for (i = 0; i < nb_points; i++) {
		for (j = i + 1; j < nb_points; j++) {
			exterior_points[h++] = P->Line_intersection[
				tangents[i] * P->N_lines + tangents[j]];
			}
		}
	INT_vec_heapsort(exterior_points, nb_exterior_points);
	cout << "the " << nb_exterior_points << " exterior points are: ";
	INT_vec_print(cout, exterior_points, nb_exterior_points);
	cout << endl;

	secants = NEW_INT(nb_secants);
	h = 0;
	for (i = 0; i < nb_points; i++) {
		for (j = i + 1; j < nb_points; j++) {
			secants[h++] = P->Line_through_two_points[
				points[i] * P->N_points + points[j]];
			}
		}
	INT_vec_heapsort(secants, nb_secants);
	cout << "the " << nb_secants << " secants are: ";
	INT_vec_print(cout, secants, nb_secants);
	cout << endl;

	INT *external_lines;
	INT nb_external_lines;
	
	external_lines = NEW_INT(P->N_lines);
	for (i = 0; i < P->N_lines; i++) {
		external_lines[i] = i;
		}
	nb_external_lines = P->N_lines;
	set_delete_elements(external_lines, nb_external_lines, tangents, nb_points);
	set_delete_elements(external_lines, nb_external_lines, secants, nb_secants);

	cout << "the " << nb_external_lines << " external lines are: ";
	INT_vec_print(cout, external_lines, nb_external_lines);
	cout << endl;
	
	INT *adjacency;
	INT idx;

	adjacency = NEW_INT(nb_external_lines * nb_external_lines);
	for (i = 0; i < nb_external_lines; i++) {
		adjacency[i * nb_external_lines + i] = 0;
		for (j = i + 1; j < nb_external_lines; j++) {
			a = P->Line_intersection[
				external_lines[i] * P->N_lines + external_lines[j]];
			if (INT_vec_search(exterior_points, nb_exterior_points, a, idx)) {
				adjacency[i * nb_external_lines + j] = 1;
				adjacency[j * nb_external_lines + i] = 1;
				}
			else {
				adjacency[i * nb_external_lines + j] = 0;
				adjacency[j * nb_external_lines + i] = 0;
				}
			}
		}
	cout << "adjacency matrix:" << endl;
	print_integer_matrix_width(cout, adjacency, 
		nb_external_lines, nb_external_lines, nb_external_lines, 
		1);
	INT *Edges1;
	INT *Edges2;
	INT *Incidence;
	INT nb_e = 0;
	for (i = 0; i < nb_external_lines; i++) {
		for (j = i + 1; j < nb_external_lines; j++) {
			if (adjacency[i * nb_external_lines + j])
				nb_e++;
			}
		}
	Edges1 = NEW_INT(nb_e);
	Edges2 = NEW_INT(nb_e);
	Incidence = NEW_INT(nb_external_lines * nb_e);
	for (i = 0; i < nb_external_lines * nb_e; i++) {
		Incidence[i] = 0;
		}

	nb_e = 0;
	for (i = 0; i < nb_external_lines; i++) {
		for (j = i + 1; j < nb_external_lines; j++) {
			if (adjacency[i * nb_external_lines + j]) {
				Edges1[nb_e] = i;
				Edges2[nb_e] = j;
				nb_e ++;
				}
			}
		}
	for (j = 0; j < nb_e; j++) {
		Incidence[Edges1[j] * nb_e + j] = 1;
		Incidence[Edges2[j] * nb_e + j] = 1;
		}

	BYTE fname[1000];
	sprintf(fname, "ext_lines_%ld.inc", P->F->q);
	{
	ofstream f(fname);

	f << nb_external_lines << " " << nb_e << " " << nb_e * 2 << endl;
	for (i = 0; i < nb_external_lines * nb_e; i++) {
		if (Incidence[i]) {
			f << i << " ";
			}
		}
	f << endl;
	f << -1 << endl;
	
	}
	cout << "written file " << fname << " of size " << file_size(fname) << endl;

	INT colors[] = {0,1};
	INT C = 2;
	INT *Pijk;
	
	Pijk = NEW_INT(C * C * C);
	if (analyze_color_graph(C, colors, nb_external_lines, adjacency, Pijk, verbose_level)) {
		cout << "is association scheme" << endl;
		}
	else {
		cout << "not an association scheme" << endl;
		}

	//exit(1);
	

	{
	set_stabilizer_compute STAB;
	strong_generators *Aut_gens;
	sims *Stab;
	//vector_ge gens;
	//INT *tl;
	INT nb_backtrack_nodes;

	cout << "computing stabilizer of conic:" << endl;
	STAB.init(A, points, nb_points, verbose_level);
	STAB.compute_set_stabilizer(t0, nb_backtrack_nodes, Aut_gens, verbose_level + - 2);
	Stab = Aut_gens->create_sims(verbose_level - 1);
	longinteger_object go, go2;
	Stab->group_order(go);
	cout << "computing stabilizer of conic done, found a group of order " << go << endl;

	
	action *A2;
	action A2r;
	INT f_induce_action = TRUE;

	projective_space_init_line_action(P, A, A2, verbose_level);
	A2r.induced_action_by_restriction(*A2, 
		f_induce_action, Stab, 
		nb_external_lines, external_lines, verbose_level);
	A2r.group_order(go2);
	cout << "induced action on external lines has order " << go2 << endl;

	for (i = 0; i < Aut_gens->gens->len; i++) {
		A2r.element_print_quick(Aut_gens->gens->ith(i), cout);
		A2->element_print_as_permutation(Aut_gens->gens->ith(i), cout);
		A2r.element_print_as_permutation(Aut_gens->gens->ith(i), cout);
		}
	delete Aut_gens;
	delete Stab;
	delete A2;
	}
}
コード例 #14
0
ファイル: unusual.C プロジェクト: SALAM2016/orbiter
INT unusual_model::build_candidate_set_with_or_without_test(orthogonal &O, INT q, 
	INT gamma, INT delta, INT offset, INT m, INT *Set, 
	INT f_second_half, INT f_test, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	INT f_vv = (verbose_level >= 2);
	INT f_vvv = (verbose_level >= 3);
	INT i, z2i, z2mi;
	INT len = (q + 1) / 2;
	INT Len = 0;
	INT *Table;
	INT zeta;

	Table = NEW_INT((q + 1) * 3);
	
	zeta = F.alpha_power(q - 1);
	for (i = 0; i < len; i++) {
		z2i = F.power(zeta, 2 * i);
		z2mi = F.power(z2i, m);
		Table[i * 3 + 0] = F.mult(gamma, z2i);
		Table[i * 3 + 1] = F.mult(delta, z2mi);
		Table[i * 3 + 2] = 1;
		}
	Len += len;
	convert_to_ranks(Len, Table, Set, verbose_level - 2);

	if (f_vvv) {
		cout << "created the following 1st half:" << endl;
		INT_vec_print(cout, Set, Len);
		cout << endl;
		print_coordinates_detailed_set(Set, Len);
		}

	if (f_test) {
		for (i = 1; i < Len; i++) {
			if (!O.BLT_test_full(i, Set, 0/*verbose_level*/)) {
				cout << "BLT test fails in point " << i << " in 1st half" << endl;
				FREE_INT(Table);
				return FALSE;
				}
			}
		if (f_vv) {
			cout << "passes BLT test for 1st half" << endl;
			}
		}

	if (f_second_half) {
		INT z2s;
		
		for (i = 0; i < len; i++) {
			z2i = F.power(zeta, 2 * i);
			z2mi = F.power(z2i, m);
			z2s = F.power(zeta, 2 * offset);
			Table[(len + i) * 3 + 0] = F.mult(delta, z2i);
			Table[(len + i) * 3 + 1] = F.mult(F.mult(gamma, z2mi), z2s);
			Table[(len + i) * 3 + 2] = 1;
			}
		Len += len;
		convert_to_ranks(Len, Table, Set, verbose_level - 2);
		if (f_test) {
			for (i = 1; i < len; i++) {
				if (!O.BLT_test_full(i, Set + len, 0/*verbose_level*/)) {
					cout << "BLT test fails in point " << i << " in 2nd half" << endl;
					FREE_INT(Table);
					return FALSE;
					}
				}
			if (f_vv) {
				cout << "passes BLT test for second half" << endl;
				}
			}
		}
	if (FALSE) {
		cout << "Table:" << endl;
		print_integer_matrix_width(cout, Table, Len, 3, 3, 2);
		}
	
	convert_to_ranks(Len, Table, Set, verbose_level - 2);
	
	if (f_vvv) {
		cout << "created the following set:" << endl;
		INT_vec_print(cout, Set, Len);
		cout << endl;
		print_coordinates_detailed_set(Set, Len);
		}
#if 0
	//INT_vec_sort(Len, Set);
	for (i = 0; i < Len - 1; i++) {
		if (Set[i] == Set[i + 1]) {
			cout << "the set contains repeats" << endl;
			FREE_INT(Table);
			return FALSE;
			}
		}
#endif

	if (f_test) {
		for (i = 1; i < Len; i++) {
			if (!O.BLT_test(i, Set, 0/*verbose_level*/)) {
				if (f_v) {
					cout << "BLT test fails in point " << i << " in the joining" << endl;
					}
				FREE_INT(Table);
				return FALSE;
				}
			}
		if (f_v) {
			cout << "passes BLT test" << endl;
			}
		}
	if (Len < q + 1) {
		FREE_INT(Table);
		return FALSE;
		}
	FREE_INT(Table);
	return TRUE;
}
コード例 #15
0
ファイル: unusual.C プロジェクト: SALAM2016/orbiter
void unusual_model::create_Mondello_BLT_set(INT *BLT, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	//INT f_vv = (verbose_level >= 2);
	INT i, beta, gamma;
	INT *norm_one_table, nb_norm_one = 0;
	INT *Table;
	INT minus_one, four, five, minus_four_fifth, minus_one_fifth;
	
	if (f_v) {
		cout << "unusual_model::create_Mondello_BLT_set" << endl;
		}
	minus_one = F.negate(1);
	four = 4 % F.p;
	five = 5 % F.p;
	minus_four_fifth = F.negate(F.mult(four, F.inverse(five)));
	minus_one_fifth = F.negate(F.inverse(five));
	
	// now we find an element beta in F_q^2 with N2(beta) = minus_four_fifth
	for (beta = 1; beta < qq; beta++) {
		if (F.N2(beta) == minus_four_fifth) {
			break;
			}
		}
	if (beta == qq) {
		cout << "did not find beta" << endl;
		}
	if (f_v) {
		cout << "beta=" << beta << endl;
		}

	// now we find an element gamma in F_q^2 with N2(beta) = minus_one_fifth
	for (gamma = 1; gamma < qq; gamma++) {
		if (F.N2(gamma) == minus_one_fifth) {
			break;
			}
		}
	if (gamma == qq) {
		cout << "did not find gamma" << endl;
		}
	if (f_v) {
		cout << "gamma=" << gamma << endl;
		}

	norm_one_table = NEW_INT(qq);
	for (i = 0; i < qq; i++) {
		if (F.N2(i) == 1) {
			norm_one_table[nb_norm_one++] = i;
			}
		}
	if (f_v) {
		cout << nb_norm_one << " norm one elements:" << endl;
		INT_vec_print(cout, norm_one_table, nb_norm_one);
		cout << endl;
		}
	if (nb_norm_one != q + 1) {
		cout << "nb_norm_one != q + 1" << endl;
		exit(1);
		}
	Table = NEW_INT((q + 1) * 3);
	for (i = 0; i < q + 1; i++) {
		Table[i * 3 + 0] = F.mult(beta, F.power(norm_one_table[i], 2));
		Table[i * 3 + 1] = F.mult(gamma, F.power(norm_one_table[i], 3));
		Table[i * 3 + 2] = 1;
		}
	if (f_v) {
		cout << "Table:" << endl;
		print_integer_matrix_width(cout, Table, q + 1, 3, 3, 2);
		}
	
	convert_to_ranks(q + 1, Table, BLT, verbose_level);
	
	if (f_v) {
		cout << "Mondello BLT set:" << endl;
		INT_vec_print(cout, BLT, q + 1);
		cout << endl;
		}
	FREE_INT(norm_one_table);
	FREE_INT(Table);
}
コード例 #16
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);
}
コード例 #17
0
ファイル: unusual.C プロジェクト: SALAM2016/orbiter
void unusual_model::create_Fisher_BLT_set(INT *Fisher_BLT, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	//INT f_vv = (verbose_level >= 2);
	INT i, j, beta, minus_one, k;
	INT *norm_one_table, nb_norm_one = 0;
	INT *Table;
	
	if (f_v) {
		cout << "unusual_model::create_Fisher_BLT_set" << endl;
		}
	minus_one = F.negate(1);

	// now we find an element beta in F_q^2 with N2(beta) = -1
	for (beta = 1; beta < qq; beta++) {
		if (F.N2(beta) == minus_one) {
			break;
			}
		}
	if (beta == qq) {
		cout << "did not find beta" << endl;
		}
	if (f_v) {
		cout << "beta=" << beta << endl;
		}
	norm_one_table = NEW_INT(qq);
	for (i = 0; i < qq; i++) {
		if (F.N2(i) == 1) {
			j = F.negate(i);
			for (k = 0; k < nb_norm_one; k++) {
				if (norm_one_table[k] == j)
					break;
				}
			if (k == nb_norm_one) {
				norm_one_table[nb_norm_one++] = i;
				}
			}
		}
	if (f_v) {
		cout << nb_norm_one << " norm one elements reduced:" << endl;
		INT_vec_print(cout, norm_one_table, nb_norm_one);
		cout << endl;
		}
	if (nb_norm_one != (q + 1) / 2) {
		cout << "nb_norm_one != (q + 1) / 2" << endl;
		exit(1);
		}
	Table = NEW_INT((q + 1) * 3);

	for (i = 0; i < nb_norm_one; i++) {
		Table[i * 3 + 0] = F.mult(beta, F.mult(norm_one_table[i], norm_one_table[i]));
		Table[i * 3 + 1] = 0;
		Table[i * 3 + 2] = 1;
		}
	for (i = 0; i < nb_norm_one; i++) {
		Table[(nb_norm_one + i) * 3 + 0] = 0;
		Table[(nb_norm_one + i) * 3 + 1] = F.mult(beta, F.mult(norm_one_table[i], norm_one_table[i]));
		Table[(nb_norm_one + i) * 3 + 2] = 1;
		}
	if (f_v) {
		cout << "Table:" << endl;
		print_integer_matrix_width(cout, Table, q + 1, 3, 3, 2);
		}
	
	convert_to_ranks(q + 1, Table, Fisher_BLT, verbose_level);
	
	if (f_v) {
		cout << "Fisher BLT set:" << endl;
		INT_vec_print(cout, Fisher_BLT, q + 1);
		cout << endl;
		}
	FREE_INT(norm_one_table);
	FREE_INT(Table);
}
コード例 #18
0
ファイル: w3q.C プロジェクト: jayant91089/orbiter-mod
void W3q::init(finite_field *F, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	INT f_vv = (verbose_level >= 2);
	INT f_vvv = (verbose_level >= 3);
	INT h, c, rk;

	W3q::F = F;
	W3q::q = F->q;

	if (f_v) {
		cout << "W3q::init" << endl;
		}
	P3 = new projective_space;
	Q4 = new orthogonal;
	Basis = NEW_INT(2 * 4);
	
	P3->init(3, F, 
		//TRUE /* f_init_group */, 
		//FALSE /* f_line_action */, 
		FALSE /* f_init_incidence_structure */, 
		//TRUE /* f_semilinear */, 
		//TRUE /* f_basis */,
		verbose_level - 1  /*MINIMUM(verbose_level - 1, 3)*/);
	F = P3->F;
	Q4->init(0, 5, F, verbose_level - 1);

	Lines = NEW_INT(P3->N_lines);
	nb_lines = 0;
	for (h = 0; h < P3->N_lines; h++) {
		P3->unrank_line(Basis, h);
		c = evaluate_symplectic_form(Basis, Basis + 4);
		if (c) {
			continue;
			}
		Lines[nb_lines++] = h;
		}
	cout << "We found " << nb_lines << " Lines, they are" << endl;
	INT_vec_print(cout, Lines, nb_lines);
	cout << endl;

	if (nb_lines != Q4->nb_points) {
		cout << "nb_lines != Q4->nb_points" << endl;
		exit(1);
		}
	Q4_rk = NEW_INT(nb_lines);
	Line_idx = NEW_INT(nb_lines);


	for (h = 0; h < nb_lines; h++) {
		P3->unrank_line(Basis, Lines[h]);
		if (f_vv) {
			cout << "Line " << h << " is " << Lines[h] << ":" << endl;
			print_integer_matrix_width(cout, Basis, 2, 4, 4, F->log10_of_q);
			cout << endl;
			}

		isomorphism_Q4q(Basis, Basis + 4, v5);

		if (f_vvv) {
			cout << "v5=";
			INT_vec_print(cout, v5, 5);
			cout << endl;
			}
		
		rk = Q4->rank_point(v5, 1, 0);

		if (f_vvv) {
			cout << "orthogonal point rank " << rk << endl;
			}
		
		Q4_rk[h] = rk;
		Line_idx[rk] = h;
		}
	

	if (f_v) {
		cout << "The isomorphism is:" << endl;
		cout << "h : Lines[h] : Q4_rk[h] : Line_idx[h] : x : y : point in Q(4,q)" << endl;
		cout << "Where x and y are a basis for the line" << endl;
		for (h = 0; h < nb_lines; h++) {
			cout << setw(4) << h << " : ";
			cout << setw(4) << Lines[h] << " : ";
			cout << setw(4) << Q4_rk[h] << " : ";
			cout << setw(4) << Line_idx[h] << " : ";
			P3->unrank_line(Basis, Lines[h]);
			INT_vec_print(cout, Basis, 4);
			cout << " : ";
			INT_vec_print(cout, Basis + 4, 4);
			Q4->unrank_point(v5, 1, Q4_rk[h], 0);
			cout << " : ";
			INT_vec_print(cout, v5, 5);
			cout << endl;
			}
		}
}
コード例 #19
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);

}
コード例 #20
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);

}
コード例 #21
0
INT grassmann_embedded::rank_INT(INT *subspace_basis, INT verbose_level)
// subspace_basis is k x big_n
{
	INT f_v = (verbose_level >= 1);
	INT rk, i, j, a;

	if (f_v) {
		cout << "grassmann_embedded::rank_INT" << endl;
		print_integer_matrix_width(cout, subspace_basis, k, big_n, big_n, F->log10_of_q);
		}
	for (i = 0; i < k; i++) {
		for (j = 0; j < n; j++) {
			a = subspace_basis[i * big_n + base_cols[j]];
			tmp_M1[i * n + j] = a;
			}
		}
	if (f_v) {
		cout << "grassmann_embedded::rank_INT tmp_M1:" << endl;
		print_integer_matrix_width(cout, tmp_M1, k, n, n, F->log10_of_q);
		}
	F->mult_matrix_matrix(tmp_M1, transform, tmp_M2, k, n, n);
	if (f_v) {
		cout << "grassmann_embedded::rank_INT tmp_M2:" << endl;
		print_integer_matrix_width(cout, tmp_M2, k, n, n, F->log10_of_q);
		}

	for (i = 0; i < k; i++) {
		F->mult_vector_from_the_left(tmp_M2 + i * n, M, Tmp2, n, big_n);
		if (f_v) {
			cout << "grassmann_embedded::rank_INT i=" << i << " Tmp2=" << endl;
			print_integer_matrix_width(cout, Tmp2, 1, big_n, big_n, F->log10_of_q);
			}
		if (INT_vec_compare(subspace_basis + i * big_n, Tmp2, big_n)) {
			cout << "grassmann_embedded::rank_INT fatal: the i-th vector is not in the space" << endl;
			cout << "i=" << i << endl;
			cout << "subspace:" << endl;
			print_integer_matrix_width(cout, subspace_basis, k, big_n, big_n, F->log10_of_q);
			cout << "space:" << endl;
			print_integer_matrix_width(cout, M, n, big_n, big_n, F->log10_of_q);
			cout << "Tmp1:" << endl;
			INT_vec_print(cout, Tmp1, n);
			cout << endl;
			cout << "Tmp2:" << endl;
			INT_vec_print(cout, Tmp2, big_n);
			cout << endl;
			exit(1);
			}
		for (j = 0; j < n; j++) {
			G->M[i * n + j] = tmp_M2[i * n + j];
			}
		}
	if (f_v) {
		cout << "grassmann_embedded::rank_INT coefficient matrix:" << endl;
		print_integer_matrix_width(cout, G->M, k, n, n, F->log10_of_q);
		}
	rk = G->rank_INT(verbose_level);
	if (f_v) {
		cout << "rk=" << rk << endl;
		}
	return rk;
}
コード例 #22
0
ファイル: unusual.C プロジェクト: SALAM2016/orbiter
void unusual_model::transform_matrix_unusual_to_usual(orthogonal *O, 
	INT *M4, INT *M5, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	INT f_vv = (verbose_level >= 2);
	INT f_vvv = (verbose_level >= 3);
	
	INT *M4_tmp1, *M4_tmp2, /**M5,*/ *M5t, *M5_tmp1, *M5_tmp2;
	INT i, j, a;
	
	M4_tmp1 = NEW_INT(4 * 4);
	M4_tmp2 = NEW_INT(4 * 4);
	//M5 = NEW_INT(5 * 5);
	M5t = NEW_INT(5 * 5);
	M5_tmp1 = NEW_INT(5 * 5);
	M5_tmp2 = NEW_INT(5 * 5);
	
	if (f_v) {
		cout << "unusual_model::transform_matrix_unusual_to_usual" << endl;
		}
	if (f_vv) {
		cout << "transformation matrix in unusual model" << endl;
		print_integer_matrix_width(cout, M4, 4, 4, 4, 3);
		}

	f.mult_matrix(hyperbolic_basis, M4, M4_tmp1, 4, 4, 4);
	f.mult_matrix(M4_tmp1, hyperbolic_basis_inverse, M4_tmp2, 4, 4, 4);
	if (f_vvv) {
		cout << "transformation matrix in standard coordinates:" << endl;
		print_integer_matrix_width(cout, M4_tmp2, 4, 4, 4, 3);
		}
	for (i = 0; i < 25; i++) {
		M5[i] = 0;
		}
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 4; j++) {
			a = M4_tmp2[i * 4 + j];
			M5[(i + 1) * 5 + j + 1] = a;
			}
		}
	M5[0 * 5 + 0] = 1;
	if (f_vvv) {
		cout << "embedded (M5):" << endl;
		print_integer_matrix_width(cout, M5, 5, 5, 5, 3);
		}
	
	f.transpose_matrix(M5, M5t, 5, 5);
	
	if (f_vvv) {
		cout << "transposed (M5t):" << endl;
		print_integer_matrix_width(cout, M5t, 5, 5, 5, 3);
		cout << "Gram matrix:" << endl;
		print_integer_matrix_width(cout, O->Gram_matrix, 5, 5, 5, 3);
		}
		

	f.mult_matrix(M5, O->Gram_matrix, M5_tmp1, 5, 5, 5);
	f.mult_matrix(M5_tmp1, M5t, M5_tmp2, 5, 5, 5);
	
	if (f_vvv) {
		cout << "Gram matrix transformed:" << endl;
		print_integer_matrix_width(cout, M5_tmp2, 5, 5, 5, 3);
		}

	for (i = 0; i < 25; i++) {
		if (M5_tmp2[i] != O->Gram_matrix[i]) {
			cout << "does not preserve the form" << endl;
			exit(1);
			}
		}

#if 0
	A->make_element(Elt, M5, verbose_level);

	if (f_vv) {
		A->print(cout, Elt);
		}
#endif
	FREE_INT(M4_tmp1);
	FREE_INT(M4_tmp2);
	//FREE_INT(M5);
	FREE_INT(M5t);
	FREE_INT(M5_tmp1);
	FREE_INT(M5_tmp2);
}
コード例 #23
0
ファイル: set_of_sets.C プロジェクト: jayant91089/orbiter-mod
void set_of_sets::intersection_matrix(
    INT *&intersection_type, INT &highest_intersection_number,
    INT *&intersection_matrix, INT &nb_big_sets,
    INT verbose_level)
{
    INT f_v = (verbose_level >= 1);
    //INT f_vv = (verbose_level >= 2);
    classify C;
    INT f_second = FALSE;
    INT f, l, a, i, ii, u, j;

    if (f_v) {
        cout << "set_of_sets::intersection_matrix" << endl;
    }
    C.init(Set_size, nb_sets, f_second, 0);
    if (FALSE /*f_v*/) {
        cout << "set_of_sets::intersection_matrix plane-intersection type: ";
        C.print(FALSE /* f_backwards*/);
    }

    if (f_v) {
        cout << "The intersection type is (";
        C.print_naked(FALSE /* f_backwards*/);
        cout << ")" << endl << endl;
    }
    f = C.type_first[C.nb_types - 1];
    highest_intersection_number = C.data_sorted[f];
    intersection_type = NEW_INT(highest_intersection_number + 1);
    for (i = 0; i <= highest_intersection_number; i++) {
        intersection_type[i] = 0;
    }

    for (i = 0; i < C.nb_types; i++) {
        f = C.type_first[i];
        l = C.type_len[i];
        a = C.data_sorted[f];
        intersection_type[a] = l;
    }
    f = C.type_first[C.nb_types - 1];
    nb_big_sets = C.type_len[C.nb_types - 1];

    INT *Incma, *Incma_t, *IIt, *ItI;

    Incma = NEW_INT(underlying_set_size * nb_big_sets);
    Incma_t = NEW_INT(nb_big_sets * underlying_set_size);
    IIt = NEW_INT(underlying_set_size * underlying_set_size);
    ItI = NEW_INT(nb_big_sets * nb_big_sets);


    for (i = 0; i < underlying_set_size * nb_big_sets; i++) {
        Incma[i] = 0;
    }
    for (i = 0; i < nb_big_sets; i++) {
        ii = C.sorting_perm_inv[f + i];
        for (j = 0; j < Set_size[ii]; j++) {
            a = Sets[ii][j];
            Incma[a * nb_big_sets + i] = 1;
        }
    }
    if (FALSE /*f_vv*/) {
        cout << "Incidence matrix:" << endl;
        print_integer_matrix_width(cout, Incma, underlying_set_size, nb_big_sets, nb_big_sets, 1);
    }
    for (i = 0; i < underlying_set_size; i++) {
        for (j = 0; j < underlying_set_size; j++) {
            a = 0;
            for (u = 0; u < nb_big_sets; u++) {
                a += Incma[i * nb_big_sets + u] * Incma_t[u * underlying_set_size + j];
            }
            IIt[i * underlying_set_size + j] = a;
        }
    }
    if (FALSE /*f_vv*/) {
        cout << "I * I^\\top = " << endl;
        print_integer_matrix_width(cout, IIt, underlying_set_size, underlying_set_size, underlying_set_size, 2);
    }
    for (i = 0; i < nb_big_sets; i++) {
        for (j = 0; j < nb_big_sets; j++) {
            a = 0;
            for (u = 0; u < underlying_set_size; u++) {
                a += Incma[u * nb_big_sets + i] * Incma[u * nb_big_sets + j];
            }
            ItI[i * nb_big_sets + j] = a;
        }
    }
    if (FALSE /*f_v*/) {
        cout << "I^\\top * I = " << endl;
        print_integer_matrix_width(cout, ItI, nb_big_sets, nb_big_sets, nb_big_sets, 3);
    }

    intersection_matrix = NEW_INT(nb_big_sets * nb_big_sets);
    for (i = 0; i < nb_big_sets; i++) {
        for (j = 0; j < nb_big_sets; j++) {
            intersection_matrix[i * nb_big_sets + j] = ItI[i * nb_big_sets + j];
        }
    }

    FREE_INT(Incma);
    FREE_INT(Incma_t);
    FREE_INT(IIt);
    FREE_INT(ItI);
    if (f_v) {
        cout << "set_of_sets::intersection_matrix done" << endl;
    }
}
コード例 #24
0
ファイル: unusual.C プロジェクト: SALAM2016/orbiter
void unusual_model::setup2(INT q, const BYTE *poly_q, const BYTE *poly_Q, INT f_sum_of_squares, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	INT f_vv = (verbose_level >= 2);
	INT f_vvv = (verbose_level >= 2);
	INT Q, i, j, b, p, h;
	
	if (f_v) {
		cout << "unusual_model::setup q=" << q << " f_sum_of_squares=" << f_sum_of_squares << endl;
		}
	unusual_model::q = q;
	Q = qq = q * q;
	nb_terms = 0;

	//const BYTE *override_poly_Q = NULL;
	//const BYTE *override_poly_q = NULL;
	
	is_prime_power(q, p, h);
	
#if 0
	if (h > 1) {
		override_poly_Q = override_polynomial_extension_field(q);
		override_poly_q = override_polynomial_subfield(q);
		F.init_override_polynomial(Q, override_poly_Q, verbose_level - 2);
		cout << "field of order " << Q << " initialized" << endl;
		f.init_override_polynomial(q, override_poly_q, verbose_level - 2);
		}
	else {
		if (f_vv) {
			cout << "initializing large field" << endl;
			}
		F.init(qq, verbose_level);
		if (f_vv) {
			cout << "initializing small field" << endl;
			}
		f.init(q, verbose_level);
		if (f.e > 1) {
			F.init(qq, 1);
			f.init(q, 3);
			cout << "need to choose the generator polynomial for the field" << endl;
			F.compute_subfields(verbose_level);
			exit(1);
			}
		}
#endif
		if (f_vv) {
			cout << "initializing large field" << endl;
			}
		F.init_override_polynomial(Q, poly_Q, verbose_level - 2);
		if (f_vv) {
			cout << "field of order " << Q << " initialized" << endl;
			}
		if (f_vv) {
			cout << "initializing small field" << endl;
			}
		f.init_override_polynomial(q, poly_q, verbose_level - 2);
		if (f_vv) {
			cout << "field of order " << q << " initialized" << endl;
			}



#if 0
	if (q == 9) {
		BYTE *override_poly_Q = "110"; // X^{4} + X^{3} + 2
		BYTE *override_poly_q = "17"; // X^2 - X - 1 = X^2 +2X + 2 = 2 + 2*3 + 9 = 17
		//finite_field::init_override_polynomial() GF(81) = GF(3^4), polynomial = X^{4} + X^{3} + 2 = 110
		//subfields of F_{81}:
		//subfield 3^2 : subgroup_index = 10
		//0 : 0 : 1 : 1
		//1 : 10 : 46 : X^{3} + 2X^{2} + 1
		//2 : 20 : 47 : X^{3} + 2X^{2} + 2
		F.init_override_polynomial(Q, override_poly_Q, verbose_level - 2);
		cout << "field of order " << Q << " initialized" << endl;
		f.init_override_polynomial(q, override_poly_q, verbose_level - 2);
		}
	else if (q == 25) {
		BYTE *override_poly_Q = "767"; // X^{4} + X^{3} + 3X + 2
		BYTE *override_poly_q = "47"; // X^2 - X - 3 = X^2 +4X + 2=25+20+2=47
		//subfields of F_{625}:
		//subfield 5^2 : subgroup_index = 26
		//0 : 0 : 1 : 1
		//1 : 26 : 110 : 4X^{2} + 2X
		//2 : 52 : 113 : 4X^{2} + 2X + 3
		F.init_override_polynomial(Q, override_poly_Q, verbose_level - 2);
		cout << "field of order " << Q << " initialized" << endl;
		f.init_override_polynomial(q, override_poly_q, verbose_level - 2);
		}
	else if (q == 27) {
		BYTE *override_poly_Q = "974"; // X^{6} + X^{5} + 2
		BYTE *override_poly_q = "34"; // X^3 - X + 1 = X^3 +2X + 1 = 27+6+1=34
		//subfields of F_{729}:
		//subfield 3^2 : subgroup_index = 91
		//0 : 0 : 1 : 1
		//1 : 91 : 599 : 2X^{5} + X^{4} + X^{3} + X + 2
		//2 : 182 : 597 : 2X^{5} + X^{4} + X^{3} + X
		//subfield 3^3 : subgroup_index = 28
		//0 : 0 : 1 : 1
		//1 : 28 : 158 : X^{4} + 2X^{3} + 2X^{2} + X + 2
		//2 : 56 : 498 : 2X^{5} + X^{2} + X
		//3 : 84 : 157 : X^{4} + 2X^{3} + 2X^{2} + X + 1
		F.init_override_polynomial(Q, override_poly_Q, verbose_level - 2);
		cout << "field of order " << Q << " initialized" << endl;
		f.init_override_polynomial(q, override_poly_q, verbose_level - 2);
		}
	else if (q == 49) {
		BYTE *override_poly_Q = "2754"; // X^{4} + X^{3} + X + 3
		BYTE *override_poly_q = "94"; // X^2-X+3 = X^2+6X+3 = 49+6*7+3=94
		//subfields of F_{2401}:
		//subfield 7^2 : subgroup_index = 50
		//0 : 0 : 1 : 1
		//1 : 50 : 552 : X^{3} + 4X^{2} + X + 6
		//2 : 100 : 549 : X^{3} + 4X^{2} + X + 3
		F.init_override_polynomial(Q, override_poly_Q, verbose_level - 2);
		cout << "field of order " << Q << " initialized" << endl;
		f.init_override_polynomial(q, override_poly_q, verbose_level - 2);
		}
	else if (q == 81) {
		BYTE *override_poly_Q = "6590"; // X^{8} + X^{3} + 2
		BYTE *override_poly_q = "89"; // X^4-X-1=X^4+2X+2=81+2*3+2=89
		//subfields of F_{6561}:
		//subfield 3^4 : subgroup_index = 82
		//0 : 0 : 1 : 1
		//1 : 82 : 5413 : 2X^{7} + X^{6} + X^{5} + 2X^{3} + X^{2} + X + 1
		//2 : 164 : 1027 : X^{6} + X^{5} + 2X^{3} + 1
		//3 : 246 : 3976 : X^{7} + 2X^{6} + X^{5} + X^{4} + 2X + 1
		//4 : 328 : 5414 : 2X^{7} + X^{6} + X^{5} + 2X^{3} + X^{2} + X + 2
		F.init_override_polynomial(Q, override_poly_Q, verbose_level - 2);
		cout << "field of order " << Q << " initialized" << endl;
		f.init_override_polynomial(q, override_poly_q, verbose_level - 2);
		}
	else if (q == 121) {
		BYTE *override_poly_Q = "15985"; // X^{4} + X^{3} + X + 2
		BYTE *override_poly_q = "200"; // X^2-4X+2=X^2+7X+2=11^2+7*11+2=200
		//subfields of F_{14641}:
		//subfield 11^2 : subgroup_index = 122
		//0 : 0 : 1 : 1
		//1 : 122 : 4352 : 3X^{3} + 2X^{2} + 10X + 7
		//2 : 244 : 2380 : X^{3} + 8X^{2} + 7X + 4
		F.init_override_polynomial(Q, override_poly_Q, verbose_level - 2);
		cout << "field of order " << Q << " initialized" << endl;
		f.init_override_polynomial(q, override_poly_q, verbose_level - 2);
		}
	else {
		}
#endif




	alpha = f.p;
	if (f_vv) {
		cout << "primitive element alpha=" << alpha << endl;
		}

	if (f_vv) {
		cout << "unusual_model::setup calling subfield_embedding_2dimensional" << endl;
		}
	F.subfield_embedding_2dimensional(f, 
		components, embedding, pair_embedding, verbose_level - 4);
	if (f_vvv) {
		cout << "unusual_model::setup subfield_embedding_2dimensional finished" << endl;
		F.print_embedding(f, components, embedding, pair_embedding);
		}

	T_alpha = F.retract(f, 2, F.T2(alpha), verbose_level - 2);	
	N_alpha = F.retract(f, 2, F.N2(alpha), verbose_level - 2);
	if (f_vv) {
		cout << "T_alpha = " << T_alpha << endl;	
		cout << "N_alpha = " << N_alpha << endl;
		}
	
	form_i = NEW_INT(4 * 4);
	form_j = NEW_INT(4 * 4);
	form_coeff = NEW_INT(4 * 4);
	Gram = NEW_INT(4 * 4);
	for (i = 0; i < 4 * 4; i++)
		Gram[i] = 0;
	if (f_sum_of_squares) {
		add_term(4, F, nb_terms, form_i, form_j, form_coeff, Gram, 0, 0, 1);
		add_term(4, F, nb_terms, form_i, form_j, form_coeff, Gram, 1, 1, 1);
		add_term(4, F, nb_terms, form_i, form_j, form_coeff, Gram, 2, 2, 1);
		add_term(4, F, nb_terms, form_i, form_j, form_coeff, Gram, 3, 3, 1);
		}
	else {
		add_term(4, F, nb_terms, form_i, form_j, form_coeff, Gram, 0, 0, 1);
		add_term(4, F, nb_terms, form_i, form_j, form_coeff, Gram, 0, 1, T_alpha);
		add_term(4, F, nb_terms, form_i, form_j, form_coeff, Gram, 1, 1, N_alpha);
		add_term(4, F, nb_terms, form_i, form_j, form_coeff, Gram, 2, 2, 1);
		add_term(4, F, nb_terms, form_i, form_j, form_coeff, Gram, 2, 3, T_alpha);
		add_term(4, F, nb_terms, form_i, form_j, form_coeff, Gram, 3, 3, N_alpha);
		}
	if (f_vv) {
		cout << "Gram matrix:" << endl;
		print_integer_matrix_width(cout, Gram, 4, 4, 4, 2);
		cout << "quadratic form:" << endl;
		print_quadratic_form_list_coded(nb_terms, form_i, form_j, form_coeff);
		}
	
	if (f_vv) {
		cout << "finding hyperbolic pair" << endl;
		}
	f.find_hyperbolic_pair(4, nb_terms, 
		form_i, form_j, form_coeff, Gram, 
		basis, basis + 4, 0 /*verbose_level - 3*/);
	f.perp(4, 2, basis, Gram);
	if (f_vv) {
		cout << "basis:" << endl;
		print_integer_matrix_width(cout, basis, 4, 4, 4, 2);
		}
	
	for (i = 0; i < 2 * 4; i++) {
		hyperbolic_basis[i] = basis[i];
		}
	
	if (f_vvv) {
		for (i = 0; i < 4; i++) {
			b = f.evaluate_quadratic_form(4, nb_terms, form_i, form_j, form_coeff, 
				basis + i * 4);
			cout << "i=" << i << " form value " << b << endl;
			}
		}
	
	f.restrict_quadratic_form_list_coding(4 - 2, 4, basis + 2 * 4, 
		nb_terms, form_i, form_j, form_coeff, 
		r_nb_terms, r_form_i, r_form_j, r_form_coeff, 
		verbose_level - 2);
	
	if (f_vv) {
		cout << "restricted quadratic form:" << endl;
		print_quadratic_form_list_coded(r_nb_terms, r_form_i, r_form_j, r_form_coeff);
		}
	r_Gram = NEW_INT(2 * 2);
	
	make_Gram_matrix_from_list_coded_quadratic_form(2, f, 
		r_nb_terms, r_form_i, r_form_j, r_form_coeff, r_Gram);
	if (f_vv) {
		cout << "restricted Gram matrix:" << endl;
		print_integer_matrix_width(cout, r_Gram, 2, 2, 2, 2);
		}

	f.find_hyperbolic_pair(2, r_nb_terms, 
		r_form_i, r_form_j, r_form_coeff, r_Gram, 
		basis_subspace, basis_subspace + 2, verbose_level - 2);
	if (f_vv) {
		cout << "basis_subspace:" << endl;
		print_integer_matrix_width(cout, basis_subspace, 2, 2, 2, 2);
		}
	f.mult_matrix(basis_subspace, basis + 8, hyperbolic_basis + 8, 2, 2, 4);

	if (f_vv) {
		cout << "hyperbolic basis:" << endl;
		print_integer_matrix_width(cout, hyperbolic_basis, 4, 4, 4, 2);
		for (i = 0; i < 4; i++) {
			b = f.evaluate_quadratic_form(4, nb_terms, form_i, form_j, form_coeff, hyperbolic_basis + i * 4);
			cout << "i=" << i << " quadratic form value " << b << endl;
			}
		}

	M = NEW_INT(4 * 4);
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 4; j++) {
			M[i * 4 + j] = f.evaluate_bilinear_form(4, hyperbolic_basis + i * 4, hyperbolic_basis + j * 4, Gram);
			}
		}
	
	if (f_vvv) {
		cout << "bilinear form on the hyperbolic basis:" << endl;
		print_integer_matrix_width(cout, M, 4, 4, 4, 2);
		}

	f.restrict_quadratic_form_list_coding(4, 4, hyperbolic_basis, 
		nb_terms, form_i, form_j, form_coeff, 
		rr_nb_terms, rr_form_i, rr_form_j, rr_form_coeff, 
		verbose_level - 2);
	if (f_vv) {
		cout << "restricted quadratic form:" << endl;
		print_quadratic_form_list_coded(rr_nb_terms, rr_form_i, rr_form_j, rr_form_coeff);
		}
	
	f.matrix_inverse(hyperbolic_basis, hyperbolic_basis_inverse, 4, verbose_level - 2);
	if (f_vv) {
		cout << "inverse hyperbolic basis:" << endl;
		print_integer_matrix_width(cout, hyperbolic_basis_inverse, 4, 4, 4, 2);
		}
	
}
コード例 #25
0
void coding_theory_domain::tt_field_reduction(
		finite_field &F, finite_field &f,
		int m, int n, int *M, int *MM, int verbose_level)
{
	int f_v = (verbose_level >= 1);
	int f_vv = (verbose_level >= 2);
	int  i, j, a, z, b, c, Q, q;
	int index;

	Q = F.q;
	q = f.q;
	index = (Q - 1) / (q - 1);
	if (f_v) {
		cout << "field reduction, Q=" << Q
				<< " q=" << q << " index=" << index << endl;
		}
	if (f_vv) {
		cout << "before:" << endl;
		print_integer_matrix_width(cout, M, m, n, n, 2);
		//print_integer_matrix(cout, M, m, n);
		cout << endl;
		F.print_integer_matrix_zech(cout, M, m, n);
		cout << endl;
		}
	for (i = 0; i < m; i++) {
		for (j = 0; j < n; j++) {
			a = M[i * n + j];
			if (a == 0) {
				c = 0;
				}
			else {
				if (f.e == 1) {
					if (a >= q) {
						cout << "field reduction: element does not "
								"lie in the subfield: " << a << endl;
						exit(1);
						}
					c = a;
					}
				else {
					z = F.log_alpha(a);
					b = z / index;
					if (b * index != z) {
						cout << "b * index != z" << endl;
						exit(1);
						}
					c = f.alpha_power(b);
					}
				}
			MM[i * n + j] = c;
			}
		}
	if (f_vv) {
		cout << "after:" << endl;
		print_integer_matrix_width(cout, MM, m, n, n, 2);
		//print_integer_matrix(cout, MM, m, n);
		cout << endl;
		f.print_integer_matrix_zech(cout, MM, m, n);
		cout << endl;
		}
}
コード例 #26
0
void grassmann_embedded::init(INT big_n, INT n, grassmann *G, INT *M, INT verbose_level)
// M is n x big_n
{
	INT f_v = (verbose_level >= 1);
	INT f_vv = (verbose_level >= 2);
	INT i, j, rk, idx;
	longinteger_object deg;
	longinteger_domain D;
	
	grassmann_embedded::big_n = big_n;
	grassmann_embedded::G = G;
	grassmann_embedded::n = n;

	if (G->n != n) {
		cout << "grassmann_embedded::init n != G->n" << endl;
		exit(1);
		}
	grassmann_embedded::k = G->k;
	grassmann_embedded::F = G->F;
	grassmann_embedded::q = G->F->q;
	

	if (f_v) {
		cout << "grassmann_embedded::init big_n = " << big_n << " n=" << n << " k=" << k << " q=" << q << endl;
		}


	base_cols = NEW_INT(big_n);
	embedding = NEW_INT(big_n);
	grassmann_embedded::M = NEW_INT(n * big_n);
	M_Gauss = NEW_INT(n * big_n);
	transform = NEW_INT(n * n);
	tmp_M1 = NEW_INT(n * n);
	tmp_M2 = NEW_INT(n * n);
	Tmp1 = NEW_INT(big_n);
	Tmp2 = NEW_INT(big_n);
	Tmp3 = NEW_INT(big_n);
	for (i = 0; i < n * big_n; i++) {
		grassmann_embedded::M[i] = M[i];
		M_Gauss[i] = M[i];
		}
	// we initialize transform as the identity matrix:
	for (i = 0; i < n * n; i++) {
		transform[i] = 0;
		}
	for (i = 0; i < n; i++) {
		transform[i * n + i] = 1;
		}

	if (f_vv) {
		cout << "grassmann_embedded::init subspace basis before Gauss reduction:" << endl;
		print_integer_matrix_width(cout, grassmann_embedded::M, n, big_n, big_n, F->log10_of_q);
		}
	//rk = F->Gauss_simple(M_Gauss, n, big_n, base_cols, verbose_level - 1);
	rk = F->Gauss_INT(M_Gauss, FALSE /*f_special*/, TRUE/* f_complete*/, base_cols, 
		TRUE /* f_P */, transform, n, big_n, n, 0/*INT verbose_level*/);
	if (f_vv) {
		cout << "grassmann_embedded::init subspace basis after reduction:" << endl;
		print_integer_matrix_width(cout, M_Gauss, n, big_n, big_n, F->log10_of_q);
		cout << "grassmann_embedded::init transform:" << endl;
		print_integer_matrix_width(cout, transform, n, n, n, F->log10_of_q);
		}
	if (f_v) {
		cout << "base_cols:" << endl;
		INT_vec_print(cout, base_cols, rk);
		cout << endl;
		}
	if (rk != n) {
		cout << "grassmann_embedded::init rk != n" << endl;
		cout << "rk=" << rk << endl;
		cout << "n=" << n << endl;
		exit(1);
		}
	j = 0;
	for (i = 0; i < big_n; i++) {
		if (!INT_vec_search(base_cols, n, i, idx)) {
			embedding[j++] = i;
			}
		}
	if (j != big_n - n) {
		cout << "j != big_n - n" << endl;
		cout << "j=" << j << endl;
		cout << "big_n - n=" << big_n - n << endl;
		exit(1);
		}
	if (f_v) {
		cout << "embedding: ";
		INT_vec_print(cout, embedding, big_n - n);
		cout << endl;
		}
	D.q_binomial(deg, n, k, q, 0);
	degree = deg.as_INT();
}
コード例 #27
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);
		}


}