15namespace layer1_foundations {
16namespace field_theory {
21 ost <<
"\\small" << endl;
22 ost <<
"\\arraycolsep=2pt" << endl;
23 ost <<
"\\parindent=0pt" << endl;
24 ost <<
"$q = " <<
q <<
"$\\\\" << endl;
25 ost <<
"$p = " <<
p <<
"$\\\\" << endl;
26 ost <<
"$e = " <<
e <<
"$\\\\" << endl;
28 ost <<
"\\clearpage" << endl << endl;
29 ost <<
"\\section{The Finite Field with $" <<
q <<
"$ Elements}" << endl;
59 cout <<
"Finite field of order " <<
q << endl;
72 cout <<
"polynomial = ";
78 cout <<
"finite_field::print_detailed !f_has_table" << endl;
83 if (f_add_mult_table) {
85 cout <<
"finite_field::print_detailed !f_has_table" << endl;
102 cout <<
"i : inverse(i) : frobenius_power(i, 1) : alpha_power(i) : "
103 "log_alpha(i)" << endl;
104 for (i = 0; i <
q; i++) {
115 cout << setw(4) << i <<
" : "
116 << setw(4) << a <<
" : "
117 << setw(4) << b <<
" : "
118 << setw(4) << c <<
" : "
119 << setw(4) << l << endl;
129 ost <<
"i & T2(i)" << endl;
130 for (i = 0; i <
q; i++) {
140 ost <<
"i & T3(i)" << endl;
141 for (i = 0; i <
q; i++) {
151 ost <<
"i & N2(i)" << endl;
152 for (i = 0; i <
q; i++) {
162 ost <<
"i & N3(i)" << endl;
163 for (i = 0; i <
q; i++) {
170 int *p,
int m,
int n)
177 for (i = 0; i < m; i++) {
178 for (j = 0; j < n; j++) {
181 for (h = 0; h < w - 1; h++)
187 ost << setw(w) << a <<
" ";
197 int *components,
int *embedding,
int *pair_embedding)
203 cout <<
"embedding:" << endl;
204 for (i = 0; i <
q; i++) {
205 cout << setw(4) << i <<
" : " << setw(4) << embedding[i] << endl;
207 cout <<
"components:" << endl;
208 for (i = 0; i < Q; i++) {
209 cout << setw(4) << i << setw(4) << components[i * 2 + 0]
210 << setw(4) << components[i * 2 + 1] << endl;
212 cout <<
"pair_embeddings:" << endl;
213 for (i = 0; i <
q; i++) {
214 for (j = 0; j <
q; j++) {
215 cout << setw(4) << i << setw(4) << j << setw(4)
216 << pair_embedding[i *
q + j] << endl;
222 int *components,
int *embedding,
int *pair_embedding)
224 int q, i, j, a, b, aa, bb, c;
229 for (j = 0; j <
q; j++) {
233 cout <<
"\\\\" << endl;
234 cout <<
"\\hline" << endl;
235 for (i = 0; i <
q; i++) {
244 for (j = 0; j <
q; j++) {
256 cout <<
"\\\\" << endl;
265 cout <<
"finite_field::print_indicator_square_nonsquare "
266 "the characteristic is two" << endl;
299 width, symbol_for_print);
319 width, symbol_for_print);
324 int a,
int f_exponential,
int width, std::string &symbol)
330 if (symbol == NULL) {
331 cout <<
"finite_field::print_element_with_symbol "
332 "symbol == NULL" << endl;
351 ost <<
"^{" << b <<
"}";
359 ost << setw((
int) width) << a;
364 int a,
int f_exponential,
int width, std::string &symbol)
370 if (symbol == NULL) {
371 cout <<
"finite_field::print_element_with_symbol_str "
372 "symbol == NULL" << endl;
391 ost <<
"^{" << b <<
"}";
399 ost << setw((
int) width) << a;
407 for (i = 0; i < len; i++) {
417 int *v,
int len, std::string &symbol_for_print)
421 for (i = 0; i < len; i++) {
423 cout <<
"finite_field::int_vec_print_elements_exponential v[i] >= q" << endl;
424 cout <<
"v[i]=" << v[i] << endl;
429 10 , symbol_for_print);
441 sprintf(str,
"GF_q%d",
q);
443 fname.append(
"_addition_table.csv");
450 sprintf(str,
"GF_q%d",
q);
452 fname.append(
"_multiplication_table.csv");
459 sprintf(str,
"GF_q%d",
q);
461 fname.append(
"_addition_table_reordered.csv");
468 sprintf(str,
"GF_q%d",
q);
470 fname.append(
"_multiplication_table_reordered.csv");
475 int f_v = (verbose_level >= 1);
481 for (i = 0; i <
q; i++) {
482 for (j = 0; j <
q; j++) {
492 cout <<
"Written file " << fname <<
" of size " << Fio.
file_size(fname) << endl;
499 int f_v = (verbose_level >= 1);
505 for (i = 0; i <
q - 1; i++) {
506 for (j = 0; j <
q - 1; j++) {
507 k =
mult(1 + i, 1 + j);
508 M[i * (
q - 1) + j] = k;
516 cout <<
"Written file " << fname <<
" of size " << Fio.
file_size(fname) << endl;
525 cout <<
"finite_field::addition_table_reordered_save_csv !f_has_table" << endl;
542 cout <<
"finite_field::multiplication_table_reordered_save_csv !f_has_table" << endl;
556 int f_elements_exponential, std::string &symbol_for_print)
561 f <<
"\\begin{array}{|r|*{" <<
q <<
"}{r}|}" << endl;
562 f <<
"\\hline" << endl;
564 for (i = 0; i <
q; i++) {
571 f <<
"\\hline" << endl;
572 for (i = 0; i <
q; i++) {
576 for (j = 0; j <
q; j++) {
585 f <<
"\\hline" << endl;
586 f <<
"\\end{array}" << endl;
590 int f_elements_exponential, std::string &symbol_for_print)
595 f <<
"\\begin{array}{|r|*{" <<
q - 1 <<
"}{r}|}" << endl;
596 f <<
"\\hline" << endl;
598 for (i = 1; i <
q; i++) {
605 f <<
"\\hline" << endl;
606 for (i = 1; i <
q; i++) {
611 for (j = 1; j <
q; j++) {
620 f <<
"\\hline" << endl;
621 f <<
"\\end{array}" << endl;
625 std::string &symbol_for_print,
int *M,
int m,
int n)
629 f <<
"\\begin{array}{*{" << n <<
"}{r}}" << endl;
630 for (i = 0; i < m; i++) {
631 for (j = 0; j < n; j++) {
634 f_elements_exponential, 10 ,
642 f <<
"\\end{array}" << endl;
647 int *power_table,
int len)
652 for (i = 1; i < len; i++) {
660 int f_v = (verbose_level >= 1);
663 cout <<
"finite_field::cheat_sheet" << endl;
666 int f_add_mult_table =
TRUE;
668 if (f_add_mult_table) {
671 cout <<
"finite_field::cheat_sheet !f_has_table" << endl;
695 cout <<
"finite_field::cheat_sheet done" << endl;
702 int f_v = (verbose_level >= 1);
708 cout <<
"finite_field::cheat_sheet_subfields" << endl;
713 f <<
"The polynomial used to define the field is : ";
724 f <<
"$ = " <<
my_poly <<
"\\\\" << endl;
727 f <<
"$Z_i = \\log_\\alpha (1 + \\alpha^i)$\\\\" << endl;
737 cout <<
"finite_field::cheat_sheet_subfields done" << endl;
743 int f_v = (verbose_level >= 1);
748 cout <<
"finite_field::report_subfields" << endl;
750 ost <<
"\\subsection*{Subfields}" << endl;
752 ost <<
"\\begin{array}{|r|r|r|}" << endl;
753 ost <<
"\\hline" << endl;
754 ost <<
"\\mbox{Subfield} & \\mbox{Polynomial} & \\mbox{Numerical Rank} \\\\"
756 ost <<
"\\hline" << endl;
757 for (h = 2; h <
e; h++) {
761 ost <<
"\\hline" << endl;
781 ost <<
"\\bbF_{" << NT.
i_power_j(
p, h) <<
"} & ";
783 ost <<
" & " << poly;
784 ost <<
"\\\\" << endl;
790 ost <<
"\\hline" << endl;
791 ost <<
"\\end{array}" << endl;
794 cout <<
"finite_field::report_subfields done" << endl;
800 int f_v = (verbose_level >= 1);
805 cout <<
"finite_field::report_subfields_detailed" << endl;
807 ost <<
"\\subsection*{Subfields in Detail}" << endl;
808 for (h = 1; h <
e; h++) {
813 long int poly_numeric, q0;
825 sprintf(str,
"%ld", poly_numeric);
828 poly_text.assign(str);
835 Sub->
init(
this , Fq, verbose_level);
839 ost <<
"Subfield ${\\mathbb F}_{" << q0 <<
"}$ generated by polynomial " << poly_numeric <<
":\\\\" << endl;
847 cout <<
"finite_field::report_subfields_detailed done" << endl;
854 int f_v = (verbose_level >= 1);
858 cout <<
"finite_field::cheat_sheet_addition_table" << endl;
866 const char *symbol_for_print =
"\\alpha";
872 f <<
"\\qquad" << endl;
880 f <<
"Addition table omitted" << endl;
886 cout <<
"finite_field::cheat_sheet_addition_table done" << endl;
892 int f_v = (verbose_level >= 1);
896 cout <<
"finite_field::cheat_sheet_multiplication_table" << endl;
904 const char *symbol_for_print =
"\\alpha";
910 f <<
"\\qquad" << endl;
918 f <<
"Multiplication table omitted" << endl;
924 cout <<
"finite_field::cheat_sheet_multiplication_table done" << endl;
942 ost <<
"\\subsection*{Cyclic structure}" << endl;
948 for (i = 0; i < len; i++) {
950 if (i && (i % 32) == 0) {
959 ost << i <<
" & " << t <<
"^{" << i <<
"} & " << Powers[i] <<
" & ";
960 for (j =
e - 1; j >= 0; j--) {
964 if (f_with_polynomials) {
971 ost <<
"\\\\" << endl;
983 ost <<
"\\begin{array}{|r|r|r|r|";
984 if (f_with_polynomials) {
988 ost <<
"\\hline" << endl;
991 ost <<
"i & \\alpha^i & \\alpha^i & \\mbox{vector}";
992 if (f_with_polynomials) {
993 ost <<
"& \\mbox{reduced rep.}";
995 ost <<
"\\\\" << endl;
996 ost <<
"\\hline" << endl;
1001 ost <<
"\\hline" << endl;
1002 ost <<
"\\end{array}" << endl;
1016 ost <<
"\\subsection*{Table of Elements of ${\\mathbb F}_{" <<
q <<
"}$}" << endl;
1017 ost <<
"$$" << endl;
1018 ost <<
"\\begin{array}{|r|r|r|}" << endl;
1019 ost <<
"\\hline" << endl;
1023 for (i = 0; i <
q; i++) {
1025 ost << setw(3) << i;
1030 for (j =
e - 1; j >= 0; j--) {
1037 ost <<
"\\\\" << endl;
1046 ost <<
"\\hline" << endl;
1047 ost <<
"\\end{array}" << endl;
1048 ost <<
"$$" << endl;
1059 for (j =
e - 1; j >= 0; j--) {
1071 if (j == 0 || v[j] > 1) {
1072 ost << setw(3) << v[j];
1078 ost <<
"^{" << j <<
"}";
1100 if ((
e % 2) == 0 &&
e > 2) {
1103 if ((
e % 3) == 0 &&
e > 3) {
1112 for (i = 0; i <
q; i++) {
1114 f << setw(3) << i <<
" & ";
1116 for (j =
e - 1; j >= 0; j--) {
1128 if (j == 0 || v[j] > 1) {
1129 f << setw(3) << v[j];
1135 f <<
"^{" << j <<
"}";
1145 10 , symbol_for_print);
1153 f <<
" & \\mbox{DNE}";
1163 f <<
" & \\mbox{DNE}";
1175 f <<
" & \\mbox{DNE}";
1191 if ((
e % 2) == 0 &&
e > 2) {
1195 if ((
e % 3) == 0 &&
e > 3) {
1201 f <<
"\\\\" << endl;
1203 if ((i % 25) == 0 && i) {
1218 f <<
"\\begin{array}{|*{" << nb_cols <<
"}{r|}}" << endl;
1219 f <<
"\\hline" << endl;
1220 f <<
"i & \\gamma_i ";
1221 f <<
"& -\\gamma_i";
1222 f <<
"& \\gamma_i^{-1}";
1223 f <<
"& \\log_\\alpha(\\gamma_i)";
1227 f <<
"& \\phi(\\gamma_i) ";
1228 f <<
"& T(\\gamma_i) ";
1229 f <<
"& N(\\gamma_i) ";
1231 if ((
e % 2) == 0 &&
e > 2) {
1232 f <<
"& T_2(\\gamma_i) ";
1233 f <<
"& N_2(\\gamma_i) ";
1235 if ((
e % 3) == 0 &&
e > 3) {
1236 f <<
"& T_3(\\gamma_i) ";
1237 f <<
"& N_3(\\gamma_i) ";
1239 f <<
"\\\\" << endl;
1240 f <<
"\\hline" << endl;
1245 f <<
"\\hline" << endl;
1246 f <<
"\\end{array}" << endl;
1252 std::ostream &ost,
long int *Pts,
int nb_pts,
int len)
1255 ost <<
"{\\renewcommand*{\\arraystretch}{1.5}" << endl;
1256 ost <<
"$$" << endl;
1260 ost <<
"$$}%" << endl;
1264 std::ostream &ost,
long int *Pts,
int nb_pts,
int len)
1270 ost <<
"\\begin{array}{|c|c|c|}" << endl;
1271 ost <<
"\\hline" << endl;
1272 ost <<
"i & a_i & P_{a_i}\\\\" << endl;
1273 ost <<
"\\hline" << endl;
1274 ost <<
"\\hline" << endl;
1275 for (i = 0; i < nb_pts; i++) {
1277 ost << i <<
" & " << Pts[i] <<
" & ";
1279 ost <<
"\\\\" << endl;
1280 if (((i + 1) % 30) == 0) {
1281 ost <<
"\\hline" << endl;
1282 ost <<
"\\end{array}" << endl;
1283 ost <<
"$$}%" << endl;
1284 ost <<
"$$" << endl;
1285 ost <<
"\\begin{array}{|c|c|c|}" << endl;
1286 ost <<
"\\hline" << endl;
1287 ost <<
"i & a_i & P_{a_i}\\\\" << endl;
1288 ost <<
"\\hline" << endl;
1289 ost <<
"\\hline" << endl;
1292 ost <<
"\\hline" << endl;
1293 ost <<
"\\end{array}" << endl;
1298 std::ostream &ost,
long int *Pts,
int nb_pts,
int len)
1304 ost <<
"\\begin{array}{|c|}" << endl;
1305 ost <<
"\\hline" << endl;
1306 ost <<
"P_i\\\\" << endl;
1307 ost <<
"\\hline" << endl;
1308 ost <<
"\\hline" << endl;
1309 for (i = 0; i < nb_pts; i++) {
1312 ost <<
"\\\\" << endl;
1313 if (((i + 1) % 30) == 0) {
1314 ost <<
"\\hline" << endl;
1315 ost <<
"\\end{array}" << endl;
1316 ost <<
"$$}%" << endl;
1317 ost <<
"$$" << endl;
1318 ost <<
"\\begin{array}{|c|}" << endl;
1319 ost <<
"\\hline" << endl;
1320 ost <<
"P_i\\\\" << endl;
1321 ost <<
"\\hline" << endl;
1322 ost <<
"\\hline" << endl;
1325 ost <<
"\\hline" << endl;
1326 ost <<
"\\end{array}" << endl;
1339 fname2.assign(fname);
1343 ofstream fp(fname2);
1345 fp <<
"G,I:=PGammaL(" << d <<
"," <<
q
1346 <<
");F:=GF(" <<
q <<
");" << endl;
1347 fp <<
"S:={};" << endl;
1348 fp <<
"a := F.1;" << endl;
1349 for (h = 0; h < nb_pts; h++) {
1354 fp <<
"Include(~S,Index(I,[";
1355 for (i = 0; i < d; i++) {
1371 fp <<
"]));" << endl;
1373 fp <<
"Stab := Stabilizer(G,S);" << endl;
1374 fp <<
"Size(Stab);" << endl;
1379 cout <<
"Written file " << fname2 <<
" of size "
1393 fname2.assign(fname);
1397 ofstream fp(fname2);
1399 fp <<
"LoadPackage(\"fining\");" << endl;
1400 fp <<
"pg := ProjectiveSpace(" << d - 1 <<
"," <<
q <<
");" << endl;
1401 fp <<
"S:=[" << endl;
1402 for (h = 0; h < nb_pts; h++) {
1408 for (i = 0; i < d; i++) {
1411 fp <<
"0*Z(" <<
q <<
")";
1414 fp <<
"Z(" <<
q <<
")^0";
1418 fp <<
"Z(" <<
q <<
")^" << b;
1425 if (h < nb_pts - 1) {
1431 fp <<
"S := List(S,x -> VectorSpaceToElement(pg,x));" << endl;
1432 fp <<
"g := CollineationGroup(pg);" << endl;
1433 fp <<
"stab := Stabilizer(g,Set(S),OnSets);" << endl;
1434 fp <<
"Size(stab);" << endl;
1438 cout <<
"Written file " << fname2 <<
" of size "
1442LoadPackage(
"fining");
1443pg := ProjectiveSpace(2,4);
1444#points := Points(pg);
1445#pointslist := AsList(points);
1446#Display(pointslist[1]);
1447frame := [[1,0,0],[0,1,0],[0,0,1],[1,1,1]]*Z(2)^0;
1448frame := List(frame,x -> VectorSpaceToElement(pg,x));
1449pairs := Combinations(frame,2);
1450secants := List(pairs,
p -> Span(
p[1],
p[2]));
1451leftover := Filtered(pointslist,t->not ForAny(secants,s->t in s));
1452hyperoval := Union(frame,leftover);
1453g := CollineationGroup(pg);
1454stab := Stabilizer(g,Set(hyperoval),OnSets);
1455StructureDescription(stab);
1466 ost <<
"\\left[" << endl;
1467 ost <<
"\\begin{array}{*{" << n <<
"}{r}}" << endl;
1468 for (i = 0; i < m; i++) {
1469 for (j = 0; j < n; j++) {
1473 if (is_prime(
GFq->q)) {
1474 ost << setw(w) << a <<
" ";
1487 ost <<
"\\\\" << endl;
1489 ost <<
"\\end{array}" << endl;
1490 ost <<
"\\right]" << endl;
1498 ost <<
"\\left[" << endl;
1499 ost <<
"\\begin{array}{*{" << n <<
"}{r}}" << endl;
1500 for (i = 0; i < m; i++) {
1501 for (j = 0; j < n; j++) {
1509 ost <<
"\\\\" << endl;
1511 ost <<
"\\end{array}" << endl;
1512 ost <<
"\\right]" << endl;
void multiplication_table_reordered_save_csv(std::string &fname, int verbose_level)
void print_add_mult_tables(std::ostream &ost)
void print_add_mult_tables_in_C(std::string &fname_base)
void print_tables_extension_field(std::string &poly)
void addition_table_reordered_save_csv(std::string &fname, int verbose_level)
void display_T2(std::ostream &ost)
void cheat_sheet_power_table_top(std::ostream &ost, int f_with_polynomials, int verbose_level)
void print_element_with_symbol_str(std::stringstream &ost, int a, int f_exponential, int width, std::string &symbol)
void cheat_sheet_main_table(std::ostream &f, int verbose_level)
void export_gap(int d, long int *Pts, int nb_pts, std::string &fname)
void cheat_sheet_power_table(std::ostream &f, int f_with_polynomials, int verbose_level)
void cheat_sheet_addition_table(std::ostream &f, int verbose_level)
void PG_element_normalize_from_front(int *v, int stride, int len)
int f_print_as_exponentials
void cheat_sheet_table_of_elements(std::ostream &ost, int verbose_level)
void print_minimum_polynomial(int p, std::string &polynomial)
void multiplication_table_save_csv(int verbose_level)
void addition_table_reordered_save_csv(int verbose_level)
void display_N3(std::ostream &ost)
void print_indicator_square_nonsquare(int a)
void print_matrix_latex(std::ostream &ost, int *A, int m, int n)
void report_subfields(std::ostream &f, int verbose_level)
void export_magma(int d, long int *Pts, int nb_pts, std::string &fname)
void print_embedding_tex(finite_field &subfield, int *components, int *embedding, int *pair_embedding)
void report_subfields_detailed(std::ostream &ost, int verbose_level)
void cheat_sheet_power_table_bottom(std::ostream &ost, int f_with_polynomials, int verbose_level)
void print_element_with_symbol(std::ostream &ost, int a, int f_exponential, int width, std::string &symbol)
void print_matrix_numerical_latex(std::ostream &ost, int *A, int m, int n)
void make_fname_addition_table_csv(std::string &fname)
void cheat_sheet(std::ostream &f, int verbose_level)
void display_table_of_projective_points(std::ostream &ost, long int *Pts, int nb_pts, int len)
void print_detailed(int f_add_mult_table)
void latex_addition_table(std::ostream &f, int f_elements_exponential, std::string &symbol_for_print)
void display_T3(std::ostream &ost)
void display_table_of_projective_points_easy(std::ostream &ost, long int *Pts, int nb_pts, int len)
void display_N2(std::ostream &ost)
void int_vec_print_elements_exponential(std::ostream &ost, int *v, int len, std::string &symbol_for_print)
void display_table_of_projective_points2(std::ostream &ost, long int *Pts, int nb_pts, int len)
void print_element_str(std::stringstream &ost, int a)
int frobenius_power(int a, int frob_power)
void report(std::ostream &ost, int verbose_level)
void cheat_sheet_main_table_bottom(std::ostream &f)
void addition_table_save_csv(int verbose_level)
void make_fname_addition_table_reordered_csv(std::string &fname)
void make_fname_multiplication_table_csv(std::string &fname)
void init_override_polynomial(int q, std::string &poly, int f_without_tables, int verbose_level)
void PG_element_unrank_modified_lint(int *v, int stride, int len, long int a)
void int_vec_print_field_elements(std::ostream &ost, int *v, int len)
void cheat_sheet_main_table_top(std::ostream &f, int nb_cols)
int absolute_trace(int i)
void latex_matrix(std::ostream &f, int f_elements_exponential, std::string &symbol_for_print, int *M, int m, int n)
void cheat_sheet_subfields(std::ostream &f, int verbose_level)
void print_embedding(finite_field &subfield, int *components, int *embedding, int *pair_embedding)
void print_element(std::ostream &ost, int a)
void cheat_sheet_multiplication_table(std::ostream &f, int verbose_level)
void latex_multiplication_table(std::ostream &f, int f_elements_exponential, std::string &symbol_for_print)
void print_integer_matrix_zech(std::ostream &ost, int *p, int m, int n)
void make_fname_multiplication_table_reordered_csv(std::string &fname)
void multiplication_table_reordered_save_csv(int verbose_level)
long int compute_subfield_polynomial(int order_subfield, int f_latex, std::ostream &ost, int verbose_level)
void power_table(int t, int *power_table, int len)
void print_element_as_polynomial(std::ostream &ost, int *v, int verbose_level)
a finite field as a vector space over a subfield
void report(std::ostream &ost)
void init(finite_field *FQ, finite_field *Fq, int verbose_level)
various functions related to geometries
void AG_element_unrank(int q, int *v, int stride, int len, long int a)
basic number theoretic functions
int i_power_j(int i, int j)
a collection of functions related to file io
void int_matrix_write_csv(std::string &fname, int *M, int m, int n)
long int file_size(std::string &fname)
domain of polynomials in one variable over a finite field
void delete_object(unipoly_object &p)
void create_object_by_rank(unipoly_object &p, long int rk, const char *file, int line, int verbose_level)
void create_object_by_rank_string(unipoly_object &p, std::string &rk, int verbose_level)
void print_object(unipoly_object p, std::ostream &ost)
#define Int_vec_print(A, B, C)
the orbiter library for the classification of combinatorial objects