Orbiter 2022
Combinatorial Objects
ring_theory_global.cpp
Go to the documentation of this file.
1/*
2 * ring_theory_global.cpp
3 *
4 * Created on: Jan 10, 2022
5 * Author: betten
6 */
7
8
9
10
11#include "foundations.h"
12
13
14using namespace std;
15
16
17namespace orbiter {
18namespace layer1_foundations {
19namespace ring_theory {
20
21
23{
24
25}
26
28{
29
30}
31
34 std::string &fname_code,
35 std::string &A_coeffs, std::string &B_coeffs,
36 int verbose_level)
37{
38 int f_v = (verbose_level >= 1);
39
40 if (f_v) {
41 cout << "ring_theory_global::write_code_for_division" << endl;
42 }
43
44
45 {
46 std::ofstream ost(fname_code);
47
48
49 string str;
51
52 Os.get_date(str);
53
54 ost << "/*" << endl;
55 ost << " * " << fname_code << endl;
56 ost << " *" << endl;
57 ost << " * Created on: " << str << endl;
58 ost << " * Author: Orbiter" << endl;
59 ost << " */" << endl;
60 ost << endl;
61 //ost << "#include \"orbiter.h\"" << endl;
62 ost << "#include <iostream>" << endl;
63 ost << endl;
64 ost << "using namespace std;" << endl;
65 //ost << "using namespace orbiter;" << endl;
66 ost << endl;
67 ost << "void divide(const unsigned char *A, unsigned char *R);" << endl;
68 ost << endl;
69 ost << "int main(int argc, char **argv)" << endl;
70 ost << "{" << endl;
71 ost << "\t" << endl;
72
73
74 int *data_A;
75 int *data_B;
76 int sz_A, sz_B;
77
78
79 orbiter_kernel_system::Orbiter->get_vector_from_label(A_coeffs, data_A, sz_A, verbose_level);
80 orbiter_kernel_system::Orbiter->get_vector_from_label(B_coeffs, data_B, sz_B, verbose_level);
81
82
83 int w;
84
85 w = F->log10_of_q;
86
87 unipoly_domain FX(F);
88 unipoly_object poly_A, poly_B, poly_Q, poly_R;
89
90
91 int da = sz_A - 1;
92 int db = sz_B - 1;
93 int i;
94
95 FX.create_object_of_degree(poly_A, da);
96
97 for (i = 0; i <= da; i++) {
98 FX.s_i(poly_A, i) = data_A[i];
99 }
100
101 FX.create_object_of_degree(poly_B, da);
102
103 for (i = 0; i <= db; i++) {
104 FX.s_i(poly_B, i) = data_B[i];
105 }
106
107
108 FREE_int(data_A);
109 FREE_int(data_B);
110
111
112
113 if (f_v) {
114 cout << "A(X)=";
115 FX.print_object(poly_A, cout);
116 cout << endl;
117 }
118
119
120 if (f_v) {
121 cout << "B(X)=";
122 FX.print_object(poly_B, cout);
123 cout << endl;
124 }
125
126 FX.create_object_of_degree(poly_Q, da);
127
128 FX.create_object_of_degree(poly_R, da);
129
130 //FX.division_with_remainder(
131 // poly_A, poly_B,
132 // poly_Q, poly_R,
133 // verbose_level);
134
135
136 int *ra = (int *) poly_A;
137 int *rb = (int *) poly_B;
138 int *A = ra + 1;
139 int *B = rb + 1;
140
141 //int da, db;
142
143 if (f_v) {
144 cout << "ring_theory_global::write_code_for_division" << endl;
145 }
146 if (da != FX.degree(poly_A)) {
147 cout << "ring_theory_global::write_code_for_division da != FX.degree(poly_A)" << endl;
148 exit(1);
149 }
150 if (db != FX.degree(poly_B)) {
151 cout << "ring_theory_global::write_code_for_division db != FX.degree(poly_B)" << endl;
152 exit(1);
153 }
154
155 int dq = da - db;
156
157
158 int j;
159 int a, b;
160
161
162 ost << "\tconst unsigned char A[] = {" << endl;
163
164
165 ost << "\t\t";
166 for (i = 0; i <= da; i++) {
167 a = A[i];
168 ost << a << ",";
169 if (((i + 1) % 25) == 0) {
170 ost << endl;
171 ost << "\t\t";
172 }
173 }
174 ost << endl;
175
176 ost << "\t};" << endl;
177
178 ost << endl;
179
180 ost << "\tunsigned char R[" << db + 1 << "] = {" << endl;
181 ost << "\t\t";
182 for (i = 0; i <= db; i++) {
183 ost << "0";
184 if (i < db) {
185 ost << ",";
186 }
187 }
188 ost << "};" << endl;
189
190 ost << endl;
191
192 ost << "\t" << endl;
193 ost << "\tdivide(A, R);" << endl;
194
195 ost << endl;
196
197
198 ost << "\tint i;" << endl;
199 ost << "\tfor (i = 0; i <= " << db << "; i++) {" << endl;
200 ost << "\t\tcout << (int) R[i] << \",\";" << endl;
201 ost << "\t}" << endl;
202 ost << "\tcout << endl;" << endl;
203
204 ost << endl;
205
206 ost << "}" << endl;
207 ost << endl;
208
209
210
211 ost << "\t// the size of the array B is " << F->q - 1 << " x " << db + 1 << endl;
212 ost << "const unsigned char B[] = {" << endl;
213
214
215 for (i = 1; i < F->q; i++) {
216 ost << "\t";
217 for (j = 0; j <= db; j++) {
218 a = B[j];
219 b = F->mult(a, i);
220 ost << setw(w) << b << ",";
221 }
222 ost << endl;
223 }
224
225 ost << "};" << endl;
226 ost << endl;
227
228
229 ost << "void divide(const unsigned char *in, unsigned char *out)" << endl;
230 ost << "{" << endl;
231
232
233 ost << "\tunsigned char R[" << da + 1 << "];" << endl;
234 ost << "\tint i, j, ii, jj;" << endl;
235 ost << "\tint x;" << endl;
236
237 // copy input over to R[]:
238
239 ost << "\tfor (i = 0; i < " << da + 1 << "; i++) {" << endl;
240 ost << "\t\tR[i] = in[i];" << endl;
241 ost << "\t}" << endl;
242
243
244 //Orbiter->Int_vec.zero(Q, dq + 1);
245
246 ost << endl;
247
248
249
250 ost << "\tfor (i = " << da << ", j = " << dq << "; i >= " << db << "; i--, j--) {" << endl;
251 ost << "\t\tx = R[i];" << endl;
252 ost << "\t\tif (x == 0) {" << endl;
253 ost << "\t\t\tcontinue;" << endl;
254 ost << "\t\t}" << endl;
255 ost << "\t\t//cout << \"i=\" << i << \" x=\" << x << endl;" << endl;
256 ost << "\t\tx--;" << endl;
257 ost << "\t\tfor (ii = i, jj = " << db << "; jj >= 0; ii--, jj--) {" << endl;
258 ost << "\t\t\tR[ii] ^= B[x * " << db + 1 << " + jj];" << endl;
259 ost << "\t\t}" << endl;
260 ost << "\t}" << endl;
261
262#if 0
263 for (i = da, j = dq; i >= db; i--, j--) {
264 x = R[i];
265 c = F->mult(x, pivot_inv);
266 Q[j] = c;
267 c = F->negate(c);
268 //cout << "i=" << i << " c=" << c << endl;
269 for (ii = i, jj = db; jj >= 0; ii--, jj--) {
270 d = B[jj];
271 d = F->mult(c, d);
272 R[ii] = F->add(d, R[ii]);
273 }
274 if (R[i] != 0) {
275 cout << "unipoly::write_code_for_division: R[i] != 0" << endl;
276 exit(1);
277 }
278 //cout << "i=" << i << endl;
279 //cout << "q="; print_object((unipoly_object)
280 // rq, cout); cout << endl;
281 //cout << "r="; print_object(r, cout); cout << endl;
282 }
283#endif
284
285
286 // copy output over from R[] to out:
287
288 ost << endl;
289
290 ost << "\tfor (i = " << db << "; i >= 0; i--) {" << endl;
291 ost << "\t\tout[i] = R[i];" << endl;
292 ost << "\t}" << endl;
293
294 ost << "}" << endl;
295
296 }
297
299
300 cout << "Written file " << fname_code << " of size " << Fio.file_size(fname_code) << endl;
301
302 if (f_v) {
303 cout << "ring_theory_global::write_code_for_division done" << endl;
304 }
305}
306
307
310 std::string &A_coeffs, std::string &B_coeffs,
311 int verbose_level)
312{
313 int f_v = (verbose_level >= 1);
314
315 if (f_v) {
316 cout << "ring_theory_global::polynomial_division" << endl;
317 }
318
319 int *data_A;
320 int *data_B;
321 int sz_A, sz_B;
322
323
324 orbiter_kernel_system::Orbiter->get_vector_from_label(A_coeffs, data_A, sz_A, verbose_level);
325 orbiter_kernel_system::Orbiter->get_vector_from_label(B_coeffs, data_B, sz_B, verbose_level);
326
327
328
329
330 unipoly_domain FX(F);
331 unipoly_object A, B, Q, R;
332
333
334 int da = sz_A - 1;
335 int db = sz_B - 1;
336 int i;
337
338 FX.create_object_of_degree(A, da);
339
340 for (i = 0; i <= da; i++) {
341 FX.s_i(A, i) = data_A[i];
342 }
343
344 FX.create_object_of_degree(B, da);
345
346 for (i = 0; i <= db; i++) {
347 FX.s_i(B, i) = data_B[i];
348 }
349
350 if (f_v) {
351 cout << "A(X)=";
352 FX.print_object(A, cout);
353 cout << endl;
354 }
355
356
357 if (f_v) {
358 cout << "B(X)=";
359 FX.print_object(B, cout);
360 cout << endl;
361 }
362
363 FX.create_object_of_degree(Q, da);
364
365 FX.create_object_of_degree(R, da);
366
367
368 if (f_v) {
369 cout << "ring_theory_global::polynomial_division "
370 "before FX.division_with_remainder" << endl;
371 }
372
374 A, B,
375 Q, R,
376 verbose_level);
377
378 if (f_v) {
379 cout << "ring_theory_global::polynomial_division "
380 "after FX.division_with_remainder" << endl;
381 }
382
383 if (f_v) {
384 cout << "A(X)=";
385 FX.print_object(A, cout);
386 cout << endl;
387
388 cout << "Q(X)=";
389 FX.print_object(Q, cout);
390 cout << endl;
391
392 cout << "R(X)=";
393 FX.print_object(R, cout);
394 cout << endl;
395 }
396
397 FREE_int(data_A);
398 FREE_int(data_B);
399
400 if (f_v) {
401 cout << "ring_theory_global::polynomial_division done" << endl;
402 }
403}
404
407 std::string &A_coeffs, std::string &B_coeffs, int verbose_level)
408{
409 int f_v = (verbose_level >= 1);
410
411 if (f_v) {
412 cout << "ring_theory_global::extended_gcd_for_polynomials" << endl;
413 }
414
415
416
417 int *data_A;
418 int *data_B;
419 int sz_A, sz_B;
420
421
422 orbiter_kernel_system::Orbiter->get_vector_from_label(A_coeffs, data_A, sz_A, verbose_level);
423 orbiter_kernel_system::Orbiter->get_vector_from_label(B_coeffs, data_B, sz_B, verbose_level);
424
425
427
428
429
430
431 unipoly_domain FX(F);
432 unipoly_object A, B, U, V, G;
433
434
435 int da = sz_A - 1;
436 int db = sz_B - 1;
437 int i;
438
439 FX.create_object_of_degree(A, da);
440
441 for (i = 0; i <= da; i++) {
442 if (data_A[i] < 0 || data_A[i] >= F->q) {
443 data_A[i] = NT.mod(data_A[i], F->q);
444 }
445 FX.s_i(A, i) = data_A[i];
446 }
447
448 FX.create_object_of_degree(B, da);
449
450 for (i = 0; i <= db; i++) {
451 if (data_B[i] < 0 || data_B[i] >= F->q) {
452 data_B[i] = NT.mod(data_B[i], F->q);
453 }
454 FX.s_i(B, i) = data_B[i];
455 }
456
457 if (f_v) {
458 cout << "A(X)=";
459 FX.print_object(A, cout);
460 cout << endl;
461
462
463 cout << "B(X)=";
464 FX.print_object(B, cout);
465 cout << endl;
466 }
467
468 FX.create_object_of_degree(U, da);
469
470 FX.create_object_of_degree(V, da);
471
472 FX.create_object_of_degree(G, da);
473
474
475 if (f_v) {
476 cout << "ring_theory_global::extended_gcd_for_polynomials "
477 "before FX.extended_gcd" << endl;
478 }
479
480 {
481 FX.extended_gcd(
482 A, B,
483 U, V, G, verbose_level);
484 }
485
486 if (f_v) {
487 cout << "ring_theory_global::extended_gcd_for_polynomials "
488 "after FX.extended_gcd" << endl;
489 }
490
491 if (f_v) {
492 cout << "U(X)=";
493 FX.print_object(U, cout);
494 cout << endl;
495
496 cout << "V(X)=";
497 FX.print_object(V, cout);
498 cout << endl;
499
500 cout << "G(X)=";
501 FX.print_object(G, cout);
502 cout << endl;
503
504 cout << "deg G(X) = " << FX.degree(G) << endl;
505 }
506
507 if (FX.degree(G) == 0) {
508 int c, cv, d;
509
510 c = FX.s_i(G, 0);
511 if (c != 1) {
512 if (f_v) {
513 cout << "normalization:" << endl;
514 }
515 cv = F->inverse(c);
516 if (f_v) {
517 cout << "cv=" << cv << endl;
518 }
519
520 d = FX.degree(U);
521 for (i = 0; i <= d; i++) {
522 FX.s_i(U, i) = F->mult(cv, FX.s_i(U, i));
523 }
524
525 d = FX.degree(V);
526 for (i = 0; i <= d; i++) {
527 FX.s_i(V, i) = F->mult(cv, FX.s_i(V, i));
528 }
529
530 d = FX.degree(G);
531 for (i = 0; i <= d; i++) {
532 FX.s_i(G, i) = F->mult(cv, FX.s_i(G, i));
533 }
534
535
536
537 if (f_v) {
538 cout << "after normalization:" << endl;
539
540 cout << "U(X)=";
541 FX.print_object(U, cout);
542 cout << endl;
543
544 cout << "V(X)=";
545 FX.print_object(V, cout);
546 cout << endl;
547
548 cout << "G(X)=";
549 FX.print_object(G, cout);
550 cout << endl;
551 }
552 }
553
554 }
555
556 if (f_v) {
557 cout << "ring_theory_global::extended_gcd_for_polynomials done" << endl;
558 }
559}
560
561
564 std::string &A_coeffs, std::string &B_coeffs, std::string &M_coeffs,
565 int verbose_level)
566{
567 int f_v = (verbose_level >= 1);
568
569 if (f_v) {
570 cout << "ring_theory_global::polynomial_mult_mod" << endl;
571 }
572
573 int *data_A;
574 int *data_B;
575 int *data_M;
576 int sz_A, sz_B, sz_M;
577
578
579 orbiter_kernel_system::Orbiter->get_vector_from_label(A_coeffs, data_A, sz_A, verbose_level);
580 orbiter_kernel_system::Orbiter->get_vector_from_label(B_coeffs, data_B, sz_B, verbose_level);
581 orbiter_kernel_system::Orbiter->get_vector_from_label(M_coeffs, data_M, sz_M, verbose_level);
582
584
585
586
587
588 unipoly_domain FX(F);
589 unipoly_object A, B, M, C;
590
591
592 int da = sz_A - 1;
593 int db = sz_B - 1;
594 int dm = sz_M - 1;
595 int i;
596
597 FX.create_object_of_degree(A, da);
598
599 for (i = 0; i <= da; i++) {
600 if (data_A[i] < 0 || data_A[i] >= F->q) {
601 data_A[i] = NT.mod(data_A[i], F->q);
602 }
603 FX.s_i(A, i) = data_A[i];
604 }
605
606 FX.create_object_of_degree(B, da);
607
608 for (i = 0; i <= db; i++) {
609 if (data_B[i] < 0 || data_B[i] >= F->q) {
610 data_B[i] = NT.mod(data_B[i], F->q);
611 }
612 FX.s_i(B, i) = data_B[i];
613 }
614
615 FX.create_object_of_degree(M, dm);
616
617 for (i = 0; i <= dm; i++) {
618 if (data_M[i] < 0 || data_M[i] >= F->q) {
619 data_M[i] = NT.mod(data_M[i], F->q);
620 }
621 FX.s_i(M, i) = data_M[i];
622 }
623
624 if (f_v) {
625 cout << "A(X)=";
626 FX.print_object(A, cout);
627 cout << endl;
628
629
630 cout << "B(X)=";
631 FX.print_object(B, cout);
632 cout << endl;
633
634 cout << "M(X)=";
635 FX.print_object(M, cout);
636 cout << endl;
637 }
638
639 FX.create_object_of_degree(C, da + db);
640
641
642
643 if (f_v) {
644 cout << "ring_theory_global::polynomial_mult_mod before FX.mult_mod" << endl;
645 }
646
647 {
648 FX.mult_mod(A, B, C, M, verbose_level);
649 }
650
651 if (f_v) {
652 cout << "ring_theory_global::polynomial_mult_mod after FX.mult_mod" << endl;
653 }
654
655 if (f_v) {
656 cout << "C(X)=";
657 FX.print_object(C, cout);
658 cout << endl;
659
660 cout << "deg C(X) = " << FX.degree(C) << endl;
661 }
662
663 if (f_v) {
664 cout << "ring_theory_global::polynomial_mult_mod done" << endl;
665 }
666}
667
670 std::string &A_coeffs,
671 int verbose_level)
672{
673 int f_v = (verbose_level >= 1);
674
675 if (f_v) {
676 cout << "ring_theory_global::polynomial_find_roots" << endl;
677 }
678
679 int *data_A;
680 int sz_A;
681
682 Int_vec_scan(A_coeffs, data_A, sz_A);
683
685
686
687
688
689 unipoly_domain FX(F);
691
692
693 int da = sz_A - 1;
694 int i;
695
696 FX.create_object_of_degree(A, da);
697
698 for (i = 0; i <= da; i++) {
699 if (data_A[i] < 0 || data_A[i] >= F->q) {
700 data_A[i] = NT.mod(data_A[i], F->q);
701 }
702 FX.s_i(A, i) = data_A[i];
703 }
704
705
706 if (f_v) {
707 cout << "A(X)=";
708 FX.print_object(A, cout);
709 cout << endl;
710 }
711
712
713
714 if (f_v) {
715 cout << "ring_theory_global::polynomial_find_roots before FX.mult_mod" << endl;
716 }
717
718 {
719 int a, b;
720
721 for (a = 0; a < F->q; a++) {
723 A, a, 0 /* verbose_level*/);
724 if (b == 0) {
725 cout << "a root is " << a << endl;
726 }
727 }
728 }
729
730 if (f_v) {
731 cout << "ring_theory_global::polynomial_find_roots after FX.mult_mod" << endl;
732 }
733
734
735 if (f_v) {
736 cout << "ring_theory_global::polynomial_find_roots done" << endl;
737 }
738}
739
742 long int rk0, long int rk1, int verbose_level)
743{
744 int f_v = (verbose_level >= 1);
747 long int rk;
748 int f_is_irred, f_is_primitive;
749 int f, i;
750 long int len, idx;
751 long int *Table;
752 longinteger_object Q, m1, Qm1;
753
754 if (f_v) {
755 cout << "ring_theory_global::sift_polynomials" << endl;
756 }
757 unipoly_domain D(F);
758
759 len = rk1 - rk0;
760 Table = NEW_lint(len * 3);
761 for (rk = rk0; rk < rk1; rk++) {
762
763 idx = rk - rk0;
764
765 D.create_object_by_rank(p, rk,
766 __FILE__, __LINE__, 0 /* verbose_level*/);
767 if (f_v) {
768 cout << "rk=" << rk << " poly=";
769 D.print_object(p, cout);
770 cout << endl;
771 }
772
773
774 int nb_primes;
775 longinteger_object *primes;
776 int *exponents;
777
778
779 f = D.degree(p);
780 Q.create(F->q, __FILE__, __LINE__);
781 m1.create(-1, __FILE__, __LINE__);
782 ZZ.power_int(Q, f);
783 ZZ.add(Q, m1, Qm1);
784 if (f_v) {
785 cout << "ring_theory_global::sift_polynomials Qm1 = " << Qm1 << endl;
786 }
788 primes, exponents, verbose_level - 2);
789 if (f_v) {
790 cout << "ring_theory_global::sift_polynomials after factoring "
791 << Qm1 << " nb_primes=" << nb_primes << endl;
792 cout << "primes:" << endl;
793 for (i = 0; i < nb_primes; i++) {
794 cout << i << " : " << primes[i] << endl;
795 }
796 }
797
798 f_is_irred = D.is_irreducible(p, verbose_level - 2);
799 f_is_primitive = D.is_primitive(p,
800 Qm1,
801 nb_primes, primes,
802 verbose_level);
803
804 if (f_v) {
805 cout << "rk=" << rk << " poly=";
806 D.print_object(p, cout);
807 cout << " is_irred=" << f_is_irred << " is_primitive=" << f_is_primitive << endl;
808 }
809
810 Table[idx * 3 + 0] = rk;
811 Table[idx * 3 + 1] = f_is_irred;
812 Table[idx * 3 + 2] = f_is_primitive;
813
814
815 D.delete_object(p);
816
817 FREE_int(exponents);
818 FREE_OBJECTS(primes);
819 }
820 for (idx = 0; idx < len; idx++) {
821 rk = Table[idx * 3 + 0];
822 D.create_object_by_rank(p, rk,
823 __FILE__, __LINE__, 0 /* verbose_level*/);
824 f_is_irred = Table[idx * 3 + 1];
825 f_is_primitive = Table[idx * 3 + 2];
826 if (f_v) {
827 cout << "rk=" << rk;
828 cout << " is_irred=" << f_is_irred << " is_primitive=" << f_is_primitive;
829 cout << " poly=";
830 D.print_object(p, cout);
831 cout << endl;
832 }
833 D.delete_object(p);
834 }
835
836 if (f_v) {
837 cout << "ring_theory_global::sift_polynomials done" << endl;
838 }
839
840}
841
844 long int rk0, long int rk1, int verbose_level)
845{
846 int f_v = (verbose_level >= 1);
847
848 if (f_v) {
849 cout << "ring_theory_global::mult_polynomials" << endl;
850 }
851 unipoly_domain D(F);
852
853 {
854 char str[1000];
855 string fname;
856 char title[1000];
857 char author[1000];
858
859 snprintf(str, 1000, "polynomial_mult_%ld_%ld.tex", rk0, rk1);
860 fname.assign(str);
861 snprintf(title, 1000, "Polynomial Mult");
862 //strcpy(author, "");
863 author[0] = 0;
864
865
866 {
867 ofstream ost(fname);
869
870 L.head(ost,
871 FALSE /* f_book*/,
872 TRUE /* f_title */,
873 title, author,
874 FALSE /* f_toc */,
875 FALSE /* f_landscape */,
876 TRUE /* f_12pt */,
877 TRUE /* f_enlarged_page */,
878 TRUE /* f_pagenumbers */,
879 NULL /* extra_praeamble */);
880
881
882 if (f_v) {
883 cout << "ring_theory_global::mult_polynomials before report" << endl;
884 }
885 //report(ost, verbose_level);
886
887 long int rk2;
888 D.mult_easy_with_report(rk0, rk1, rk2, ost, verbose_level);
889 ost << "$" << rk0 << " \\otimes " << rk1 << " = " << rk2 << "$\\\\" << endl;
890
891
892 if (f_v) {
893 cout << "ring_theory_global::mult_polynomials after report" << endl;
894 }
895
896
897 L.foot(ost);
898
899 }
901
902 cout << "ring_theory_global::mult_polynomials written file " << fname << " of size "
903 << Fio.file_size(fname) << endl;
904 }
905
906 if (f_v) {
907 cout << "ring_theory_global::mult_polynomials done" << endl;
908 }
909
910}
911
912
915 long int rk0, long int rk1, int verbose_level)
916{
917 int f_v = (verbose_level >= 1);
918
919 if (f_v) {
920 cout << "ring_theory_global::polynomial_division_with_report" << endl;
921 }
922 unipoly_domain D(F);
923
924 {
925 char str[1000];
926 string fname;
927 char title[1000];
928 char author[1000];
929
930 snprintf(str, 1000, "polynomial_division_%ld_%ld.tex", rk0, rk1);
931 fname.assign(str);
932 snprintf(title, 1000, "Polynomial Division");
933 //strcpy(author, "");
934 author[0] = 0;
935
936
937 {
938 ofstream ost(fname);
940
941 L.head(ost,
942 FALSE /* f_book*/,
943 TRUE /* f_title */,
944 title, author,
945 FALSE /* f_toc */,
946 FALSE /* f_landscape */,
947 TRUE /* f_12pt */,
948 TRUE /* f_enlarged_page */,
949 TRUE /* f_pagenumbers */,
950 NULL /* extra_praeamble */);
951
952
953 if (f_v) {
954 cout << "ring_theory_global::polynomial_division_with_report before division_with_remainder_numerically_with_report" << endl;
955 }
956 //report(ost, verbose_level);
957
958 long int rk2, rk3;
959 D.division_with_remainder_numerically_with_report(rk0, rk1, rk2, rk3, ost, verbose_level);
960 ost << "$" << rk0 << " / " << rk1 << " = " << rk2 << "$ Remainder $" << rk3 << "$\\\\" << endl;
961
962
963 if (f_v) {
964 cout << "ring_theory_global::polynomial_division_with_report after division_with_remainder_numerically_with_report" << endl;
965 }
966
967
968 L.foot(ost);
969
970 }
972
973 cout << "ring_theory_global::polynomial_division_with_report written file " << fname << " of size "
974 << Fio.file_size(fname) << endl;
975 }
976
977 if (f_v) {
978 cout << "ring_theory_global::polynomial_division_with_report done" << endl;
979 }
980
981}
982
985 std::string &input_file, long int rk1, int verbose_level)
986{
987 int f_v = (verbose_level >= 1);
988
989 if (f_v) {
990 cout << "ring_theory_global::polynomial_division_from_file_with_report" << endl;
991 }
992 unipoly_domain D(F);
993 {
994 char str[1000];
995 string fname;
996 char title[1000];
997 char author[1000];
998
999 snprintf(str, 1000, "polynomial_division_file_%ld.tex", rk1);
1000 fname.assign(str);
1001 snprintf(title, 1000, "Polynomial Division");
1002 //strcpy(author, "");
1003 author[0] = 0;
1004
1005
1006 {
1007 ofstream ost(fname);
1009
1010 L.head(ost,
1011 FALSE /* f_book*/,
1012 TRUE /* f_title */,
1013 title, author,
1014 FALSE /* f_toc */,
1015 FALSE /* f_landscape */,
1016 TRUE /* f_12pt */,
1017 TRUE /* f_enlarged_page */,
1018 TRUE /* f_pagenumbers */,
1019 NULL /* extra_praeamble */);
1020
1021
1022 if (f_v) {
1023 cout << "ring_theory_global::polynomial_division_from_file_with_report "
1024 "before division_with_remainder_numerically_with_report" << endl;
1025 }
1026 //report(ost, verbose_level);
1027
1028 long int rk_q, rk_r;
1029
1031 rk_q, rk_r, ost, verbose_level);
1032
1033 ost << "$ / " << rk1 << " = " << rk_q << "$ Remainder $"
1034 << rk_r << "$\\\\" << endl;
1035
1036
1037 if (f_v) {
1038 cout << "ring_theory_global::polynomial_division_from_file_with_report "
1039 "after division_with_remainder_numerically_with_report" << endl;
1040 }
1041
1042
1043 L.foot(ost);
1044
1045 }
1047
1048 cout << "ring_theory_global::polynomial_division_from_file_with_report written file " << fname << " of size "
1049 << Fio.file_size(fname) << endl;
1050 }
1051
1052
1053 if (f_v) {
1054 cout << "ring_theory_global::polynomial_division_from_file_with_report done" << endl;
1055 }
1056
1057}
1058
1061 std::string &input_file, long int rk1, int k, int verbose_level)
1062{
1063 int f_v = (verbose_level >= 1);
1064
1065 if (f_v) {
1066 cout << "ring_theory_global::polynomial_division_from_file_all_k_error_patterns_with_report" << endl;
1067 }
1068 unipoly_domain D(F);
1069 {
1070 char str[1000];
1071 string fname;
1072 char title[1000];
1073 char author[1000];
1074
1075 snprintf(str, 1000, "polynomial_division_file_all_%d_error_patterns_%ld.tex", k, rk1);
1076 fname.assign(str);
1077 snprintf(title, 1000, "Polynomial Division");
1078 //strcpy(author, "");
1079 author[0] = 0;
1080
1081
1082 {
1083 ofstream ost(fname);
1085
1086 L.head(ost,
1087 FALSE /* f_book*/,
1088 TRUE /* f_title */,
1089 title, author,
1090 FALSE /* f_toc */,
1091 FALSE /* f_landscape */,
1092 TRUE /* f_12pt */,
1093 TRUE /* f_enlarged_page */,
1094 TRUE /* f_pagenumbers */,
1095 NULL /* extra_praeamble */);
1096
1097
1098 if (f_v) {
1099 cout << "ring_theory_global::polynomial_division_from_file_all_k_error_patterns_with_report before division_with_remainder_numerically_with_report" << endl;
1100 }
1101 //report(ost, verbose_level);
1102
1103 long int *rk_q, *rk_r;
1104 int N, n, h;
1106
1107 int *set;
1108
1109 set = NEW_int(k);
1110
1111
1112
1114 rk1, k,
1115 rk_q, rk_r, n, N, ost, verbose_level);
1116
1117 ost << "$" << input_file << " / " << rk1 << "$\\\\" << endl;
1118
1119 for (h = 0; h < N; h++) {
1120 Combi.unrank_k_subset(h, set, n, k);
1121 ost << h << " : ";
1122 Int_vec_print(ost, set, k);
1123 ost << " : ";
1124 ost << rk_r[h] << "\\\\" << endl;
1125 }
1126
1127 FREE_lint(rk_q);
1128 FREE_lint(rk_r);
1129
1130 if (f_v) {
1131 cout << "ring_theory_global::polynomial_division_from_file_all_k_error_patterns_with_report after division_with_remainder_numerically_with_report" << endl;
1132 }
1133
1134 FREE_int(set);
1135
1136 L.foot(ost);
1137
1138 }
1140
1141 cout << "ring_theory_global::polynomial_division_from_file_all_k_error_patterns_with_report written file " << fname << " of size "
1142 << Fio.file_size(fname) << endl;
1143 }
1144
1145
1146 if (f_v) {
1147 cout << "ring_theory_global::polynomial_division_from_file_with_report done" << endl;
1148 }
1149
1150}
1151
1154 std::string &variety_label_txt,
1155 std::string &variety_label_tex,
1156 int variety_nb_vars, int variety_degree,
1157 std::vector<std::string> &Variety_coeffs,
1158 monomial_ordering_type Monomial_ordering_type,
1159 std::string &number_of_conditions_satisfied_fname,
1160 std::string &label_txt,
1161 std::string &label_tex,
1162 int &nb_pts, long int *&Pts,
1163 int verbose_level)
1164// creates homogeneous_polynomial_domain
1165{
1166 int f_v = (verbose_level >= 1);
1168
1169 if (f_v) {
1170 cout << "ring_theory_global::number_of_conditions_satisfied" << endl;
1171 }
1172
1173
1174 if (f_v) {
1175 cout << "Reading file " << number_of_conditions_satisfied_fname << " of size "
1176 << Fio.file_size(number_of_conditions_satisfied_fname) << endl;
1177 }
1178 Fio.read_set_from_file(number_of_conditions_satisfied_fname, Pts, nb_pts, verbose_level);
1179
1180 int *Cnt;
1181
1182 Cnt = NEW_int(nb_pts);
1183 Int_vec_zero(Cnt, nb_pts);
1184
1185
1188 int h, i, a;
1189 long int rk;
1190 int *v;
1191
1192 v = NEW_int(variety_nb_vars);
1193
1195
1196 HPD->init(F, variety_nb_vars, variety_degree,
1197 FALSE /* f_init_incidence_structure */,
1198 Monomial_ordering_type,
1199 0 /*verbose_level*/);
1200
1201 HPD->print_monomial_ordering(cout);
1202
1203
1204 label_txt.assign(variety_label_txt);
1205 label_tex.assign(variety_label_tex);
1206 //fname.append(".txt");
1207
1208
1209
1210 for (h = 0; h < Variety_coeffs.size(); h++) {
1211
1212 if (f_v) {
1213 cout << "ring_theory_global::number_of_conditions_satisfied "
1214 "h=" << h << " / " << Variety_coeffs.size() << " : ";
1215 cout << Variety_coeffs[h] << endl;
1216 }
1217
1218 int *coeff;
1219
1220 coeff = HPD->read_from_string_coefficient_pairs(Variety_coeffs[h], verbose_level - 2);
1221
1222 if (f_v) {
1223 cout << "ring_theory_global::number_of_conditions_satisfied "
1224 "h=" << h << " / " << Variety_coeffs.size() << " coeff:";
1225 Int_vec_print(cout, coeff, HPD->get_nb_monomials());
1226 cout << endl;
1227 }
1228
1229 for (i = 0; i < nb_pts; i++) {
1230 rk = Pts[i];
1231 HPD->unrank_point(v, rk);
1232 a = HPD->evaluate_at_a_point(coeff, v);
1233 if (a == 0) {
1234 Cnt[i]++;
1235 }
1236 }
1237
1238 FREE_int(coeff);
1239
1240
1241 } // next h
1242
1243
1245
1246 T.init(Cnt, nb_pts, FALSE, 0);
1247
1248 cout << "Number of conditions satisfied:" << endl;
1249 T.print_naked(TRUE);
1250 cout << endl;
1251
1252 //T.save_classes_individually(fname);
1253
1254 int f, l, t, j, pos;
1255
1256 // go through classes in reverse order:
1257 for (i = T.nb_types - 1; i >= 0; i--) {
1258
1259 f = T.type_first[i];
1260 l = T.type_len[i];
1261 t = T.data_sorted[f];
1262
1263
1264 string fname2;
1265 char str[10000];
1266
1267 fname2.assign(number_of_conditions_satisfied_fname);
1268 sprintf(str, "%d", t);
1269 fname2.append(str);
1270 fname2.append(".csv");
1271
1272
1273
1274 long int *the_class;
1275
1276 the_class = NEW_lint(l);
1277 for (j = 0; j < l; j++) {
1278 pos = T.sorting_perm_inv[f + j];
1279 the_class[j] = Pts[pos];
1280 }
1281
1282 Fio.lint_vec_write_csv(the_class, l, fname2, "case");
1283
1284 cout << "class of type " << t << " contains " << l << " elements:" << endl;
1286 cout, the_class, l, variety_nb_vars);
1287
1288 FREE_lint(the_class);
1289
1290 }
1291
1292
1293
1294 FREE_OBJECT(HPD);
1295 FREE_int(Cnt);
1296
1297 FREE_int(v);
1298
1299 if (f_v) {
1300 cout << "ring_theory_global::number_of_conditions_satisfied done" << endl;
1301 }
1302}
1303
1304
1307 std::string &variety_label_txt,
1308 std::string &variety_label_tex,
1309 int variety_nb_vars, int variety_degree,
1310 std::vector<std::string> &Variety_coeffs,
1311 monomial_ordering_type Monomial_ordering_type,
1312 std::string &label_txt,
1313 std::string &label_tex,
1314 int &nb_pts, long int *&Pts,
1315 int verbose_level)
1316// creates homogeneous_polynomial_domain
1317{
1318 int f_v = (verbose_level >= 1);
1319
1320 if (f_v) {
1321 cout << "ring_theory_global::create_intersection_of_zariski_open_sets" << endl;
1322 }
1325 int h;
1326 long int *Pts1;
1327 int sz1;
1328 long int *Pts2;
1329 int sz2;
1331
1333
1334 HPD->init(F, variety_nb_vars, variety_degree,
1335 FALSE /* f_init_incidence_structure */,
1336 Monomial_ordering_type,
1337 verbose_level);
1338
1339 HPD->print_monomial_ordering(cout);
1340
1341
1342 label_txt.assign(variety_label_txt);
1343 label_tex.assign(variety_label_tex);
1344
1345 for (h = 0; h < Variety_coeffs.size(); h++) {
1346
1347 if (f_v) {
1348 cout << "ring_theory_global::create_intersection_of_zariski_open_sets "
1349 "h=" << h << " / " << Variety_coeffs.size() << " : ";
1350 cout << Variety_coeffs[h] << endl;
1351 }
1352
1353 int *coeff;
1354
1355 coeff = HPD->read_from_string_coefficient_pairs(Variety_coeffs[h], verbose_level - 2);
1356 if (f_v) {
1357 cout << "ring_theory_global::create_intersection_of_zariski_open_sets "
1358 "h=" << h << " / " << Variety_coeffs.size() << " coeff:";
1359 Int_vec_print(cout, coeff, HPD->get_nb_monomials());
1360 cout << endl;
1361 }
1362
1363 Pts = NEW_lint(HPD->get_P()->N_points);
1364
1365 if (f_v) {
1366 cout << "ring_theory_global::create_intersection_of_zariski_open_sets "
1367 "before HPD->enumerate_points_zariski_open_set" << endl;
1368 }
1369
1370 vector<long int> Points;
1371
1372
1373 HPD->enumerate_points_zariski_open_set(coeff, Points, verbose_level);
1374
1375 FREE_int(coeff);
1376
1377 if (h == 0) {
1378 int i;
1379 nb_pts = Points.size();
1380 Pts1 = NEW_lint(nb_pts);
1381 Pts2 = NEW_lint(nb_pts);
1382 for (i = 0; i < nb_pts; i++) {
1383 Pts1[i] = Points[i];
1384 }
1385 sz1 = nb_pts;
1386 }
1387 else {
1388 int i, idx;
1389 long int a;
1390 nb_pts = Points.size();
1391 sz2 = 0;
1392 for (i = 0; i < nb_pts; i++) {
1393 a = Points[i];
1394 if (Sorting.lint_vec_search(Pts1, sz1, a, idx, 0)) {
1395 Pts2[sz2++] = a;
1396 }
1397 }
1398 Lint_vec_copy(Pts2, Pts1, sz2);
1399 sz1 = sz2;
1400 }
1401 if (f_v) {
1402 cout << "ring_theory_global::create_intersection_of_zariski_open_sets "
1403 "after HPD->enumerate_points_zariski_open_set, "
1404 "nb_pts = " << nb_pts << endl;
1405 }
1406 } // next h
1407
1408 nb_pts = sz1;
1409 Pts = NEW_lint(sz1);
1410 Lint_vec_copy(Pts1, Pts, sz1);
1411
1413 cout, Pts, nb_pts, variety_nb_vars);
1414
1415 FREE_OBJECT(HPD);
1416 FREE_lint(Pts1);
1417 FREE_lint(Pts2);
1418
1419
1420
1421 if (f_v) {
1422 cout << "ring_theory_global::create_intersection_of_zariski_open_sets done" << endl;
1423 }
1424}
1425
1426
1429 std::string &variety_label,
1430 std::string &variety_label_tex,
1431 int variety_nb_vars, int variety_degree,
1432 std::string &variety_coeffs,
1433 monomial_ordering_type Monomial_ordering_type,
1434 std::string &label_txt,
1435 std::string &label_tex,
1436 int &nb_pts, long int *&Pts,
1437 int verbose_level)
1438// creates homogeneous_polynomial_domain
1439{
1440 int f_v = (verbose_level >= 1);
1441
1442 if (f_v) {
1443 cout << "ring_theory_global::create_projective_variety" << endl;
1444 }
1445
1448
1450
1451 HPD->init(F, variety_nb_vars, variety_degree,
1452 FALSE /* f_init_incidence_structure */,
1453 Monomial_ordering_type,
1454 verbose_level);
1455
1456 HPD->print_monomial_ordering(cout);
1457
1458 label_txt.assign(variety_label);
1459 label_tex.append(variety_label_tex);
1460
1461 int *coeff;
1462 int sz;
1463
1464 orbiter_kernel_system::Orbiter->get_vector_from_label(variety_coeffs, coeff, sz, verbose_level);
1465 //coeff = HPD->read_from_string_coefficient_vector(variety_coeffs, verbose_level - 2);
1466
1467 if (sz != HPD->get_nb_monomials()) {
1468 cout << "ring_theory_global::create_projective_variety "
1469 "the number of coefficients should be " << HPD->get_nb_monomials()
1470 << " but is " << sz << endl;
1471 exit(1);
1472 }
1473 if (f_v) {
1474 cout << "ring_theory_global::create_projective_variety coeff:";
1475 Int_vec_print(cout, coeff, HPD->get_nb_monomials());
1476 cout << endl;
1477 }
1478
1479 Pts = NEW_lint(HPD->get_P()->N_points);
1480
1481 if (f_v) {
1482 cout << "ring_theory_global::create_projective_variety "
1483 "before HPD->enumerate_points" << endl;
1484 }
1485
1486 vector<long int> Points;
1487 int i;
1488
1489 HPD->enumerate_points(coeff, Points, verbose_level);
1490 nb_pts = Points.size();
1491 Pts = NEW_lint(nb_pts);
1492 for (i = 0; i < nb_pts; i++) {
1493 Pts[i] = Points[i];
1494 }
1495 if (f_v) {
1496 cout << "ring_theory_global::create_projective_variety "
1497 "after HPD->enumerate_points, nb_pts = " << nb_pts << endl;
1498 }
1499
1501 cout, Pts, nb_pts, variety_nb_vars);
1502
1503 FREE_int(coeff);
1504 FREE_OBJECT(HPD);
1505
1506 if (f_v) {
1507 cout << "ring_theory_global::create_projective_variety done" << endl;
1508 }
1509}
1510
1513 std::string &variety_label_txt,
1514 std::string &variety_label_tex,
1515 int curve_nb_vars, int curve_degree,
1516 std::string &curve_coeffs,
1517 monomial_ordering_type Monomial_ordering_type,
1518 std::string &label_txt,
1519 std::string &label_tex,
1520 int &nb_pts, long int *&Pts,
1521 int verbose_level)
1522// creates homogeneous_polynomial_domain
1523{
1524 int f_v = (verbose_level >= 1);
1525
1526 if (f_v) {
1527 cout << "ring_theory_global::create_projective_curve" << endl;
1528 }
1529
1531 int *coeff;
1532
1534
1535 HPD->init(F, 2, curve_degree,
1536 FALSE /* f_init_incidence_structure */,
1537 Monomial_ordering_type,
1538 verbose_level);
1539
1540 HPD->print_monomial_ordering(cout);
1541
1542 coeff = NEW_int(HPD->get_nb_monomials());
1543 Int_vec_zero(coeff, HPD->get_nb_monomials());
1544
1545 label_txt.assign(variety_label_txt);
1546 label_tex.assign(variety_label_tex);
1547 int *coeffs;
1548 int len, i, j, a, b, c, s, t;
1549 int *v;
1550 int v2[2];
1551
1552 Int_vec_scan(curve_coeffs.c_str(), coeffs, len);
1553 if (len != curve_degree + 1) {
1554 cout << "ring_theory_global::create_projective_curve "
1555 "len != curve_degree + 1" << endl;
1556 exit(1);
1557 }
1558
1559 nb_pts = F->q + 1;
1560
1561 v = NEW_int(curve_nb_vars);
1562 Pts = NEW_lint(nb_pts);
1563
1564 for (i = 0; i < nb_pts; i++) {
1565 F->PG_element_unrank_modified(v2, 1, 2, i);
1566 s = v2[0];
1567 t = v2[1];
1568 for (j = 0; j < curve_nb_vars; j++) {
1569 a = HPD->get_monomial(j, 0);
1570 b = HPD->get_monomial(j, 1);
1571 v[j] = F->mult3(coeffs[j], F->power(s, a), F->power(t, b));
1572 }
1573 F->PG_element_rank_modified(v, 1, curve_nb_vars, c);
1574 Pts[i] = c;
1575 if (f_v) {
1576 cout << setw(4) << i << " : ";
1577 Int_vec_print(cout, v, curve_nb_vars);
1578 cout << " : " << setw(5) << c << endl;
1579 }
1580 }
1581
1583 cout, Pts, nb_pts, curve_nb_vars);
1584
1585
1586 FREE_int(v);
1587 FREE_int(coeffs);
1588 FREE_OBJECT(HPD);
1589
1590 if (f_v) {
1591 cout << "ring_theory_global::create_projective_curve done" << endl;
1592 }
1593}
1594
1595
1598 unipoly_domain *Fq,
1599 unipoly_object *&Beta, int n,
1600 long int *cyclotomic_set, int cylotomic_set_size,
1601 unipoly_object *&generator,
1602 int verbose_level)
1603{
1604 int f_v = (verbose_level >= 1);
1605
1606 if (f_v) {
1607 cout << "ring_theory_global::create_irreducible_polynomial n=" << n << endl;
1608 }
1609 if (f_v) {
1610 cout << "ring_theory_global::create_irreducible_polynomial before allocating generator etc" << endl;
1611 }
1612
1613 int degree = cylotomic_set_size;
1614
1616
1617 generator = NEW_OBJECTS(unipoly_object, degree + 2);
1618 unipoly_object *tmp = NEW_OBJECTS(unipoly_object, degree + 1);
1619 unipoly_object *linear_factor = NEW_OBJECTS(unipoly_object, 2);
1620 unipoly_object Pc, Pd;
1621
1622 int i, j, h, r;
1623
1624 // create the polynomial linear_factor = X - a:
1625 if (f_v) {
1626 cout << "ring_theory_global::create_irreducible_polynomial creating linear_factor = X-a" << endl;
1627 }
1628 for (i = 0; i < 2; i++) {
1629 if (i == 1) {
1630 Fq->create_object_by_rank(linear_factor[i], 1, __FILE__, __LINE__, verbose_level);
1631 }
1632 else {
1633 Fq->create_object_by_rank(linear_factor[i], 0, __FILE__, __LINE__, verbose_level);
1634 }
1635 }
1636 for (i = 0; i <= degree; i++) {
1637 if (f_v) {
1638 cout << "ring_theory_global::create_irreducible_polynomial creating generator[" << i << "]" << endl;
1639 }
1640 Fq->create_object_by_rank(generator[i], 0, __FILE__, __LINE__, verbose_level);
1641 Fq->create_object_by_rank(tmp[i], 0, __FILE__, __LINE__, verbose_level);
1642 }
1643 if (f_v) {
1644 cout << "ring_theory_global::create_irreducible_polynomial creating generator[0]" << endl;
1645 }
1646 Fq->create_object_by_rank(generator[0], 1, __FILE__, __LINE__, verbose_level);
1647
1648 // now coeffs has degree 1
1649 // and generator has degree 0
1650
1651 if (f_v) {
1652 cout << "ring_theory_global::create_irreducible_polynomial coeffs:" << endl;
1653 Codes.print_polynomial(*Fq, 1, linear_factor);
1654 cout << endl;
1655 cout << "ring_theory_global::create_irreducible_polynomial generator:" << endl;
1656 Codes.print_polynomial(*Fq, 0, generator);
1657 cout << endl;
1658 }
1659
1660 if (f_v) {
1661 cout << "ring_theory_global::create_irreducible_polynomial creating Pc" << endl;
1662 }
1663 Fq->create_object_by_rank(Pc, 0, __FILE__, __LINE__, verbose_level);
1664 if (f_v) {
1665 cout << "ring_theory_global::create_irreducible_polynomial creating Pd" << endl;
1666 }
1667 Fq->create_object_by_rank(Pd, 0, __FILE__, __LINE__, verbose_level);
1668
1669 r = 0;
1670 for (h = 0; h < cylotomic_set_size; h++) {
1671 i = cyclotomic_set[h];
1672 if (f_v) {
1673 cout << "h=" << h << ", i=" << i << endl;
1674 }
1675 if (f_v) {
1676 cout << "ring_theory_global::create_irreducible_polynomial working on root " << i << endl;
1677 }
1678 if (f_v) {
1679 cout << "ring_theory_global::create_irreducible_polynomial before Fq.assign beta" << endl;
1680 }
1681 Fq->assign(Beta[i], linear_factor[0], verbose_level);
1682 if (f_v) {
1683 cout << "ring_theory_global::create_irreducible_polynomial before Fq.negate" << endl;
1684 }
1685 Fq->negate(linear_factor[0]);
1686 if (f_v) {
1687 cout << "ring_theory_global::create_irreducible_polynomial root: " << i << " : ";
1688 Fq->print_object(linear_factor[0], cout);
1689 //cout << " : ";
1690 //print_polynomial(Fq, 2, coeffs);
1691 cout << endl;
1692 }
1693
1694
1695 if (f_v) {
1696 cout << "ring_theory_global::create_irreducible_polynomial before Fq.assign(generator[j], tmp[j])" << endl;
1697 }
1698 for (j = 0; j <= r; j++) {
1699 Fq->assign(generator[j], tmp[j], verbose_level);
1700 }
1701
1702 //cout << "tmp:" << endl;
1703 //print_polynomial(Fq, r, tmp);
1704 //cout << endl;
1705
1706 if (f_v) {
1707 cout << "ring_theory_global::create_irreducible_polynomial before Fq.assign(tmp[j], generator[j + 1])" << endl;
1708 }
1709 for (j = 0; j <= r; j++) {
1710 Fq->assign(tmp[j], generator[j + 1], verbose_level);
1711 }
1712 Fq->delete_object(generator[0]);
1713 Fq->create_object_by_rank(generator[0], 0, __FILE__, __LINE__, verbose_level);
1714
1715 //cout << "generator after shifting up:" << endl;
1716 //print_polynomial(Fq, r + 1, generator);
1717 //cout << endl;
1718
1719 for (j = 0; j <= r; j++) {
1720 if (f_v) {
1721 cout << "ring_theory_global::create_irreducible_polynomial j=" << j << endl;
1722 }
1723 if (f_v) {
1724 cout << "ring_theory_global::create_irreducible_polynomial before Fq.mult(tmp[j], linear_factor[0], Pc)" << endl;
1725 }
1726 Fq->mult(tmp[j], linear_factor[0], Pc, verbose_level - 1);
1727 if (f_v) {
1728 cout << "ring_theory_global::create_irreducible_polynomial before Fq.add()" << endl;
1729 }
1730 Fq->add(Pc, generator[j], Pd);
1731 if (f_v) {
1732 cout << "ring_theory_global::create_irreducible_polynomial before Fq.assign()" << endl;
1733 }
1734 Fq->assign(Pd, generator[j], verbose_level);
1735 }
1736 r++;
1737 if (f_v) {
1738 cout << "ring_theory_global::create_irreducible_polynomial r=" << r << endl;
1739 }
1740 if (f_v) {
1741 cout << "ring_theory_global::create_irreducible_polynomial current polynomial: ";
1742 Codes.print_polynomial(*Fq, r, generator);
1743 cout << endl;
1744 }
1745
1746 }
1747
1748 if (r != degree) {
1749 cout << "ring_theory_global::create_irreducible_polynomial r != degree" << endl;
1750 exit(1);
1751 }
1752
1753 if (f_v) {
1754 cout << "ring_theory_global::create_irreducible_polynomial The generator polynomial is: ";
1755 Codes.print_polynomial(*Fq, r, generator);
1756 cout << endl;
1757 }
1758
1759 if (f_v) {
1760 cout << "ring_theory_global::create_irreducible_polynomial done" << endl;
1761 }
1762
1763}
1764
1767 unipoly_domain *FpX,
1768 unipoly_domain *Fq, unipoly_object *&Beta, int n1, int n2, int verbose_level)
1769{
1770 int f_v = (verbose_level >= 1);
1771 //unipoly_object M;
1772 unipoly_object beta;
1773
1774 if (f_v) {
1775 cout << "ring_theory_global::compute_nth_roots_as_polynomials " << endl;
1776 }
1777
1778#if 0
1779 Fp.finite_field_init(p, FALSE /* f_without_tables */, verbose_level - 1);
1780
1781 algebra_global Algebra;
1782 unipoly_domain FpX(&Fp);
1784 Algebra.get_primitive_polynomial(p, field_degree, 0),
1785 verbose_level - 2);
1786#endif
1787
1788 int m, r;
1789 int i;
1790 longinteger_object Qm1, Index;
1793
1794 m = NT.order_mod_p(F->q, n1);
1795 if (f_v) {
1796 cout << "ring_theory_global::make_cyclic_code order of q mod n is m=" << m << endl;
1797 }
1798 D.create_qnm1(Qm1, F->q, m);
1799
1800 // q = i_power_j(p, e);
1801 // GF(q)=GF(p^e) has n-th roots of unity
1802 D.integral_division_by_int(Qm1, n2, Index, r);
1803 if (f_v) {
1804 cout << "ring_theory_global::make_cyclic_code Index = " << Index << endl;
1805 }
1806
1807 int subgroup_index;
1808
1809 subgroup_index = Index.as_int();
1810 if (f_v) {
1811 cout << "ring_theory_global::make_cyclic_code subgroup_index = " << subgroup_index << endl;
1812 }
1813
1814 //b = (q - 1) / n;
1815 if (r != 0) {
1816 cout << "ring_theory_global::make_cyclic_code n does not divide q^m-1" << endl;
1817 exit(1);
1818 }
1819
1820#if 0
1821 if (f_v) {
1822 cout << "ring_theory_global::compute_nth_roots_as_polynomials choosing the following irreducible "
1823 "and primitive polynomial:" << endl;
1824 FpX.print_object(M, cout);
1825 cout << endl;
1826 }
1827
1828 if (f_v) {
1829 cout << "ring_theory_global::compute_nth_roots_as_polynomials creating unipoly_domain Fq modulo M" << endl;
1830 }
1831 //unipoly_domain Fq(this, M, verbose_level); // Fq = Fp[X] modulo factor polynomial M
1832 if (f_v) {
1833 cout << "ring_theory_global::compute_nth_roots_as_polynomials extension field created" << endl;
1834 }
1835#endif
1836
1837 Beta = new unipoly_object[n2];
1838
1839 for (i = 0; i < n2; i++) {
1840 Fq->create_object_by_rank(Beta[i], 0, __FILE__, __LINE__, verbose_level);
1841
1842 }
1843
1844 //Fq->create_object_by_rank(c, 0, __FILE__, __LINE__, verbose_level);
1845 Fq->create_object_by_rank(beta, F->p, __FILE__, __LINE__, verbose_level); // the element alpha
1846 //Fq->create_object_by_rank(beta_i, 1, __FILE__, __LINE__, verbose_level);
1847 if (subgroup_index != 1) {
1848 //Fq.power_int(beta, b);
1849 if (f_v) {
1850 cout << "\\alpha = ";
1851 Fq->print_object(beta, cout);
1852 cout << endl;
1853 }
1854 if (f_v) {
1855 cout << "ring_theory_global::compute_nth_roots_as_polynomials before Fq->power_int" << endl;
1856 }
1857 Fq->power_int(beta, subgroup_index, verbose_level - 1);
1858 if (f_v) {
1859 cout << "\\beta = \\alpha^" << Index << " = ";
1860 Fq->print_object(beta, cout);
1861 cout << endl;
1862 }
1863 }
1864 else {
1865 if (f_v) {
1866 cout << "ring_theory_global::compute_nth_roots_as_polynomials subgroup_index is one" << endl;
1867 }
1868 }
1869
1870
1871 for (i = 0; i < n2; i++) {
1872 if (f_v) {
1873 cout << "ring_theory_global::compute_nth_roots_as_polynomials i=" << i << endl;
1874 }
1875 if (f_v) {
1876 cout << "ring_theory_global::compute_nth_roots_as_polynomials working on root " << i << endl;
1877 }
1878 if (f_v) {
1879 cout << "ring_theory_global::compute_nth_roots_as_polynomials before Fq.assign beta" << endl;
1880 }
1881 Fq->assign(beta, Beta[i], verbose_level);
1882 if (f_v) {
1883 cout << "ring_theory_global::compute_nth_roots_as_polynomials before Fq.power_int" << endl;
1884 }
1885 Fq->power_int(Beta[i], i, verbose_level);
1886 }
1887
1888
1889 if (f_v) {
1890 cout << "ring_theory_global::compute_nth_roots_as_polynomials done" << endl;
1891 }
1892
1893}
1894
1897 unipoly_domain *Fq,
1898 int n, int start_idx,
1899 unipoly_object *&Beta, int verbose_level)
1900{
1901 int f_v = (verbose_level >= 1);
1902
1903 if (f_v) {
1904 cout << "ring_theory_global::compute_powers" << endl;
1905 }
1906 int i;
1907 unipoly_object beta;
1908
1909 Beta = new unipoly_object[n];
1910
1911 for (i = 0; i < n; i++) {
1912 Fq->create_object_by_rank(Beta[i], 0, __FILE__, __LINE__, verbose_level);
1913
1914 }
1915
1916 Fq->create_object_by_rank(beta, F->p, __FILE__, __LINE__, verbose_level); // the element alpha
1917
1918 if (start_idx != 1) {
1919
1920 if (f_v) {
1921 cout << "\\alpha = ";
1922 Fq->print_object(beta, cout);
1923 cout << endl;
1924 }
1925 if (f_v) {
1926 cout << "ring_theory_global::compute_powers before Fq->power_int" << endl;
1927 }
1928 Fq->power_int(beta, start_idx, verbose_level - 1);
1929 if (f_v) {
1930 cout << "\\beta = \\alpha^" << start_idx << " = ";
1931 Fq->print_object(beta, cout);
1932 cout << endl;
1933 }
1934 }
1935 else {
1936 if (f_v) {
1937 cout << "ring_theory_global::compute_powers subgroup_index is one" << endl;
1938 }
1939 }
1940
1941
1942 for (i = 0; i < n; i++) {
1943 if (f_v) {
1944 cout << "ring_theory_global::compute_powers i=" << i << endl;
1945 }
1946 if (f_v) {
1947 cout << "ring_theory_global::compute_powers working on root " << i << endl;
1948 }
1949 if (f_v) {
1950 cout << "ring_theory_global::compute_powers before Fq.assign beta" << endl;
1951 }
1952 Fq->assign(beta, Beta[i], verbose_level);
1953 if (f_v) {
1954 cout << "ring_theory_global::compute_powers before Fq.power_int" << endl;
1955 }
1956 Fq->power_int(Beta[i], i, verbose_level);
1957 }
1958
1959 if (f_v) {
1960 cout << "ring_theory_global::compute_powers done" << endl;
1961 }
1962
1963}
1964
1965
1968 int d, std::vector<std::vector<int> > &Table,
1969 int verbose_level)
1970{
1971 int f_v = (verbose_level >= 1);
1972 int f_vv = (verbose_level >= 2);
1973 int i;
1974 int cnt;
1976
1977 if (f_v) {
1978 cout << "ring_theory_global::make_all_irreducible_polynomials_of_degree_d "
1979 "d=" << d << " q=" << F->q << endl;
1980 cout << "verbose_level=" << verbose_level << endl;
1981 }
1982
1983#if 0
1984 cnt = count_all_irreducible_polynomials_of_degree_d(F, d, verbose_level - 2);
1985
1986 if (f_v) {
1987 cout << "ring_theory_global::make_all_irreducible_polynomials_of_degree_d "
1988 "cnt = " << cnt << endl;
1989 }
1990
1991 nb = cnt;
1992
1993 Table = NEW_int(nb * (d + 1));
1994#endif
1995
1996 //NT.factor_prime_power(F->q, p, e);
1997
1998 if (f_v) {
1999 cout << "ring_theory_global::make_all_irreducible_polynomials_of_degree_d "
2000 " q=" << F->q << " p=" << F->p << " e=" << F->e << endl;
2001 }
2002
2003 unipoly_domain FX(F);
2004
2005 string poly;
2007
2008 K.get_primitive_polynomial(poly, F->q, d, 0 /* verbose_level */);
2009
2010 if (f_v) {
2011 cout << "ring_theory_global::make_all_irreducible_polynomials_of_degree_d "
2012 "chosen irreducible polynomial is " << poly << endl;
2013 }
2014
2017 unipoly_object minpol;
2019
2020
2021 FX.create_object_by_rank_string(m, poly, 0 /* verbose_level */);
2022
2023 if (f_v) {
2024 cout << "ring_theory_global::make_all_irreducible_polynomials_of_degree_d "
2025 "chosen irreducible polynomial m = ";
2026 FX.print_object(m, cout);
2027 cout << endl;
2028 }
2029
2030 FX.create_object_by_rank(g, 0, __FILE__, __LINE__, 0 /* verbose_level */);
2031 FX.create_object_by_rank(minpol, 0, __FILE__, __LINE__, 0 /* verbose_level */);
2032
2033 int *Frobenius;
2034 int *Normal_basis;
2035 int *v;
2036 int *w;
2037
2038 //Frobenius = NEW_int(d * d);
2039 Normal_basis = NEW_int(d * d);
2040 v = NEW_int(d);
2041 w = NEW_int(d);
2042
2043 if (f_v) {
2044 cout << "ring_theory_global::make_all_irreducible_polynomials_of_degree_d "
2045 "before FX.Frobenius_matrix" << endl;
2046 }
2047 FX.Frobenius_matrix(Frobenius, m, verbose_level - 2);
2048 if (f_v) {
2049 cout << "ring_theory_global::make_all_irreducible_polynomials_of_degree_d "
2050 "Frobenius_matrix = " << endl;
2051 Int_matrix_print(Frobenius, d, d);
2052 cout << endl;
2053 }
2054
2055 if (f_v) {
2056 cout << "ring_theory_global::make_all_irreducible_polynomials_of_degree_d "
2057 "before compute_normal_basis" << endl;
2058 }
2059 FX.compute_normal_basis(d, Normal_basis, Frobenius, verbose_level - 1);
2060
2061 if (f_v) {
2062 cout << "ring_theory_global::make_all_irreducible_polynomials_of_degree_d "
2063 "Normal_basis = " << endl;
2064 Int_matrix_print(Normal_basis, d, d);
2065 cout << endl;
2066 }
2067
2068 cnt = 0;
2069
2070 Combi.int_vec_first_regular_word(v, d, F->q);
2071 while (TRUE) {
2072 if (f_vv) {
2073 cout << "ring_theory_global::make_all_irreducible_polynomials_of_degree_d "
2074 "regular word " << cnt << " : v = ";
2075 Int_vec_print(cout, v, d);
2076 cout << endl;
2077 }
2078
2079 F->Linear_algebra->mult_vector_from_the_right(Normal_basis, v, w, d, d);
2080 if (f_vv) {
2081 cout << "ring_theory_global::make_all_irreducible_polynomials_of_degree_d "
2082 "regular word " << cnt << " : w = ";
2083 Int_vec_print(cout, w, d);
2084 cout << endl;
2085 }
2086
2087 FX.delete_object(g);
2088 FX.create_object_of_degree(g, d - 1);
2089 for (i = 0; i < d; i++) {
2090 ((int *) g)[1 + i] = w[i];
2091 }
2092
2093 FX.minimum_polynomial_extension_field(g, m, minpol, d, Frobenius,
2094 verbose_level - 3);
2095 if (f_vv) {
2096 cout << "ring_theory_global::make_all_irreducible_polynomials_of_degree_d "
2097 "regular word " << cnt << " : v = ";
2098 Int_vec_print(cout, v, d);
2099 cout << " irreducible polynomial = ";
2100 FX.print_object(minpol, cout);
2101 cout << endl;
2102 }
2103
2104
2105
2106 std::vector<int> T;
2107
2108 for (i = 0; i <= d; i++) {
2109 T.push_back(((int *)minpol)[1 + i]);
2110 }
2111 Table.push_back(T);
2112
2113
2114 cnt++;
2115
2116
2117 if (!Combi.int_vec_next_regular_word(v, d, F->q)) {
2118 break;
2119 }
2120
2121 }
2122
2123 if (f_v) {
2124 cout << "ring_theory_global::make_all_irreducible_polynomials_of_degree_d "
2125 "there are " << cnt
2126 << " irreducible polynomials "
2127 "of degree " << d << " over " << "F_" << F->q << endl;
2128 }
2129
2130 FREE_int(Frobenius);
2131 FREE_int(Normal_basis);
2132 FREE_int(v);
2133 FREE_int(w);
2134 FX.delete_object(m);
2135 FX.delete_object(g);
2136 FX.delete_object(minpol);
2137
2138
2139 if (f_v) {
2140 cout << "ring_theory_global::make_all_irreducible_polynomials_of_degree_d "
2141 "d=" << d << " q=" << F->q << " done" << endl;
2142 }
2143}
2144
2146 field_theory::finite_field *F, int d, int verbose_level)
2147{
2148 int f_v = (verbose_level >= 1);
2149 int f_vv = (verbose_level >= 2);
2150 int i;
2151 int cnt;
2154
2155 if (f_v) {
2156 cout << "ring_theory_global::count_all_irreducible_polynomials_of_degree_d "
2157 "d=" << d << " q=" << F->q << endl;
2158 }
2159
2160
2161 if (f_v) {
2162 cout << "ring_theory_global::count_all_irreducible_polynomials_of_degree_d " << endl;
2163 }
2164
2165 if (f_v) {
2166 cout << "ring_theory_global::count_all_irreducible_polynomials_of_degree_d "
2167 "p=" << F->p << " e=" << F->e << endl;
2168 }
2169 if (F->e > 1) {
2170 cout << "ring_theory_global::count_all_irreducible_polynomials_of_degree_d "
2171 "e=" << F->e << " is greater than one" << endl;
2172 }
2173
2174 unipoly_domain FX(F);
2175
2176 string poly;
2178
2179 K.get_primitive_polynomial(poly, F->q, d, 0 /* verbose_level */);
2180
2183 unipoly_object minpol;
2184
2185
2186 FX.create_object_by_rank_string(m, poly, 0 /* verbose_level */);
2187
2188 if (f_v) {
2189 cout << "ring_theory_global::count_all_irreducible_polynomials_of_degree_d "
2190 "chosen irreducible polynomial m = ";
2191 FX.print_object(m, cout);
2192 cout << endl;
2193 }
2194
2195 FX.create_object_by_rank(g, 0, __FILE__, __LINE__, 0 /* verbose_level */);
2196 FX.create_object_by_rank(minpol, 0, __FILE__, __LINE__, 0 /* verbose_level */);
2197
2198 int *Frobenius;
2199 //int *F2;
2200 int *Normal_basis;
2201 int *v;
2202 int *w;
2203
2204 //Frobenius = NEW_int(d * d);
2205 //F2 = NEW_int(d * d);
2206 Normal_basis = NEW_int(d * d);
2207 v = NEW_int(d);
2208 w = NEW_int(d);
2209
2210 FX.Frobenius_matrix(Frobenius, m, verbose_level - 3);
2211 if (f_v) {
2212 cout << "ring_theory_global::count_all_irreducible_polynomials_of_degree_d "
2213 "Frobenius_matrix = " << endl;
2214 Int_matrix_print(Frobenius, d, d);
2215 cout << endl;
2216 }
2217
2218#if 0
2219 F->mult_matrix_matrix(Frobenius, Frobenius, F2, d, d, d,
2220 0 /* verbose_level */);
2221 if (f_v) {
2222 cout << "ring_theory_global::count_all_irreducible_polynomials_of_degree_d "
2223 "Frobenius^2 = " << endl;
2224 int_matrix_print(F2, d, d);
2225 cout << endl;
2226 }
2227#endif
2228
2229 FX.compute_normal_basis(d, Normal_basis, Frobenius, verbose_level - 3);
2230
2231 if (f_v) {
2232 cout << "ring_theory_global::count_all_irreducible_polynomials_of_degree_d "
2233 "Normal_basis = " << endl;
2234 Int_matrix_print(Normal_basis, d, d);
2235 cout << endl;
2236 }
2237
2238 cnt = 0;
2239 Combi.int_vec_first_regular_word(v, d, F->q);
2240 while (TRUE) {
2241 if (f_vv) {
2242 cout << "ring_theory_global::count_all_irreducible_polynomials_of_degree_d "
2243 "regular word " << cnt << " : v = ";
2244 Int_vec_print(cout, v, d);
2245 cout << endl;
2246 }
2247
2248 F->Linear_algebra->mult_vector_from_the_right(Normal_basis, v, w, d, d);
2249 if (f_vv) {
2250 cout << "ring_theory_global::count_all_irreducible_polynomials_of_degree_d "
2251 "regular word " << cnt << " : w = ";
2252 Int_vec_print(cout, w, d);
2253 cout << endl;
2254 }
2255
2256 FX.delete_object(g);
2257 FX.create_object_of_degree(g, d - 1);
2258 for (i = 0; i < d; i++) {
2259 ((int *) g)[1 + i] = w[i];
2260 }
2261
2262 FX.minimum_polynomial_extension_field(g, m, minpol, d,
2263 Frobenius, verbose_level - 3);
2264 if (f_vv) {
2265 cout << "ring_theory_global::count_all_irreducible_polynomials_of_degree_d "
2266 "regular word " << cnt << " : v = ";
2267 Int_vec_print(cout, v, d);
2268 cout << " irreducible polynomial = ";
2269 FX.print_object(minpol, cout);
2270 cout << endl;
2271 }
2272 if (FX.degree(minpol) != d) {
2273 cout << "ring_theory_global::count_all_irreducible_polynomials_of_degree_d "
2274 "The polynomial does not have degree d"
2275 << endl;
2276 FX.print_object(minpol, cout);
2277 cout << endl;
2278 exit(1);
2279 }
2280 if (!FX.is_irreducible(minpol, verbose_level)) {
2281 cout << "ring_theory_global::count_all_irreducible_polynomials_of_degree_d "
2282 "The polynomial is not irreducible" << endl;
2283 FX.print_object(minpol, cout);
2284 cout << endl;
2285 exit(1);
2286 }
2287
2288
2289 cnt++;
2290
2291 if (!Combi.int_vec_next_regular_word(v, d, F->q)) {
2292 break;
2293 }
2294
2295 }
2296
2297 if (f_v) {
2298 cout << "ring_theory_global::count_all_irreducible_polynomials_of_degree_d "
2299 "there are " << cnt << " irreducible polynomials "
2300 "of degree " << d << " over " << "F_" << F->q << endl;
2301 }
2302
2303 FREE_int(Frobenius);
2304 //FREE_int(F2);
2305 FREE_int(Normal_basis);
2306 FREE_int(v);
2307 FREE_int(w);
2308 FX.delete_object(m);
2309 FX.delete_object(g);
2310 FX.delete_object(minpol);
2311
2312 if (f_v) {
2313 cout << "ring_theory_global::count_all_irreducible_polynomials_of_degree_d done" << endl;
2314 }
2315 return cnt;
2316}
2317
2320 int deg, int verbose_level)
2321{
2322 int f_v = (verbose_level >= 1);
2323
2324 if (f_v) {
2325 cout << "ring_theory_global::do_make_table_of_irreducible_polynomials" << endl;
2326 cout << "deg=" << deg << endl;
2327 cout << "q=" << F->q << endl;
2328 }
2329
2330 int nb;
2331 std::vector<std::vector<int>> Table;
2332
2334 Table, verbose_level);
2335
2336 nb = Table.size();
2337
2338 cout << "The " << nb << " irreducible polynomials of "
2339 "degree " << deg << " over F_" << F->q << " are:" << endl;
2340
2342
2343
2344 int *T;
2345 int i, j;
2346
2347 T = NEW_int(Table.size() * (deg + 1));
2348 for (i = 0; i < Table.size(); i++) {
2349 for (j = 0; j < deg + 1; j++) {
2350 T[i * (deg + 1) + j] = Table[i][j];
2351 }
2352 }
2353
2354
2355
2356 {
2357 char str[1000];
2358 string fname;
2359 char title[1000];
2360 char author[1000];
2361
2362 snprintf(str, 1000, "Irred_q%d_d%d.tex", F->q, deg);
2363 fname.assign(str);
2364 snprintf(title, 1000, "Irreducible Polynomials of Degree %d over F%d", deg, F->q);
2365 //strcpy(author, "");
2366 author[0] = 0;
2367
2368
2369 {
2370 ofstream ost(fname);
2373 long int rk;
2374
2375 L.head(ost,
2376 FALSE /* f_book*/,
2377 TRUE /* f_title */,
2378 title, author,
2379 FALSE /* f_toc */,
2380 FALSE /* f_landscape */,
2381 TRUE /* f_12pt */,
2382 TRUE /* f_enlarged_page */,
2383 TRUE /* f_pagenumbers */,
2384 NULL /* extra_praeamble */);
2385
2386
2387 if (f_v) {
2388 cout << "ring_theory_global::do_make_table_of_irreducible_polynomials before report" << endl;
2389 }
2390 //report(ost, verbose_level);
2391
2392 ost << "There are " << Table.size() << " irreducible polynomials of "
2393 "degree " << deg << " over the field F" << F->q << ":\\\\" << endl;
2394 ost << "The coefficients in increasing order are:\\\\" << endl;
2395 ost << endl;
2396 ost << "\\bigskip" << endl;
2397 ost << endl;
2398 //ost << "\\begin{multicols}{2}" << endl;
2399 ost << "\\noindent" << endl;
2400 for (i = 0; i < Table.size(); i++) {
2401 ost << i << " : $";
2402 for (j = 0; j <= deg; j++) {
2403 ost << T[i * (deg + 1) + j];
2404 }
2405 ost << " : ";
2406 rk = GG.AG_element_rank(F->q, T + i * (deg + 1), 1, deg + 1);
2407 ost << rk;
2408 ost << "$\\\\" << endl;
2409 }
2410 //ost << "\\end{multicols}" << endl;
2411
2412
2413 if (f_v) {
2414 cout << "ring_theory_global::do_make_table_of_irreducible_polynomials after report" << endl;
2415 }
2416
2417
2418 L.foot(ost);
2419
2420 }
2422
2423 cout << "ring_theory_global::do_make_table_of_irreducible_polynomials written file " << fname << " of size "
2424 << Fio.file_size(fname) << endl;
2425 }
2426
2427 FREE_int(T);
2428
2429 //int_matrix_print(Table, nb, deg + 1);
2430
2431 //FREE_int(Table);
2432
2433 if (f_v) {
2434 cout << "ring_theory_global::do_make_table_of_irreducible_polynomials done" << endl;
2435 }
2436}
2437
2438
2439
2440
2442 int p_min, int p_max,
2443 int deg_min, int deg_max,
2444 int verbose_level)
2445{
2446 int f_v = (verbose_level >= 1);
2447
2448 if (f_v) {
2449 cout << "ring_theory_global::do_search_for_primitive_polynomial_in_range" << endl;
2450 cout << "p_min=" << p_min << endl;
2451 cout << "p_max=" << p_max << endl;
2452 cout << "deg_min=" << deg_min << endl;
2453 cout << "deg_max=" << deg_max << endl;
2454 }
2455
2456
2457 if (deg_min == deg_max && p_min == p_max) {
2458 char *poly;
2459
2460
2461
2463 p_min, deg_min, verbose_level);
2464
2465 cout << "poly = " << poly << endl;
2466
2467 }
2468 else {
2469
2471 deg_min, deg_max,
2472 verbose_level);
2473 }
2474
2475 if (f_v) {
2476 cout << "ring_theory_global::do_search_for_primitive_polynomial_in_range done" << endl;
2477 }
2478}
2479
2481 int p, int degree, int verbose_level)
2482{
2483 int f_v = (verbose_level >= 1);
2485
2486 if (f_v) {
2487 cout << "ring_theory_global::search_for_primitive_polynomial_of_given_degree" << endl;
2488 }
2489 Fp.finite_field_init(p, FALSE /* f_without_tables */, 0 /*verbose_level*/);
2490 unipoly_domain FX(&Fp);
2491
2494
2495 FX.create_object_by_rank(m, 0, __FILE__, __LINE__, verbose_level);
2496
2497 if (f_v) {
2498 cout << "search_for_primitive_polynomial_of_given_degree "
2499 "p=" << p << " degree=" << degree << endl;
2500 }
2501 FX.get_a_primitive_polynomial(m, degree, verbose_level - 1);
2502 FX.rank_longinteger(m, rk);
2503
2504 char *s;
2505 int i, j;
2506 if (f_v) {
2507 cout << "found a primitive polynomial. The rank is " << rk << endl;
2508 }
2509
2510 s = NEW_char(rk.len() + 1);
2511 for (i = rk.len() - 1, j = 0; i >= 0; i--, j++) {
2512 s[j] = '0' + rk.rep()[i];
2513 }
2514 s[rk.len()] = 0;
2515
2516 if (f_v) {
2517 cout << "created string " << s << endl;
2518 }
2519
2520 if (f_v) {
2521 cout << "ring_theory_global::search_for_primitive_polynomial_of_given_degree done" << endl;
2522 }
2523 return s;
2524}
2525
2526
2528 int p_min, int p_max, int n_min, int n_max,
2529 int verbose_level)
2530{
2531 int f_v = (verbose_level >= 1);
2532 int d, q;
2534
2535
2537
2538
2539 if (f_v) {
2540 cout << "ring_theory_global::search_for_primitive_polynomials "
2541 "p_min=" << p_min << " p_max=" << p_max
2542 << " n_min=" << n_min << " n_max=" << n_max << endl;
2543 }
2544 for (q = p_min; q <= p_max; q++) {
2545
2546
2547 if (!NT.is_prime_power(q)) {
2548 continue;
2549 }
2550
2551 if (f_v) {
2552 cout << "ring_theory_global::search_for_primitive_polynomials "
2553 "considering the coefficient field of order " << q << endl;
2554 }
2555
2556 {
2558 Fq.finite_field_init(q, FALSE /* f_without_tables */, 0 /*verbose_level*/);
2559 unipoly_domain FX(&Fq);
2560
2563
2564 FX.create_object_by_rank(m, 0, __FILE__, __LINE__, verbose_level);
2565
2566 for (d = n_min; d <= n_max; d++) {
2567 if (f_v) {
2568 cout << "d=" << d << endl;
2569 }
2570 FX.get_a_primitive_polynomial(m, d, verbose_level);
2571 FX.rank_longinteger(m, rk);
2572 //cout << d << " : " << rk << " : ";
2573 cout << "\"" << rk << "\", // ";
2574 FX.print_object(m, cout);
2575 cout << endl;
2576 }
2577 if (f_v) {
2578 cout << "ring_theory_global::search_for_primitive_polynomials "
2579 "before FX.delete_object(m)" << endl;
2580 }
2581 FX.delete_object(m);
2582 if (f_v) {
2583 cout << "ring_theory_global::search_for_primitive_polynomials "
2584 "after FX.delete_object(m)" << endl;
2585 }
2586 }
2587 }
2588 if (f_v) {
2589 cout << "ring_theory_global::search_for_primitive_polynomials done" << endl;
2590 }
2591}
2592
2593
2595 int *coeffs, int f_poly, std::string &poly, int verbose_level)
2596{
2597 int f_v = (verbose_level >= 1);
2598 int p, e, m, i, j, Q, a, b, c, cv, ccv, t, r1, r2, len;
2599 int field_degree, subgroup_index;
2603
2604 NT.factor_prime_power(q, p, e);
2605 if (f_v) {
2606 cout << "ring_theory_global::factor_cyclotomic q=" << q << " p=" << q
2607 << " e=" << e << " n=" << n << endl;
2608 }
2609 m = NT.order_mod_p(q, n);
2610 if (f_v) {
2611 cout << "ring_theory_global::factor_cyclotomic order mod q is m=" << m << endl;
2612 }
2613 field_degree = e * m;
2614 Q = NT.i_power_j(p, field_degree);
2615
2616
2617 if (f_poly) {
2618 Fq.init_override_polynomial(q, poly, FALSE /* f_without_tables */, verbose_level - 1);
2619 }
2620 else {
2621 Fq.finite_field_init(q, FALSE /* f_without_tables */, verbose_level - 2);
2622 }
2623 FQ.finite_field_init(Q, FALSE /* f_without_tables */, verbose_level - 2);
2624
2625 FQ.compute_subfields(verbose_level);
2626
2627 subgroup_index = (Q - 1) / (q - 1);
2628
2629 unipoly_domain FQX(&FQ);
2630 unipoly_object quo, rem, h, Xma;
2631
2632 FQX.create_object_of_degree(h, d);
2633
2634 if (e > 1) {
2635 cout << "ring_theory_global::factor_cyclotomic "
2636 "embedding the coefficients into the larger field" << endl;
2637 for (i = 0; i <= d; i++) {
2638 c = coeffs[i];
2639 if (c == 0) {
2640 t = 0;
2641 }
2642 else {
2643 a = Fq.log_alpha(c);
2644 t = a * subgroup_index;
2645 t = FQ.alpha_power(t);
2646 }
2647 FQX.s_i(h, i) = t;
2648 }
2649 }
2650 else {
2651 for (i = 0; i <= d; i++) {
2652 FQX.s_i(h, i) = coeffs[i];
2653 }
2654 }
2655
2656 if (f_v) {
2657 cout << "ring_theory_global::factor_cyclotomic "
2658 "the polynomial is: ";
2659 FQX.print_object(h, cout);
2660 cout << endl;
2661 }
2662
2663
2664 FQX.create_object_of_degree(quo, d);
2665 FQX.create_object_of_degree(rem, d);
2666
2667 int *roots;
2668 int *roots2;
2669 int nb_roots = 0;
2670 int beta = (Q - 1) / n, Beta;
2671
2672 Beta = FQ.alpha_power(beta);
2673
2674 if (f_v) {
2675 cout << "ring_theory_global::factor_cyclotomic "
2676 "the primitive n-th root of unity we choose "
2677 "is beta = alpha^" << beta << " = " << Beta << endl;
2678 }
2679
2680 roots = NEW_int(n);
2681 roots2 = NEW_int(n);
2682 for (a = 0; a < n; a++) {
2683 FQX.create_object_of_degree(Xma, 1);
2684 t = FQ.power(Beta, a);
2685 FQX.s_i(Xma, 0) = FQ.negate(t);
2686 FQX.s_i(Xma, 1) = 1;
2687 FQX.division_with_remainder(h, Xma, quo, rem, 0);
2688 b = FQX.s_i(rem, 0);
2689 if (b == 0) {
2690 cout << "ring_theory_global::factor_cyclotomic "
2691 "zero Beta^" << a << " log "
2692 << FQ.log_alpha(t) << endl;
2693 roots[nb_roots++] = a;
2694 }
2695 }
2696
2697 exit(1);
2698
2700 longinteger_object C, N, A, B, G, U, V;
2702
2703 for (c = 0; c < n; c++) {
2704 if (NT.gcd_lint(c, n) != 1)
2705 continue;
2706 C.create(c, __FILE__, __LINE__);
2707 N.create(n, __FILE__, __LINE__);
2708 D.extended_gcd(C, N, G, U, V, FALSE);
2709 cv = U.as_int();
2710 ccv= c * cv;
2711 cout << c << " : " << cv << " : ";
2712 if (ccv < 0) {
2713 if ((-ccv % n) != n - 1) {
2714 cout << "ring_theory_global::factor_cyclotomic "
2715 "error: c=" << c << " cv=" << cv << endl;
2716 exit(1);
2717 }
2718 }
2719 else if ((ccv % n) != 1) {
2720 cout << "ring_theory_global::factor_cyclotomic "
2721 "error: c=" << c << " cv=" << cv << endl;
2722 exit(1);
2723 }
2724 for (i = 0; i < nb_roots; i++) {
2725 roots2[i] = (cv * roots[i]) % n;
2726 while (roots2[i] < 0) {
2727 roots2[i] += n;
2728 }
2729 }
2730 Sorting.int_vec_quicksort_increasingly(roots2, nb_roots);
2731 t = 0;
2732 for (i = 0; i < nb_roots; i++) {
2733 r1 = roots2[i];
2734 for (j = i + 1; j < i + nb_roots; j++) {
2735 r2 = roots2[j % nb_roots];
2736 if (r2 != r1 + 1) {
2737 break;
2738 }
2739 }
2740 len = j - i - 1;
2741 t = MAXIMUM(t, len);
2742 }
2743 for (i = 0; i < nb_roots; i++) {
2744 cout << roots2[i] << " ";
2745 }
2746 cout << " : " << t << endl;
2747 }
2748}
2749
2752 int *S, unipoly_domain &D, unipoly_object &poly,
2753 int verbose_level)
2754{
2755 int f_v = (verbose_level >= 1);
2756 int i, v[3], x; //, y;
2757 int *map;
2758
2759 if (f_v) {
2760 cout << "ring_theory_global::oval_polynomial" << endl;
2761 }
2762 map = NEW_int(F->q);
2763 for (i = 0; i < F->q; i++) {
2765 v, 1 /* stride */, 3 /* len */, S[2 + i]);
2766 if (v[2] != 1) {
2767 cout << "ring_theory_global::oval_polynomial "
2768 "not an affine point" << endl;
2769 exit(1);
2770 }
2771 x = v[0];
2772 //y = v[1];
2773 //cout << "map[" << i << "] = " << xx << endl;
2774 map[i] = x;
2775 }
2776 if (f_v) {
2777 cout << "the map" << endl;
2778 for (i = 0; i < F->q; i++) {
2779 cout << map[i] << " ";
2780 }
2781 cout << endl;
2782 }
2783
2784 D.create_Dickson_polynomial(poly, map);
2785
2786 FREE_int(map);
2787 if (f_v) {
2788 cout << "ring_theory_global::oval_polynomial done" << endl;
2789 }
2790}
2791
2793 ostream &ost, int *factors, int len)
2794{
2797
2798 D.multiply_up(a, factors, len, 0 /* verbose_level */);
2799 ost << a;
2800}
2801
2802
2803#if 0
2804void finite_field::do_ideal(int n,
2805 long int *set_in, int set_size, int degree,
2806 long int *&set_out, int &size_out,
2807 monomial_ordering_type Monomial_ordering_type,
2808 int verbose_level)
2809{
2810 int f_v = (verbose_level >= 1);
2812 int *Kernel;
2813 int *w1;
2814 int *w2;
2815 long int *Pts;
2816 int nb_pts;
2817 int r, h, ns;
2818 geometry_global Gg;
2819
2820 if (f_v) {
2821 cout << "finite_field::do_ideal" << endl;
2822 }
2823
2824 size_out = 0;
2825
2826 HPD = NEW_OBJECT(homogeneous_polynomial_domain);
2827
2828 if (f_v) {
2829 cout << "finite_field::do_ideal before HPD->init" << endl;
2830 }
2831 HPD->init(this, n + 1, degree,
2832 FALSE /* f_init_incidence_structure */,
2833 Monomial_ordering_type,
2834 verbose_level - 2);
2835 if (f_v) {
2836 cout << "finite_field::do_ideal after HPD->init" << endl;
2837 }
2838
2839 Kernel = NEW_int(HPD->get_nb_monomials() * HPD->get_nb_monomials());
2840 w1 = NEW_int(HPD->get_nb_monomials());
2841 w2 = NEW_int(HPD->get_nb_monomials());
2842
2843 if (f_v) {
2844 cout << "finite_field::do_ideal before HPD->vanishing_ideal" << endl;
2845 }
2846 HPD->vanishing_ideal(set_in, set_size,
2847 r, Kernel, 0 /*verbose_level */);
2848 if (f_v) {
2849 cout << "finite_field::do_ideal after HPD->vanishing_ideal" << endl;
2850 }
2851
2852 ns = HPD->get_nb_monomials() - r; // dimension of null space
2853 cout << "The system has rank " << r << endl;
2854 cout << "The ideal has dimension " << ns << endl;
2855 cout << "and is generated by:" << endl;
2856 Orbiter->Int_vec.matrix_print(Kernel, ns, HPD->get_nb_monomials());
2857 cout << "corresponding to the following basis "
2858 "of polynomials:" << endl;
2859 for (h = 0; h < ns; h++) {
2860 HPD->print_equation(cout, Kernel + h * HPD->get_nb_monomials());
2861 cout << endl;
2862 }
2863
2864 cout << "looping over all generators of the ideal:" << endl;
2865 for (h = 0; h < ns; h++) {
2866 cout << "generator " << h << " / " << ns << ":" << endl;
2867
2868 vector<long int> Points;
2869 int i;
2870
2871 HPD->enumerate_points(Kernel + h * HPD->get_nb_monomials(),
2872 Points, verbose_level);
2873 nb_pts = Points.size();
2874
2875 Pts = NEW_lint(nb_pts);
2876 for (i = 0; i < nb_pts; i++) {
2877 Pts[i] = Points[i];
2878 }
2879
2880
2881 cout << "We found " << nb_pts << " points on the generator of the ideal" << endl;
2882 cout << "They are : ";
2883 Orbiter->Lint_vec.print(cout, Pts, nb_pts);
2884 cout << endl;
2885 HPD->get_P()->print_set_numerical(cout, Pts, nb_pts);
2886
2887
2888 if (h == 0) {
2889 size_out = HPD->get_nb_monomials();
2890 set_out = NEW_lint(size_out);
2891 //int_vec_copy(Kernel + h * HPD->nb_monomials, set_out, size_out);
2892 int u;
2893 for (u = 0; u < size_out; u++) {
2894 set_out[u] = Kernel[h * HPD->get_nb_monomials() + u];
2895 }
2896 //break;
2897 }
2898 FREE_lint(Pts);
2899
2900 }
2901
2902#if 0
2903 int N;
2904 int *Pts;
2905 cout << "looping over all elements of the ideal:" << endl;
2906 N = Gg.nb_PG_elements(ns - 1, q);
2907 for (h = 0; h < N; h++) {
2908 PG_element_unrank_modified(w1, 1, ns, h);
2909 cout << "element " << h << " / " << N << " w1=";
2910 int_vec_print(cout, w1, ns);
2911 mult_vector_from_the_left(w1, Kernel, w2, ns, HPD->get_nb_monomials());
2912 cout << " w2=";
2913 int_vec_print(cout, w2, HPD->get_nb_monomials());
2914 HPD->enumerate_points(w2, Pts, nb_pts, verbose_level);
2915 cout << " We found " << nb_pts << " points on this curve" << endl;
2916 }
2917#endif
2918
2919 FREE_OBJECT(HPD);
2920 FREE_int(Kernel);
2921 FREE_int(w1);
2922 FREE_int(w2);
2923}
2924#endif
2925
2926
2927
2928}}}
2929
2930
void print_polynomial(ring_theory::unipoly_domain &Fq, int degree, ring_theory::unipoly_object *coeffs)
void vec_print(std::vector< std::vector< int > > &p)
Definition: int_vec.cpp:351
void print(std::ostream &ost, long int *v, int len)
Definition: lint_vec.cpp:246
a collection of functions related to sorted vectors
int lint_vec_search(long int *v, int len, long int a, int &idx, int verbose_level)
Definition: sorting.cpp:1157
a statistical analysis of data consisting of single integers
void init(int *data, int data_length, int f_second, int verbose_level)
Definition: tally.cpp:72
void PG_element_rank_modified(int *v, int stride, int len, int &a)
void PG_element_unrank_modified(int *v, int stride, int len, int a)
void display_table_of_projective_points(std::ostream &ost, long int *Pts, int nb_pts, int len)
void finite_field_init(int q, int f_without_tables, int verbose_level)
void init_override_polynomial(int q, std::string &poly, int f_without_tables, int verbose_level)
various functions related to geometries
Definition: geometry.h:721
long int AG_element_rank(int q, int *v, int stride, int len)
void print_set_numerical(std::ostream &ost, long int *set, int set_size)
provides access to pre-computed combinatorial data in encoded form
void get_primitive_polynomial(std::string &poly, int p, int e, int verbose_level)
void mult_vector_from_the_right(int *A, int *v, int *Av, int m, int n)
void lint_vec_write_csv(long int *v, int len, std::string &fname, const char *label)
Definition: file_io.cpp:1191
void read_set_from_file(std::string &fname, long int *&the_set, int &set_size, int verbose_level)
Definition: file_io.cpp:2374
void head(std::ostream &ost, int f_book, int f_title, const char *title, const char *author, int f_toc, int f_landscape, int f_12pt, int f_enlarged_page, int f_pagenumbers, const char *extras_for_preamble)
void get_vector_from_label(std::string &label, int *&v, int &sz, int verbose_level)
homogeneous polynomials of a given degree in a given number of variables over a finite field GF(q)
Definition: ring_theory.h:88
void init(field_theory::finite_field *F, int nb_vars, int degree, int f_init_incidence_structure, monomial_ordering_type Monomial_ordering_type, int verbose_level)
void enumerate_points(int *coeff, std::vector< long int > &Pts, int verbose_level)
void enumerate_points_zariski_open_set(int *coeff, std::vector< long int > &Pts, int verbose_level)
void vanishing_ideal(long int *Pts, int nb_pts, int &r, int *Kernel, int verbose_level)
domain to compute with objects of type longinteger
Definition: ring_theory.h:240
void extended_gcd(longinteger_object &a, longinteger_object &b, longinteger_object &g, longinteger_object &u, longinteger_object &v, int verbose_level)
void multiply_up(longinteger_object &a, int *x, int len, int verbose_level)
void add(longinteger_object &a, longinteger_object &b, longinteger_object &c)
void integral_division_by_int(longinteger_object &a, int b, longinteger_object &q, int &r)
void factor_into_longintegers(longinteger_object &a, int &nb_primes, longinteger_object *&primes, int *&exponents, int verbose_level)
a class to represent arbitrary precision integers
Definition: ring_theory.h:366
void create(long int i, const char *file, int line)
void polynomial_division_with_report(field_theory::finite_field *F, long int rk0, long int rk1, int verbose_level)
void create_projective_variety(field_theory::finite_field *F, std::string &variety_label, std::string &variety_label_tex, int variety_nb_vars, int variety_degree, std::string &variety_coeffs, monomial_ordering_type Monomial_ordering_type, std::string &label_txt, std::string &label_tex, int &nb_pts, long int *&Pts, int verbose_level)
void polynomial_division_from_file_all_k_error_patterns_with_report(field_theory::finite_field *F, std::string &input_file, long int rk1, int k, int verbose_level)
void write_code_for_division(field_theory::finite_field *F, std::string &fname_code, std::string &A_coeffs, std::string &B_coeffs, int verbose_level)
void make_all_irreducible_polynomials_of_degree_d(field_theory::finite_field *F, int d, std::vector< std::vector< int > > &Table, int verbose_level)
void polynomial_division(field_theory::finite_field *F, std::string &A_coeffs, std::string &B_coeffs, int verbose_level)
char * search_for_primitive_polynomial_of_given_degree(int p, int degree, int verbose_level)
void sift_polynomials(field_theory::finite_field *F, long int rk0, long int rk1, int verbose_level)
void do_make_table_of_irreducible_polynomials(field_theory::finite_field *F, int deg, int verbose_level)
void oval_polynomial(field_theory::finite_field *F, int *S, unipoly_domain &D, unipoly_object &poly, int verbose_level)
int count_all_irreducible_polynomials_of_degree_d(field_theory::finite_field *F, int d, int verbose_level)
void create_intersection_of_zariski_open_sets(field_theory::finite_field *F, std::string &variety_label_txt, std::string &variety_label_tex, int variety_nb_vars, int variety_degree, std::vector< std::string > &Variety_coeffs, monomial_ordering_type Monomial_ordering_type, std::string &label_txt, std::string &label_tex, int &nb_pts, long int *&Pts, int verbose_level)
void print_longinteger_after_multiplying(std::ostream &ost, int *factors, int len)
void polynomial_division_from_file_with_report(field_theory::finite_field *F, std::string &input_file, long int rk1, int verbose_level)
void extended_gcd_for_polynomials(field_theory::finite_field *F, std::string &A_coeffs, std::string &B_coeffs, int verbose_level)
void mult_polynomials(field_theory::finite_field *F, long int rk0, long int rk1, int verbose_level)
void factor_cyclotomic(int n, int q, int d, int *coeffs, int f_poly, std::string &poly, int verbose_level)
void create_irreducible_polynomial(field_theory::finite_field *F, unipoly_domain *Fq, unipoly_object *&Beta, int n, long int *cyclotomic_set, int cylotomic_set_size, unipoly_object *&generator, int verbose_level)
void search_for_primitive_polynomials(int p_min, int p_max, int n_min, int n_max, int verbose_level)
void compute_nth_roots_as_polynomials(field_theory::finite_field *F, unipoly_domain *FpX, unipoly_domain *Fq, unipoly_object *&Beta, int n1, int n2, int verbose_level)
void polynomial_mult_mod(field_theory::finite_field *F, std::string &A_coeffs, std::string &B_coeffs, std::string &M_coeffs, int verbose_level)
void create_projective_curve(field_theory::finite_field *F, std::string &variety_label_txt, std::string &variety_label_tex, int curve_nb_vars, int curve_degree, std::string &curve_coeffs, monomial_ordering_type Monomial_ordering_type, std::string &label_txt, std::string &label_tex, int &nb_pts, long int *&Pts, int verbose_level)
void do_search_for_primitive_polynomial_in_range(int p_min, int p_max, int deg_min, int deg_max, int verbose_level)
void compute_powers(field_theory::finite_field *F, unipoly_domain *Fq, int n, int start_idx, unipoly_object *&Beta, int verbose_level)
void number_of_conditions_satisfied(field_theory::finite_field *F, std::string &variety_label_txt, std::string &variety_label_tex, int variety_nb_vars, int variety_degree, std::vector< std::string > &Variety_coeffs, monomial_ordering_type Monomial_ordering_type, std::string &number_of_conditions_satisfied_fname, std::string &label_txt, std::string &label_tex, int &nb_pts, long int *&Pts, int verbose_level)
void polynomial_find_roots(field_theory::finite_field *F, std::string &A_coeffs, int verbose_level)
domain of polynomials in one variable over a finite field
Definition: ring_theory.h:691
int substitute_scalar_in_polynomial(unipoly_object &p, int scalar, int verbose_level)
void add(unipoly_object a, unipoly_object b, unipoly_object &c)
void power_int(unipoly_object &a, int n, int verbose_level)
void get_a_primitive_polynomial(unipoly_object &m, int f, int verbose_level)
void mult_easy_with_report(long int rk_a, long int rk_b, long int &rk_c, std::ostream &ost, int verbose_level)
int is_primitive(unipoly_object &m, longinteger_object &qm1, int nb_primes, longinteger_object *primes, int verbose_level)
void mult_mod(unipoly_object a, unipoly_object b, unipoly_object &c, unipoly_object m, int verbose_level)
void division_with_remainder_from_file_all_k_bit_error_patterns(std::string &input_fname, long int rk_b, int k, long int *&rk_q, long int *&rk_r, int &n, int &N, std::ostream &ost, int verbose_level)
void mult(unipoly_object a, unipoly_object b, unipoly_object &c, int verbose_level)
void compute_normal_basis(int d, int *Normal_basis, int *Frobenius, int verbose_level)
void extended_gcd(unipoly_object m, unipoly_object n, unipoly_object &u, unipoly_object &v, unipoly_object &g, int verbose_level)
void minimum_polynomial_extension_field(unipoly_object &g, unipoly_object m, unipoly_object &minpol, int d, int *Frobenius, int verbose_level)
void division_with_remainder_from_file_with_report(std::string &input_fname, long int rk_b, long int &rk_q, long int &rk_r, std::ostream &ost, int verbose_level)
void division_with_remainder(unipoly_object a, unipoly_object b, unipoly_object &q, unipoly_object &r, int verbose_level)
int is_irreducible(unipoly_object a, int verbose_level)
void Frobenius_matrix(int *&Frob, unipoly_object factor_polynomial, int verbose_level)
void create_object_by_rank(unipoly_object &p, long int rk, const char *file, int line, int verbose_level)
void create_Dickson_polynomial(unipoly_object &p, int *map)
void division_with_remainder_numerically_with_report(long int rk_a, long int rk_b, long int &rk_q, long int &rk_r, std::ostream &ost, int verbose_level)
void create_object_by_rank_string(unipoly_object &p, std::string &rk, int verbose_level)
void rank_longinteger(unipoly_object p, longinteger_object &rank)
void assign(unipoly_object a, unipoly_object &b, int verbose_level)
void print_object(unipoly_object p, std::ostream &ost)
#define Lint_vec_copy(A, B, C)
Definition: foundations.h:694
#define FREE_OBJECTS(p)
Definition: foundations.h:652
#define Int_vec_scan(A, B, C)
Definition: foundations.h:716
#define FREE_int(p)
Definition: foundations.h:640
#define Int_vec_zero(A, B)
Definition: foundations.h:713
#define NEW_char(n)
Definition: foundations.h:632
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define FREE_OBJECT(p)
Definition: foundations.h:651
#define NEW_int(n)
Definition: foundations.h:625
#define Int_matrix_print(A, B, C)
Definition: foundations.h:707
#define NEW_OBJECTS(type, n)
Definition: foundations.h:639
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define FREE_lint(p)
Definition: foundations.h:642
#define NEW_lint(n)
Definition: foundations.h:628
#define Int_vec_print(A, B, C)
Definition: foundations.h:685
#define MAXIMUM(x, y)
Definition: foundations.h:217
orbiter_kernel_system::orbiter_session * Orbiter
global Orbiter session
the orbiter library for the classification of combinatorial objects