Orbiter 2022
Combinatorial Objects
algebra_global.cpp
Go to the documentation of this file.
1/*
2 * algebra_global.cpp
3 *
4 * Created on: Nov 25, 2019
5 * Author: betten
6 */
7
8
9
10
11
12
13#include "foundations.h"
14
15using namespace std;
16
17namespace orbiter {
18namespace layer1_foundations {
19namespace algebra {
20
21
22
23void algebra_global::count_subprimitive(int Q_max, int H_max)
24{
25 int q, h, p, e, i, g, phi_g, l, cmp;
26 int *Q, *Rdq, *G, nb_primes = 0;
30
31 //formula(2, 64, r2, 1);
32
33 Q = new int[Q_max];
34 Rdq = new int[Q_max * H_max];
35 G = new int[Q_max * H_max];
36
37 for (q = 2; q <= Q_max; q++) {
38 if (NT.is_prime_power(q, p, e)) {
39 Q[nb_primes] = q;
40
41 cout << "studying prime power " << q << endl;
42 for (h = 2; h <= H_max; h++) {
43 //r1 = subprimitive(q, h);
44 formula_subprimitive(h, q, r3, g, 1);
45 phi_g = NT.eulers_totient_function(g, 1);
46 formula(h, q, r2, 1);
47 //cout << "The experiment gives " << r1 << endl;
48 cout << "g= " << g << endl;
49 cout << "\\Phi(g)= " << phi_g << endl;
50 cout << "The formula gives " << r2 << endl;
51 cout << "#subprimitive " << r3 << endl;
52 l = (phi_g * (q - 1)) / g;
53 cout << "l=" << l << endl;
54 A.create(l, __FILE__, __LINE__);
55 D.mult(r2, A, B);
56 cout << "#subprimitive from R_c(d,q)=" << B << endl;
57 cmp = D.compare_unsigned(r3, B);
58 if (cmp) {
59 cout << "cmp=" << cmp << endl;
60 exit(1);
61 }
62
63 //cout << h << " times it = " << h * r2 << endl;
64#if 0
65 if (r1 != r2 * h) {
66 cout << "r1 != r2 * h" << endl;
67 exit(1);
68 }
69#endif
70 Rdq[nb_primes * H_max + h - 2] = r2.as_int();
71 G[nb_primes * H_max + h - 2] = g;
72 }
73 nb_primes++;
74 }
75 }
76 for (i = 0; i < nb_primes; i++) {
77 cout << setw(10) << Q[i];
78 for (h = 2; h <= H_max; h++) {
79 cout << " & " << setw(10) << Rdq[i * H_max + h - 2]
80 << "_{" << setw(3) << G[i * H_max + h - 2] << "}";
81 }
82 cout << "\\\\" << endl;
83 }
84}
85
86
87
89 ring_theory::longinteger_object &Rdq, int &g, int verbose_level)
90{
91 int f_v = (verbose_level >= 1);
92 int theta_mod_qm1, p, e, i, rem;
93 int nb_primes, *primes, *exponents;
95 ring_theory::longinteger_object Theta, M1, Qm1, A, B, C, R;
97
98 if (f_v) {
99 cout << "algebra_global::formula_subprimitive d=" << d << " q=" << q << endl;
100 }
101 Theta.create(q, __FILE__, __LINE__);
102 M1.create(-1, __FILE__, __LINE__);
103 Qm1.create(q-1, __FILE__, __LINE__);
104 D.power_int(Theta, d);
105 D.add(Theta, M1, A);
106 if (f_v) {
107 cout << "q^d-1 = " << A << endl;
108 }
109 D.integral_division(A, Qm1, Theta, C, 0);
110 if (f_v) {
111 cout << "theta = " << Theta << endl;
112 }
113 D.integral_division_by_int(Theta, q - 1, C, theta_mod_qm1);
114 g = NT.gcd_lint(q - 1, theta_mod_qm1);
115 if (f_v) {
116 cout << "g = " << g << endl;
117 }
118 D.factor(Theta, nb_primes, primes, exponents, verbose_level);
119 if (f_v) {
120 cout << "theta = " << Theta << endl;
121 NT.print_factorization(nb_primes, primes, exponents);
122 cout << endl;
123 }
124 R.create(1, __FILE__, __LINE__);
125 for (i = 0; i < nb_primes; i++) {
126 p = primes[i];
127 e = exponents[i];
128 if (f_v) {
129 cout << "p=" << p << " e=" << e << endl;
130 }
131 //r = r * (i_power_j(p, e) - i_power_j(p, e - 1));
132 A.create(p, __FILE__, __LINE__);
133 D.power_int(A, e);
134 if (f_v) {
135 cout << "p^e=" << A << endl;
136 }
137 B.create(p, __FILE__, __LINE__);
138 D.power_int(B, e - 1);
139 if (f_v) {
140 cout << "p^{e-1}=" << A << endl;
141 }
142 B.negate();
143 D.add(A, B, C);
144 if (f_v) {
145 cout << "p^e-p^{e-1}=" << C << endl;
146 }
147 D.mult(R, C, A);
148 A.assign_to(R);
149 if (f_v) {
150 cout << "R=" << R << endl;
151 }
152 }
153 if (f_v) {
154 cout << "\\Phi(theta)=" << R << endl;
155 }
156 D.mult(R, Qm1, B);
157 B.assign_to(R);
158 if (f_v) {
159 cout << "(q-1)\\Phi(theta)=" << R << endl;
160 }
161 D.integral_division_by_int(R, d, A, rem);
162 if (rem) {
163 cout << "R not divisible by d" << endl;
164 exit(1);
165 }
166 if (f_v) {
167 cout << "R/d=" << A << endl;
168 }
169 A.assign_to(Rdq);
170 if (f_v) {
171 cout << "algebra_global::formula_subprimitive done" << endl;
172 }
173}
174
175void algebra_global::formula(int d, int q, ring_theory::longinteger_object &Rdq, int verbose_level)
176{
177 int f_v = (verbose_level >= 1);
178 int theta_mod_qm1, g, p, e, i, rem;
179 int nb_primes, *primes, *exponents;
181 ring_theory::longinteger_object Theta, M1, Qm1, A, B, C, R;
183
184 if (f_v) {
185 cout << "algebra_global::formula d=" << d << " q=" << q << endl;
186 }
187 Theta.create(q, __FILE__, __LINE__);
188 M1.create(-1, __FILE__, __LINE__);
189 Qm1.create(q - 1, __FILE__, __LINE__);
190 D.power_int(Theta, d);
191 D.add(Theta, M1, A);
192 if (f_v) {
193 cout << "q^d-1 = " << A << endl;
194 }
195 D.integral_division(A, Qm1, Theta, C, 0);
196 if (f_v) {
197 cout << "theta = " << Theta << endl;
198 }
200 q - 1, C, theta_mod_qm1);
201 g = NT.gcd_lint(q - 1, theta_mod_qm1);
202 if (f_v) {
203 cout << "g = " << g << endl;
204 }
205 D.factor(Theta, nb_primes, primes, exponents, verbose_level);
206 if (f_v) {
207 cout << "theta = " << Theta << endl;
208 NT.print_factorization(nb_primes, primes, exponents);
209 cout << endl;
210 }
211 R.create(1, __FILE__, __LINE__);
212 for (i = 0; i < nb_primes; i++) {
213 p = primes[i];
214 e = exponents[i];
215 if (f_v) {
216 cout << "p=" << p << " e=" << e << endl;
217 }
218 if (((q - 1) % p) == 0) {
219 A.create(p, __FILE__, __LINE__);
220 D.power_int(A, e);
221 D.mult(R, A, B);
222 B.assign_to(R);
223 }
224 else {
225 //r = r * (i_power_j(p, e) - i_power_j(p, e - 1));
226 A.create(p, __FILE__, __LINE__);
227 D.power_int(A, e);
228 cout << "p^e=" << A << endl;
229 B.create(p, __FILE__, __LINE__);
230 D.power_int(B, e - 1);
231 cout << "p^{e-1}=" << A << endl;
232 B.negate();
233 D.add(A, B, C);
234 cout << "p^e-p^{e-1}=" << C << endl;
235 D.mult(R, C, A);
236 A.assign_to(R);
237 cout << "R=" << R << endl;
238 }
239 }
240 if (f_v) {
241 cout << "R=" << R << endl;
242 }
243 D.integral_division_by_int(R, d, A, rem);
244 if (rem) {
245 cout << "R not divisible by d" << endl;
246 exit(1);
247 }
248 if (f_v) {
249 cout << "R/d=" << A << endl;
250 }
251 A.assign_to(Rdq);
252}
253
255{
256 int Q, f, i, j, k, s, c, l, r = 0;
258
259 Q = NT.i_power_j(q, h);
260 f = (Q - 1) / (q - 1);
261 cout << "q=" << q << " h=" << h << endl;
262 //cout << " Q=" << Q << " f=" << f << endl;
263 int *S, *C, *SM, *CM;
264
265
266 S = NEW_int(f * (q - 1));
267 C = NEW_int(f * (q - 1));
268 SM = NEW_int(Q);
269 CM = NEW_int(q - 1);
270 for (k = 0; k < Q; k++) {
271 SM[k] = 0;
272 }
273 for (k = 0; k < q - 1; k++) {
274 CM[k] = 0;
275 }
276
277 for (k = 0; k < f; k++) {
278 for (j = 0; j < q - 1; j++) {
279 subexponent(q, Q, h, f, j, k, s, c);
280 S[k * (q - 1) + j] = s;
281 if (s >= Q) {
282 cout << "s=" << s << " >= Q=" << Q << endl;
283 exit(1);
284 }
285 SM[s]++;
286 if (s == f) {
287 if (c >= q - 1) {
288 cout << "c=" << c << " >= q-1=" << q-1 << endl;
289 exit(1);
290 }
291 CM[c]++;
292 C[k * (q - 1) + j] = c;
293 }
294 else {
295 C[k * (q - 1) + j] = -1;
296 }
297 }
298 }
299#if 0
300 cout << "subexponents mod " << q - 1 << " :" << endl;
301 print_integer_matrix_width(cout, S, f, q - 1, q - 1, 2);
302 cout << "subexponents mod " << f << " :" << endl;
303 print_integer_matrix_width(cout, S, q - 1, f, f, 2);
304 cout << "integral elements:" << endl;
305 print_integer_matrix_width(cout, C, f, q - 1, q - 1, 2);
306 cout << "integral elements mod " << f << " :" << endl;
307 print_integer_matrix_width(cout, C, q - 1, f, f, 2);
308
309 cout << "multiplicities SM:" << endl;
310 for (i = 0; i < Q; i++) {
311 if (SM[i]) {
312 cout << i << " : " << SM[i] << endl;
313 }
314 }
315#endif
316 cout << f << "^" << SM[f] << endl;
317 cout << "multiplicities CM:" << endl;
318 Int_vec_print_integer_matrix_width(cout, CM, 1, q - 1, q - 1, 2);
319 l = period_of_sequence(CM, q - 1);
320 cout << "period " << l << endl;
321 for (i = 0; i < q - 1; i++) {
322 if (CM[i]) {
323 r = CM[i];
324 }
325 }
326
327 //cout << "delete S" << endl;
328 FREE_int(S);
329 //cout << "delete C" << endl;
330 FREE_int(C);
331 //cout << "delete SM" << endl;
332 FREE_int(SM);
333 //cout << "delete CM" << endl;
334 FREE_int(CM);
335 return r;
336}
337
339{
340 int p, i, j;
341
342 for (p = 1; p < l; p++) {
343 // test if period p;
344 for (i = 0; i < l; i++) {
345 j = i + p;
346 if (j < l) {
347 if (v[i] != v[j])
348 break;
349 }
350 }
351 if (i == l) {
352 return p;
353 }
354 }
355 return l;
356}
357
358void algebra_global::subexponent(int q, int Q, int h, int f, int j, int k, int &s, int &c)
359{
360 int a, g;
362
363 a = j + k * (q - 1);
364 g = NT.gcd_lint(a, f);
365 s = f / g;
366 c = a / g;
367 c = c % (q - 1);
368#if 0
369 for (s = 1; TRUE; s++) {
370 b = a * s;
371 if ((b % f) == 0) {
372 c = b / f;
373 c = c % (q - 1);
374 return;
375 }
376 }
377#endif
378}
379
380
381const char *algebra_global::plus_minus_string(int epsilon)
382{
383 if (epsilon == 1) {
384 return "+";
385 }
386 if (epsilon == -1) {
387 return "-";
388 }
389 if (epsilon == 0) {
390 return "";
391 }
392 cout << "algebra_global::plus_minus_string epsilon=" << epsilon << endl;
393 exit(1);
394}
395
396const char *algebra_global::plus_minus_letter(int epsilon)
397{
398 if (epsilon == 1) {
399 return "p";
400 }
401 if (epsilon == -1) {
402 return "m";
403 }
404 if (epsilon == 0) {
405 return "";
406 }
407 cout << "algebra_global::plus_minus_letter epsilon=" << epsilon << endl;
408 exit(1);
409}
410
411
412
413
415{
416 int *v = NEW_int(n + 1);
417 int l;
418 int i, j, a;
420
421 if (!R.f_chain_ring) {
422 cout << "algebra_global::display_all_PHG_elements not a chain ring" << endl;
423 exit(1);
424 }
425 R.init(q, 0);
426 l = R.nb_PHG_elements(n);
427 for (i = 0; i < l; i++) {
428 R.PHG_element_unrank(v, 1, n + 1, i);
429 cout << i << " : ";
430 for (j = 0; j < n + 1; j++) {
431 cout << v[j] << " ";
432 }
433 a = R.PHG_element_rank(v, 1, n + 1);
434 cout << " : " << a << endl;
435 }
436 FREE_int(v);
437}
438
440{
442 int p = 2;
445 int i, j;
446 int verbose_level = 0;
447
448 GFp.finite_field_init(p, FALSE /* f_without_tables */, verbose_level);
450
451 FX.create_object_by_rank(m, 7, __FILE__, __LINE__, 0);
452 FX.create_object_by_rank(a, 5, __FILE__, __LINE__, 0);
453 FX.create_object_by_rank(b, 55, __FILE__, __LINE__, 0);
454 FX.print_object(a, cout); cout << endl;
455 FX.print_object(b, cout); cout << endl;
456
457 ring_theory::unipoly_domain Fq(&GFp, m, verbose_level);
458 Fq.create_object_by_rank(c, 2, __FILE__, __LINE__, 0);
459 for (i = 0; i < 4; i++) {
460 Fq.create_object_by_rank(elts[i], i, __FILE__, __LINE__, 0);
461 cout << "elt_" << i << " = ";
462 Fq.print_object(elts[i], cout); cout << endl;
463 }
464 for (i = 0; i < 4; i++) {
465 for (j = 0; j < 4; j++) {
466 Fq.print_object(elts[i], cout);
467 cout << " * ";
468 Fq.print_object(elts[j], cout);
469 cout << " = ";
470 Fq.mult(elts[i], elts[j], c, verbose_level);
471 Fq.print_object(c, cout); cout << endl;
472
473 FX.mult(elts[i], elts[j], a, verbose_level);
474 FX.print_object(a, cout); cout << endl;
475 }
476 }
477
478}
479
481{
483 int q = 4, p = 2, i;
484 int verbose_level = 0;
485
486 Fq.finite_field_init(q, FALSE /* f_without_tables */, verbose_level);
488
490
491 FX.create_object_by_rank(a, 0, __FILE__, __LINE__, 0);
492 for (i = 1; i < q; i++) {
493 FX.minimum_polynomial(a, i, p, TRUE);
494 //cout << "minpoly_" << i << " = ";
495 //FX.print_object(a, cout); cout << endl;
496 }
497
498}
499
501{
502 int i, j;
503
504 for (i = 0; i < n; i++) {
505 for (j = 0; j < n; j++) {
506 if (i == j) {
507 continue;
508 }
509 else {
510 if (A[i * n + j]) {
511 return FALSE;
512 }
513 }
514 }
515 }
516 return TRUE;
517}
518
519
520
521
523{
525 int x[] = {15, 14, 12, 8};
527 int verbose_level = 0;
528
529 D.multiply_up(a, x, 4, verbose_level);
530 cout << "a=" << a << endl;
531 b.create(2, __FILE__, __LINE__);
532 while (!a.is_zero()) {
533 D.integral_division(a, b, q, r, verbose_level);
534 //cout << a << " = " << q << " * " << b << " + " << r << endl;
535 cout << r << endl;
536 q.assign_to(a);
537 }
538
539 D.multiply_up(a, x, 4, verbose_level);
540 cout << "a=" << a << endl;
541
542 int *rep, len;
543 D.base_b_representation(a, 2, rep, len);
545 cout << "b=" << b << endl;
546 FREE_int(rep);
547}
548
550{
553 int r;
554 int verbose_level = 0;
555
556 a.create_from_base_10_string("562949953421311", verbose_level);
557 D.integral_division_by_int(a, 127, b, r);
558 cout << a << " = " << b << " * 127 + " << r << endl;
559 c.create_from_base_10_string("270549121", verbose_level);
560 D.integral_division(b, c, d, e, verbose_level);
561 cout << b << " = " << d << " * " << c << " + " << e << endl;
562}
563
565{
566 int i, j;
569
570 for (i = 0; i < 10; i++) {
571 for (j = 0; j < 10; j++) {
572 D.binomial(a, i, j, FALSE);
573 a.print(cout);
574 cout << " ";
575 }
576 cout << endl;
577 }
578}
579
581{
582 int n = 6, q = 2, k, x, d = 3;
585
586 for (k = 0; k <= n; k++) {
587 for (x = 0; x <= n; x++) {
588 if (x > 0 && x < d) {
589 continue;
590 }
591 if (q == 2 && EVEN(d) && ODD(x)) {
592 continue;
593 }
594 D.krawtchouk(a, n, q, k, x);
595 a.print(cout);
596 cout << " ";
597 }
598 cout << endl;
599 }
600}
601
603{
606 int verbose_level = 2;
607
608 a.create(9548, __FILE__, __LINE__);
609 b.create(254774, __FILE__, __LINE__);
610 D.extended_gcd(a, b, g, u, v, verbose_level);
611
612 g.print(cout);
613 cout << " = ";
614 u.print(cout);
615 cout << " * ";
616 a.print(cout);
617 cout << " + ";
618 v.print(cout);
619 cout << " * ";
620 b.print(cout);
621 cout << endl;
622
623}
624
626{
627 int verbose_level = 2;
630
631 a.create(7411, __FILE__, __LINE__);
632 b.create(9283, __FILE__, __LINE__);
633 D.jacobi(a, b, verbose_level);
634
635
636}
637
639{
642 int i, j;
643 int mult[15];
644
645 a.create(15, __FILE__, __LINE__);
646 for (i = 0; i < 15; i++) {
647 mult[i] = 0;
648 }
649 for (i = 0; i < 10000; i++) {
651 j = b.as_int();
652 mult[j]++;
653 //cout << b << endl;
654 }
655 for (i = 0; i < 15; i++) {
656 cout << i << " : " << mult[i] << endl;
657 }
658
659}
660
662{
663 int verbose_level = 2;
666 int nb_solovay_strassen_tests = 100;
667 int f_miller_rabin_test = TRUE;
668
669 one.create(1, __FILE__, __LINE__);
670 a.create(197659, __FILE__, __LINE__);
671 Crypto.find_probable_prime_above(a, nb_solovay_strassen_tests,
672 f_miller_rabin_test, verbose_level);
673}
674
676 ring_theory::longinteger_object *&agos, int *&multiplicities)
677{
678 nb_agos = 0;
679 agos = NULL;
680 multiplicities = NULL;
681}
682
684 ring_theory::longinteger_object *&agos, int *&multiplicities)
685{
686 if (nb_agos) {
687 FREE_OBJECTS(agos);
688 FREE_int(multiplicities);
689 }
690}
691
693 ring_theory::longinteger_object *&agos, int *&multiplicities,
695{
696 int j, c, h, f_added;
698 int *tmp_multiplicities;
700
701 f_added = FALSE;
702 for (j = 0; j < nb_agos; j++) {
703 c = D.compare_unsigned(ago, agos[j]);
704 //cout << "comparing " << ago << " with "
705 //<< agos[j] << " yields " << c << endl;
706 if (c >= 0) {
707 if (c == 0) {
708 multiplicities[j]++;
709 }
710 else {
711 tmp_agos = agos;
712 tmp_multiplicities = multiplicities;
713 agos = NEW_OBJECTS(ring_theory::longinteger_object, nb_agos + 1);
714 multiplicities = NEW_int(nb_agos + 1);
715 for (h = 0; h < j; h++) {
716 tmp_agos[h].swap_with(agos[h]);
717 multiplicities[h] = tmp_multiplicities[h];
718 }
719 ago.swap_with(agos[j]);
720 multiplicities[j] = 1;
721 for (h = j; h < nb_agos; h++) {
722 tmp_agos[h].swap_with(agos[h + 1]);
723 multiplicities[h + 1] = tmp_multiplicities[h];
724 }
725 nb_agos++;
726 if (tmp_agos) {
727 FREE_OBJECTS(tmp_agos);
728 FREE_int(tmp_multiplicities);
729 }
730 }
731 f_added = TRUE;
732 break;
733 }
734 }
735 if (!f_added) {
736 // add at the end (including the case that the list is empty)
737 tmp_agos = agos;
738 tmp_multiplicities = multiplicities;
739 agos = NEW_OBJECTS(ring_theory::longinteger_object, nb_agos + 1);
740 multiplicities = NEW_int(nb_agos + 1);
741 for (h = 0; h < nb_agos; h++) {
742 tmp_agos[h].swap_with(agos[h]);
743 multiplicities[h] = tmp_multiplicities[h];
744 }
745 ago.swap_with(agos[nb_agos]);
746 multiplicities[nb_agos] = 1;
747 nb_agos++;
748 if (tmp_agos) {
749 FREE_OBJECTS(tmp_agos);
750 FREE_int(tmp_multiplicities);
751 }
752 }
753}
754
756 int &nb_agos, ring_theory::longinteger_object *&agos, int *&multiplicities)
757{
758 int j;
759
760 ost << "(";
761 for (j = 0; j < nb_agos; j++) {
762 ost << agos[j];
763 if (multiplicities[j] == 1) {
764 }
765 else if (multiplicities[j] >= 10) {
766 ost << "^{" << multiplicities[j] << "}";
767 }
768 else {
769 ost << "^" << multiplicities[j];
770 }
771 if (j < nb_agos - 1) {
772 ost << ", ";
773 }
774 }
775 ost << ")" << endl;
776}
777
778
780{
781 int f_v = (verbose_level >= 1);
782 int i, j, h, a, b, ap, bp, g;
785
786 if (f_v) {
787 cout << "algebra_global::do_equivalence_class_of_fractions" << endl;
788 }
789
790 int *Pairs;
791 int *Table;
792 int length;
793
794 Table = NEW_int(N * N);
795 Pairs = NEW_int(N * N);
796 length = 0;
797
798 for (i = 0; i < N; i++) {
799 a = i + 1;
800 for (j = 0; j < N; j++) {
801 b = j + 1;
802 g = NT.gcd_lint(a, b);
803 ap = a / g;
804 bp = b / g;
805 for (h = 0; h < length; h++) {
806 if (Pairs[h * 2 + 0] == ap && Pairs[h * 2 + 1] == bp) {
807 Table[i * N + j] = h;
808 break;
809 }
810 }
811 if (h == length) {
812 Pairs[h * 2 + 0] = ap;
813 Pairs[h * 2 + 1] = bp;
814 Table[i * N + j] = h;
815 length++;
816 }
817 }
818 }
819
820 char str[1000];
821 string fname;
822
823 sprintf(str, "table_fractions_N%d.csv", N);
824 fname.assign(str);
825 Fio.int_matrix_write_csv(fname, Table, N, N);
826 cout << "Written file " << fname << " of size " << Fio.file_size(fname) << endl;
827
828 FREE_int(Table);
829 FREE_int(Pairs);
830
831 if (f_v) {
832 cout << "algebra_global::do_equivalence_class_of_fractions done" << endl;
833 }
834}
835
836
837
838
839
840void algebra_global::order_of_q_mod_n(int q, int n_min, int n_max, int verbose_level)
841{
842 int f_v = (verbose_level >= 1);
843
844 if (f_v) {
845 cout << "algebra_global::order_of_q_mod_n" << endl;
846 }
847 {
848 char str[1000];
849 string fname;
850
851 snprintf(str, 1000, "order_of_q_mod_n_q%d_%d_%d.csv", q, n_min, n_max);
852 fname.assign(str);
853
854
855 {
856 ofstream ost(fname);
858
859 if (f_v) {
860 cout << "algebra_global::order_of_q_mod_n writing csv file" << endl;
861 }
862 //report(ost, verbose_level);
863
864 int n, row;
865 long int o;
866
867 row = 0;
868
869 ost << "ROW,N,ORD,PHI,COF" << endl;
870 for (n = n_min; n <= n_max; n++) {
871
872 int g, phi, cof;
873
874 g = NT.gcd_lint(q, n);
875 if (g > 1) {
876 continue;
877 }
878
879 ost << row << "," << n;
880 cout << "computing n=" << n << " q=" << q << endl;
881
882 o = NT.order_mod_p(q, n);
883 phi = NT.euler_function(n);
884 cof = phi / o;
885
886 ost << "," << o;
887 ost << "," << phi;
888 ost << "," << cof;
889 ost << endl;
890 row++;
891 }
892 ost << "END" << endl;
893
894 if (f_v) {
895 cout << "algebra_global::order_of_q_mod_n writing csv file" << endl;
896 }
897
898
899 }
901
902 cout << "algebra_global::order_of_q_mod_n written file " << fname << " of size "
903 << Fio.file_size(fname) << endl;
904 }
905
906
907
908
909 if (f_v) {
910 cout << "algebra_global::order_of_q_mod_n done" << endl;
911 }
912}
913
914
915void algebra_global::power_function_mod_n(int k, int n, int verbose_level)
916{
917 int f_v = (verbose_level >= 1);
918
919 if (f_v) {
920 cout << "algebra_global::power_function_mod_n" << endl;
921 }
922 {
923 char str[1000];
924 string fname;
925
926 snprintf(str, 1000, "power_function_k%d_n%d.csv", k, n);
927 fname.assign(str);
928
929
930 {
931 ofstream ost(fname);
933
934 if (f_v) {
935 cout << "algebra_global::power_function_mod_n computing powers" << endl;
936 }
937 //report(ost, verbose_level);
938
939 int row;
940 long int a;
941 long int b;
942
943 row = 0;
944
945 ost << "ROW,A,APOWK" << endl;
946 for (a = 0; a < n; a++) {
947
948 b = NT.power_mod(a, k, n);
949
950 ost << row;
951 ost << "," << a;
952 ost << "," << b;
953 ost << endl;
954 row++;
955 }
956 ost << "END" << endl;
957
958 if (f_v) {
959 cout << "algebra_global::power_function_mod_n writing csv file" << endl;
960 }
961
962
963 }
965
966 cout << "algebra_global::power_function_mod_n written file " << fname << " of size "
967 << Fio.file_size(fname) << endl;
968 }
969
970
971
972
973 if (f_v) {
974 cout << "algebra_global::power_mod_interval_n done" << endl;
975 }
976}
977
979{
980 int f_v = (verbose_level >= 1);
981 int s, t;
982 int *T = NULL;
983 int *T0 = NULL;
984 int *T1 = NULL;
985 int nb_T0 = 0;
986 int nb_T1 = 0;
987
988
989 if (f_v) {
990 cout << "algebra_global::do_trace" << endl;
991 }
992
993
994 T = NEW_int(F->q);
995 T0 = NEW_int(F->q);
996 T1 = NEW_int(F->q);
997
998 for (s = 0; s < F->q; s++) {
999
1000#if 0
1001 int s2, /*s3,*/ s4, s8, s2p1, s2p1t7, s2p1t6, s2p1t4, f;
1002
1003 s2 = F->mult(s, s);
1004 s2p1 = F->add(s2, 1);
1005 s2p1t7 = F->power(s2p1, 7);
1006 s2p1t6 = F->power(s2p1, 6);
1007 s2p1t4 = F->power(s2p1, 4);
1008 //s3 = F->power(s, 3);
1009 s4 = F->power(s, 4);
1010 s8 = F->power(s, 8);
1011
1012 f = F->add4(F->mult(s, s2p1t7), F->mult(s2, s2p1t6), F->mult(s4, s2p1t4), s8);
1013
1014 //f = F->mult(top, F->inverse(bot));
1015 t = F->absolute_trace(f);
1016#endif
1017
1018 t = F->absolute_trace(s);
1019 T[s] = t;
1020 if (t == 1) {
1021 T1[nb_T1++] = s;
1022 }
1023 else {
1024 T0[nb_T0++] = s;
1025 }
1026 }
1027
1028
1029
1030 cout << "Trace 0:" << endl;
1031 Int_vec_print_fully(cout, T0, nb_T0);
1032 cout << endl;
1033
1034 cout << "Trace 1:" << endl;
1035 Int_vec_print_fully(cout, T1, nb_T1);
1036 cout << endl;
1037
1038 char str[1000];
1039 string fname_csv;
1041
1042 snprintf(str, 1000, "F_q%d_trace.csv", F->q);
1043 fname_csv.assign(str);
1044 Fio.int_matrix_write_csv(fname_csv, T, 1, F->q);
1045 cout << "written file " << fname_csv << " of size "
1046 << Fio.file_size(fname_csv) << endl;
1047
1048
1049 snprintf(str, 1000, "F_q%d_trace_0.csv", F->q);
1050 fname_csv.assign(str);
1051 Fio.int_vec_write_csv(T0, nb_T0,
1052 fname_csv, "Trace_0");
1053 cout << "written file " << fname_csv << " of size "
1054 << Fio.file_size(fname_csv) << endl;
1055
1056 snprintf(str, 1000, "F_q%d_trace_1.csv", F->q);
1057 fname_csv.assign(str);
1058 Fio.int_vec_write_csv(T1, nb_T1,
1059 fname_csv, "Trace_1");
1060 cout << "written file " << fname_csv << " of size "
1061 << Fio.file_size(fname_csv) << endl;
1062
1063 FREE_int(T);
1064 FREE_int(T0);
1065 FREE_int(T1);
1066
1067 if (f_v) {
1068 cout << "algebra_global::do_trace done" << endl;
1069 }
1070}
1071
1073{
1074 int f_v = (verbose_level >= 1);
1075 int s, t;
1076 int *T0 = NULL;
1077 int *T1 = NULL;
1078 int nb_T0 = 0;
1079 int nb_T1 = 0;
1080
1081 if (f_v) {
1082 cout << "algebra_global::do_norm" << endl;
1083 }
1084
1085 T0 = NEW_int(F->q);
1086 T1 = NEW_int(F->q);
1087
1088 for (s = 0; s < F->q; s++) {
1089 t = F->absolute_norm(s);
1090 if (t == 1) {
1091 T1[nb_T1++] = s;
1092 }
1093 else {
1094 T0[nb_T0++] = s;
1095 }
1096 }
1097
1098 cout << "Norm 0:" << endl;
1099 Int_vec_print_fully(cout, T0, nb_T0);
1100 cout << endl;
1101
1102 cout << "Norm 1:" << endl;
1103 Int_vec_print_fully(cout, T1, nb_T1);
1104 cout << endl;
1105
1106
1107 char str[1000];
1108 string fname_csv;
1110
1111 snprintf(str, 1000, "F_q%d_norm_0.csv", F->q);
1112 fname_csv.assign(str);
1113 Fio.int_vec_write_csv(T0, nb_T0,
1114 fname_csv, "Norm_0");
1115 cout << "written file " << fname_csv << " of size " << Fio.file_size(fname_csv) << endl;
1116
1117 snprintf(str, 1000, "F_q%d_norm_1.csv", F->q);
1118 fname_csv.assign(str);
1119 Fio.int_vec_write_csv(T1, nb_T1,
1120 fname_csv, "Norm_1");
1121 cout << "written file " << fname_csv << " of size " << Fio.file_size(fname_csv) << endl;
1122
1123
1124 if (f_v) {
1125 cout << "algebra_global::do_norm done" << endl;
1126 }
1127}
1128
1130{
1131 int f_v = (verbose_level >= 1);
1132
1133 if (f_v) {
1134 cout << "algebra_global::do_cheat_sheet_GF q=" << F->q << endl;
1135 }
1136
1137 char fname[1000];
1138 char title[1000];
1139 char author[1000];
1140
1141 snprintf(fname, 1000, "%s.tex", F->label.c_str());
1142 snprintf(title, 1000, "Cheat Sheet $%s$", F->label_tex.c_str());
1143 //sprintf(author, "");
1144 author[0] = 0;
1145
1146
1147
1148 F->addition_table_save_csv(verbose_level);
1149
1150 F->multiplication_table_save_csv(verbose_level);
1151
1152 F->addition_table_reordered_save_csv(verbose_level);
1153
1155
1156
1157 {
1158 ofstream ost(fname);
1159
1160
1162
1163
1164 L.head(ost, FALSE /* f_book*/, TRUE /* f_title */,
1165 title, author, FALSE /* f_toc */, FALSE /* f_landscape */,
1166 TRUE /* f_12pt */,
1167 TRUE /* f_enlarged_page */,
1168 TRUE /* f_pagenumbers */,
1169 NULL /* extra_praeamble */);
1170
1171
1172 F->cheat_sheet(ost, verbose_level);
1173
1174 F->cheat_sheet_main_table(ost, verbose_level);
1175
1176 F->cheat_sheet_addition_table(ost, verbose_level);
1177
1178 F->cheat_sheet_multiplication_table(ost, verbose_level);
1179
1180 F->cheat_sheet_power_table(ost, TRUE, verbose_level);
1181
1182 F->cheat_sheet_power_table(ost, FALSE, verbose_level);
1183
1184
1185
1186
1187
1188 L.foot(ost);
1189 }
1190
1192
1193 cout << "written file " << fname << " of size " << Fio.file_size(fname) << endl;
1194
1195
1196 if (f_v) {
1197 cout << "algebra_global::do_cheat_sheet_GF q=" << F->q << " done" << endl;
1198 }
1199}
1200
1201
1202
1203
1204
1205
1207{
1208 int f_v = (verbose_level >= 1);
1209 int *M;
1210 int *M2;
1212
1213 if (f_v) {
1214 cout << "algebra_global::gl_random_matrix" << endl;
1215 }
1216 //F.finite_field_init(q, 0 /*verbose_level*/);
1217 M = NEW_int(k * k);
1218 M2 = NEW_int(k * k);
1219
1220 F->Linear_algebra->random_invertible_matrix(M, k, verbose_level - 2);
1221
1222 cout << "Random invertible matrix:" << endl;
1224
1225
1226 {
1228
1229
1230
1231 U.create_object_by_rank(char_poly, 0, __FILE__, __LINE__, verbose_level);
1232
1233 U.characteristic_polynomial(M, k, char_poly, verbose_level - 2);
1234
1235 cout << "The characteristic polynomial is ";
1236 U.print_object(char_poly, cout);
1237 cout << endl;
1238
1239 U.substitute_matrix_in_polynomial(char_poly, M, M2, k, verbose_level);
1240 cout << "After substitution, the matrix is " << endl;
1242
1243 U.delete_object(char_poly);
1244
1245 }
1246 FREE_int(M);
1247 FREE_int(M2);
1248
1249}
1250
1251
1252
1253
1255 std::string &fname_csv_in, int n, int verbose_level)
1256{
1257 int f_v = (verbose_level >= 1);
1258
1259 if (f_v) {
1260 cout << "algebra_global::apply_Walsh_Hadamard_transform" << endl;
1261 }
1262
1263
1265
1267
1268 BF->init(n, verbose_level);
1269
1270
1272 int *M;
1273 int m, nb_cols;
1274 int len;
1275 string fname_csv_out;
1277
1278 fname_csv_out.assign(fname_csv_in);
1279 ST.chop_off_extension(fname_csv_out);
1280 fname_csv_out.append("_transformed.csv");
1281
1282 Fio.int_matrix_read_csv(fname_csv_in, M, m, nb_cols, verbose_level);
1283 len = m * nb_cols;
1284 if (len != BF->Q) {
1285 cout << "algebra_global::apply_Walsh_Hadamard_transform len != BF->Q" << endl;
1286 exit(1);
1287 }
1288 BF->raise(M, BF->F);
1289
1290 BF->apply_Walsh_transform(BF->F, BF->T);
1291
1292 cout << " : ";
1293 Int_vec_print(cout, BF->T, BF->Q);
1294 cout << endl;
1295
1296 if (EVEN(n)) {
1297 if (BF->is_bent(BF->T)) {
1298 cout << "is bent" << endl;
1299 }
1300 else {
1301 cout << "is not bent" << endl;
1302 }
1303 }
1304 else {
1305 if (BF->is_near_bent(BF->T)) {
1306 cout << "is near bent" << endl;
1307 }
1308 else {
1309 cout << "is not near bent" << endl;
1310 }
1311
1312 }
1313 Fio.int_matrix_write_csv(fname_csv_out, BF->T, m, nb_cols);
1314 cout << "written file " << fname_csv_out << " of size "
1315 << Fio.file_size(fname_csv_out) << endl;
1316
1317 FREE_int(M);
1318 FREE_OBJECT(BF);
1319
1320 if (f_v) {
1321 cout << "algebra_global::apply_Walsh_Hadamard_transform done" << endl;
1322 }
1323}
1324
1326 std::string &fname_csv_in, int n, int verbose_level)
1327{
1328 int f_v = (verbose_level >= 1);
1329
1330 if (f_v) {
1331 cout << "algebra_global::algebraic_normal_form" << endl;
1332 }
1333
1334
1336
1338
1339 if (f_v) {
1340 cout << "algebra_global::algebraic_normal_form before BF->init" << endl;
1341 }
1342 BF->init(n, verbose_level);
1343 if (f_v) {
1344 cout << "algebra_global::algebraic_normal_form after BF->init" << endl;
1345 }
1346
1347
1349 int *M;
1350 int m, nb_cols;
1351 int len;
1352 string fname_csv_out;
1354
1355 fname_csv_out.assign(fname_csv_in);
1356 ST.chop_off_extension(fname_csv_out);
1357 fname_csv_out.append("_alg_normal_form.csv");
1358
1359 Fio.int_matrix_read_csv(fname_csv_in, M, m, nb_cols, verbose_level);
1360 len = m * nb_cols;
1361 if (len != BF->Q) {
1362 cout << "algebra_global::algebraic_normal_form len != BF->Q" << endl;
1363 exit(1);
1364 }
1365
1366 int *coeff;
1367 int nb_coeff;
1368
1369 nb_coeff = BF->Poly[n].get_nb_monomials();
1370
1371 coeff = NEW_int(nb_coeff);
1372
1373 if (f_v) {
1374 cout << "algebra_global::algebraic_normal_form before BF->compute_polynomial_representation" << endl;
1375 }
1376 BF->compute_polynomial_representation(M, coeff, verbose_level);
1377 if (f_v) {
1378 cout << "algebra_global::algebraic_normal_form after BF->compute_polynomial_representation" << endl;
1379 }
1380
1381 cout << "algebraic normal form:" << endl;
1382 BF->Poly[n].print_equation(cout, coeff);
1383 cout << endl;
1384
1385 cout << "algebraic normal form in tex:" << endl;
1386 BF->Poly[n].print_equation_tex(cout, coeff);
1387 cout << endl;
1388
1389 cout << "algebraic normal form in numerical form:" << endl;
1390 BF->Poly[n].print_equation_numerical(cout, coeff);
1391 cout << endl;
1392
1393
1394
1395 Fio.int_matrix_write_csv(fname_csv_out, coeff, 1, nb_coeff);
1396 cout << "written file " << fname_csv_out << " of size "
1397 << Fio.file_size(fname_csv_out) << endl;
1398
1399 FREE_int(M);
1400 FREE_OBJECT(BF);
1401
1402 if (f_v) {
1403 cout << "algebra_global::algebraic_normal_form done" << endl;
1404 }
1405}
1406
1408 std::string &fname_csv_in, int verbose_level)
1409{
1410 int f_v = (verbose_level >= 1);
1411
1412 if (f_v) {
1413 cout << "algebra_global::apply_trace_function" << endl;
1414 }
1415
1416
1418 int *M;
1419 int m, nb_cols;
1420 int len, i;
1421 string fname_csv_out;
1423
1424 fname_csv_out.assign(fname_csv_in);
1425 ST.chop_off_extension(fname_csv_out);
1426 fname_csv_out.append("_trace.csv");
1427
1428 Fio.int_matrix_read_csv(fname_csv_in, M, m, nb_cols, verbose_level);
1429 len = m * nb_cols;
1430 for (i = 0; i < len; i++) {
1431 M[i] = F->absolute_trace(M[i]);
1432 }
1433 Fio.int_matrix_write_csv(fname_csv_out, M, m, nb_cols);
1434
1435 FREE_int(M);
1436
1437 if (f_v) {
1438 cout << "algebra_global::apply_trace_function done" << endl;
1439 }
1440}
1441
1443 std::string &fname_csv_in, long int d, int verbose_level)
1444{
1445 int f_v = (verbose_level >= 1);
1446
1447 if (f_v) {
1448 cout << "algebra_global::apply_power_function" << endl;
1449 }
1450
1451
1453 int *M;
1454 int m, nb_cols;
1455 int len, i;
1456 string fname_csv_out;
1458
1459 fname_csv_out.assign(fname_csv_in);
1460 ST.chop_off_extension(fname_csv_out);
1461
1462 char str[1000];
1463
1464 sprintf(str, "_power_%ld.csv", d);
1465 fname_csv_out.append(str);
1466
1467 Fio.int_matrix_read_csv(fname_csv_in, M, m, nb_cols, verbose_level);
1468 len = m * nb_cols;
1469 for (i = 0; i < len; i++) {
1470 M[i] = F->power(M[i], d);
1471 }
1472 Fio.int_matrix_write_csv(fname_csv_out, M, m, nb_cols);
1473 cout << "written file " << fname_csv_out << " of size "
1474 << Fio.file_size(fname_csv_out) << endl;
1475
1476 FREE_int(M);
1477
1478 if (f_v) {
1479 cout << "algebra_global::apply_power_function done" << endl;
1480 }
1481}
1482
1484 std::string &fname_csv_out, int verbose_level)
1485{
1486 int f_v = (verbose_level >= 1);
1487
1488 if (f_v) {
1489 cout << "algebra_global::identity_function" << endl;
1490 }
1491
1492
1494 int *M;
1495 int i;
1496
1497 M = NEW_int(F->q);
1498 for (i = 0; i < F->q; i++) {
1499 M[i] = i;
1500 }
1501 Fio.int_matrix_write_csv(fname_csv_out, M, 1, F->q);
1502 cout << "written file " << fname_csv_out << " of size "
1503 << Fio.file_size(fname_csv_out) << endl;
1504
1505 FREE_int(M);
1506
1507 if (f_v) {
1508 cout << "algebra_global::identity_function done" << endl;
1509 }
1510}
1511
1512
1513void algebra_global::Walsh_matrix(field_theory::finite_field *F, int n, int *&W, int verbose_level)
1514{
1515 int f_v = (verbose_level >= 1);
1516 int Q;
1517 int *v;
1518 int *w;
1519 int *W01;
1520 int i, j, a;
1522
1523 if (f_v) {
1524 cout << "algebra_global::Walsh_matrix" << endl;
1525 }
1526 v = NEW_int(n);
1527 w = NEW_int(n);
1528 Q = 1 << n;
1529 W = NEW_int(Q * Q);
1530 W01 = NEW_int(Q * Q);
1531 for (i = 0; i < Q; i++) {
1532 Gg.AG_element_unrank(2, v, 1, n, i);
1533 for (j = 0; j < Q; j++) {
1534 Gg.AG_element_unrank(2, w, 1, n, j);
1535 a = F->Linear_algebra->dot_product(n, v, w);
1536 if (a) {
1537 W[i * Q + j] = -1;
1538 W01[i * Q + j] = 1;
1539 }
1540 else {
1541 W[i * Q + j] = 1;
1542 W01[i * Q + j] = 0;
1543 }
1544 }
1545 }
1546 char str[1000];
1547 string fname_csv;
1549
1550 snprintf(str, 1000, "Walsh_pm_%d.csv", n);
1551 fname_csv.assign(str);
1552 Fio.int_matrix_write_csv(fname_csv, W, Q, Q);
1553 cout << "written file " << fname_csv << " of size "
1554 << Fio.file_size(fname_csv) << endl;
1555
1556
1557 snprintf(str, 1000, "Walsh_01_%d.csv", n);
1558 fname_csv.assign(str);
1559 Fio.int_matrix_write_csv(fname_csv, W01, Q, Q);
1560 cout << "written file " << fname_csv << " of size "
1561 << Fio.file_size(fname_csv) << endl;
1562
1563
1564 FREE_int(v);
1565 FREE_int(w);
1566 FREE_int(W01);
1567 if (f_v) {
1568 cout << "algebra_global::Walsh_matrix done" << endl;
1569 }
1570}
1571
1572void algebra_global::Vandermonde_matrix(field_theory::finite_field *F, int *&W, int *&W_inv, int verbose_level)
1573{
1574 int f_v = (verbose_level >= 1);
1575 int q;
1576 int i, j, a;
1578
1579 if (f_v) {
1580 cout << "algebra_global::Vandermonde_matrix" << endl;
1581 }
1582 q = F->q;
1583 W = NEW_int(q * q);
1584 W_inv = NEW_int(q * q);
1585 for (i = 0; i < q; i++) {
1586 a = 1;
1587 W[i * q + 0] = 1;
1588 for (j = 1; j < q; j++) {
1589 a = F->mult(i, a);
1590 W[i * q + j] = a;
1591 }
1592 }
1593
1594 if (f_v) {
1595 cout << "algebra_global::Vandermonde_matrix before invert_matrix" << endl;
1596 }
1597 F->Linear_algebra->invert_matrix(W, W_inv, q, verbose_level);
1598 if (f_v) {
1599 cout << "algebra_global::Vandermonde_matrix after invert_matrix" << endl;
1600 }
1601
1602 char str[1000];
1603 string fname_csv;
1605
1606 snprintf(str, 1000, "Vandermonde_%d.csv", q);
1607 fname_csv.assign(str);
1608 Fio.int_matrix_write_csv(fname_csv, W, q, q);
1609 cout << "written file " << fname_csv << " of size "
1610 << Fio.file_size(fname_csv) << endl;
1611
1612
1613 snprintf(str, 1000, "Vandermonde_inv_%d.csv", q);
1614 fname_csv.assign(str);
1615 Fio.int_matrix_write_csv(fname_csv, W_inv, q, q);
1616 cout << "written file " << fname_csv << " of size "
1617 << Fio.file_size(fname_csv) << endl;
1618
1619
1620 if (f_v) {
1621 cout << "algebra_global::Vandermonde_matrix done" << endl;
1622 }
1623}
1624
1626{
1627 int f_v = (verbose_level >= 1);
1628 int q;
1629 int *f;
1630 int delta_min, nb_times;
1631
1632 if (f_v) {
1633 cout << "algebra_global::search_APN" << endl;
1634 }
1635 q = F->q;
1636 delta_min = INT_MAX;
1637 nb_times = 0;
1638 f = NEW_int(q);
1639
1640 std::vector<std::vector<int> > Solutions;
1641
1643 f,
1644 0 /* depth */,
1645 delta_min, nb_times, Solutions,
1646 verbose_level);
1647 cout << "nb_times = " << nb_times << endl;
1648 FREE_int(f);
1649
1650 string fname;
1651 char str[1000];
1653
1654 sprintf(str, "APN_functions_q%d.csv", F->q);
1655
1656 fname.assign(str);
1657 Fio.vector_matrix_write_csv(fname, Solutions);
1658 cout << "Written file " << fname << " of size " << Fio.file_size(fname) << endl;
1659
1660
1661 if (f_v) {
1662 cout << "algebra_global::search_APN done" << endl;
1663 }
1664}
1665
1667 int *f, int depth, int &delta_min, int &nb_times,
1668 std::vector<std::vector<int> > &Solutions, int verbose_level)
1669{
1670 if (depth == F->q) {
1671 int delta;
1672
1673 delta = non_linearity(F, f, 0 /* verbose_level */);
1674 if (delta < delta_min) {
1675 delta_min = delta;
1676 nb_times = 1;
1677
1678 Solutions.clear();
1679
1680 vector<int> S;
1681 int i;
1682
1683 for (i = 0; i < F->q; i++) {
1684 S.push_back(f[i]);
1685 }
1686 Solutions.push_back(S);
1687
1688 Int_vec_print(cout, f, F->q);
1689 cout << " delta = " << delta << " nb_times=" << nb_times << endl;
1690 }
1691 else if (delta == delta_min) {
1692 nb_times++;
1693 int f_do_it;
1694
1695 if (nb_times > 100) {
1696 if ((nb_times % 1000) == 0) {
1697 f_do_it = TRUE;
1698 }
1699 else {
1700 f_do_it = FALSE;
1701 }
1702 }
1703 else {
1704 f_do_it = TRUE;
1705 }
1706
1707 vector<int> S;
1708 int i;
1709
1710 for (i = 0; i < F->q; i++) {
1711 S.push_back(f[i]);
1712 }
1713 Solutions.push_back(S);
1714
1715 if (f_do_it) {
1716 Int_vec_print(cout, f, F->q);
1717 cout << " delta = " << delta << " nb_times=" << nb_times << endl;
1718 }
1719 }
1720 return;
1721 }
1722
1723 int a;
1724
1725 for (a = 0; a < F->q; a++) {
1726 f[depth]= a;
1728 f, depth + 1, delta_min, nb_times, Solutions, verbose_level);
1729 }
1730}
1731
1733// f[q]
1734{
1735 int f_v = (verbose_level >= 1);
1736 int q;
1737 int a, av, x, b, fx, fxpa, mfx, dy, delta;
1738 int *nb_times_ab;
1739
1740 if (f_v) {
1741 cout << "algebra_global::non_linearity" << endl;
1742 }
1743 q = F->q;
1744 nb_times_ab = NEW_int(q * q);
1745 Int_vec_zero(nb_times_ab, q * q);
1746 for (x = 0; x < q; x++) {
1747 fx = f[x];
1748 mfx = F->negate(fx);
1749 for (a = 1; a < q; a++) {
1750 fxpa = f[F->add(x, a)];
1751 av = F->inverse(a);
1752 dy = F->add(fxpa, mfx);
1753 b = F->mult(dy, av);
1754 nb_times_ab[a * q + b]++;
1755 }
1756 }
1757 delta = 0;
1758 for (a = 1; a < q; a++) {
1759 for (b = 0; b < q; b++) {
1760 delta = MAXIMUM(delta, nb_times_ab[a * q + b]);
1761 }
1762 }
1763 FREE_int(nb_times_ab);
1764 return delta;
1765}
1766
1768 int *At, int *As, int &f_switch, int *B,
1769 int verbose_level)
1770{
1771 int f_v = (verbose_level >= 1);
1772 int f_vv = (verbose_level >= 2);
1773 int a, b, c, d, e, f, g, h;
1774 int ev, fv;
1775 int P[4], Q[4], R[4], S[4];
1776 int Rx, Ry, Sx, Sy;
1777 int /*b11,*/ b12, b13, b14;
1778 int /*b21,*/ b22, b23, b24;
1779 int /*b31,*/ b32, b33, b34;
1780 int /*b41,*/ b42, b43, b44;
1781
1782 if (f_v) {
1783 cout << "algebra_global::O4_isomorphism_4to2" << endl;
1784 }
1785 //b11 = B[0 * 4 + 0];
1786 b12 = B[0 * 4 + 1];
1787 b13 = B[0 * 4 + 2];
1788 b14 = B[0 * 4 + 3];
1789 //b21 = B[1 * 4 + 0];
1790 b22 = B[1 * 4 + 1];
1791 b23 = B[1 * 4 + 2];
1792 b24 = B[1 * 4 + 3];
1793 //b31 = B[2 * 4 + 0];
1794 b32 = B[2 * 4 + 1];
1795 b33 = B[2 * 4 + 2];
1796 b34 = B[2 * 4 + 3];
1797 //b41 = B[3 * 4 + 0];
1798 b42 = B[3 * 4 + 1];
1799 b43 = B[3 * 4 + 2];
1800 b44 = B[3 * 4 + 3];
1801 O4_grid_coordinates_unrank(F, P[0], P[1], P[2], P[3],
1802 0, 0, verbose_level);
1803 if (f_vv) {
1804 cout << "grid point (0,0) = ";
1805 Int_vec_print(cout, P, 4);
1806 cout << endl;
1807 }
1808 O4_grid_coordinates_unrank(F, Q[0], Q[1], Q[2], Q[3],
1809 1, 0, verbose_level);
1810 if (f_vv) {
1811 cout << "grid point (1,0) = ";
1812 Int_vec_print(cout, Q, 4);
1813 cout << endl;
1814 }
1815 F->Linear_algebra->mult_vector_from_the_left(P, B, R, 4, 4);
1816 F->Linear_algebra->mult_vector_from_the_left(Q, B, S, 4, 4);
1817 O4_grid_coordinates_rank(F, R[0], R[1], R[2], R[3],
1818 Rx, Ry, verbose_level);
1819 O4_grid_coordinates_rank(F, S[0], S[1], S[2], S[3],
1820 Sx, Sy, verbose_level);
1821 if (f_vv) {
1822 cout << "Rx=" << Rx << " Ry=" << Ry
1823 << " Sx=" << Sx << " Sy=" << Sy << endl;
1824 }
1825 if (Ry == Sy) {
1826 f_switch = FALSE;
1827 }
1828 else {
1829 f_switch = TRUE;
1830 }
1831 if (f_vv) {
1832 cout << "f_switch=" << f_switch << endl;
1833 }
1834 if (f_switch) {
1835 if (b22 == 0 && b24 == 0 && b32 == 0 && b34 == 0) {
1836 a = 0;
1837 b = 1;
1838 f = b12;
1839 h = b14;
1840 e = b42;
1841 g = b44;
1842 if (e == 0) {
1843 fv = F->inverse(f);
1844 c = F->mult(fv, b33);
1845 d = F->negate(F->mult(fv, b13));
1846 }
1847 else {
1848 ev = F->inverse(e);
1849 c = F->negate(F->mult(ev, b23));
1850 d = F->negate(F->mult(ev, b43));
1851 }
1852 }
1853 else {
1854 a = 1;
1855 e = b22;
1856 g = b24;
1857 f = F->negate(b32);
1858 h = F->negate(b34);
1859 if (e == 0) {
1860 fv = F->inverse(f);
1861 b = F->mult(fv, b12);
1862 c = F->mult(fv, b33);
1863 d = F->negate(F->mult(fv, b13));
1864 }
1865 else {
1866 ev = F->inverse(e);
1867 b = F->mult(ev, b42);
1868 c = F->negate(F->mult(ev, b23));
1869 d = F->negate(F->mult(ev, b43));
1870 }
1871 }
1872 }
1873 else {
1874 // no switch
1875 if (b22 == 0 && b24 == 0 && b42 == 0 && b44 == 0) {
1876 a = 0;
1877 b = 1;
1878 f = b12;
1879 h = b14;
1880 e = F->negate(b32);
1881 g = F->negate(b34);
1882 if (e == 0) {
1883 fv = F->inverse(f);
1884 c = F->negate(F->mult(fv, b43));
1885 d = F->negate(F->mult(fv, b13));
1886 }
1887 else {
1888 ev = F->inverse(e);
1889 c = F->negate(F->mult(ev, b23));
1890 d = F->mult(ev, b33);
1891 }
1892 }
1893 else {
1894 a = 1;
1895 e = b22;
1896 g = b24;
1897 f = b42;
1898 h = b44;
1899 if (e == 0) {
1900 fv = F->inverse(f);
1901 b = F->mult(fv, b12);
1902 c = F->negate(F->mult(fv, b43));
1903 d = F->negate(F->mult(fv, b13));
1904 }
1905 else {
1906 ev = F->inverse(e);
1907 b = F->negate(F->mult(ev, b32));
1908 c = F->negate(F->mult(ev, b23));
1909 d = F->mult(ev, b33);
1910 }
1911 }
1912 }
1913 if (f_vv) {
1914 cout << "a=" << a << " b=" << b << " c=" << c << " d=" << d << endl;
1915 cout << "e=" << e << " f=" << f << " g=" << g << " h=" << h << endl;
1916 }
1917 At[0] = d;
1918 At[1] = b;
1919 At[2] = c;
1920 At[3] = a;
1921 As[0] = h;
1922 As[1] = f;
1923 As[2] = g;
1924 As[3] = e;
1925 if (f_v) {
1926 cout << "At:" << endl;
1927 Int_vec_print_integer_matrix_width(cout, At, 2, 2, 2, F->log10_of_q);
1928 cout << "As:" << endl;
1929 Int_vec_print_integer_matrix_width(cout, As, 2, 2, 2, F->log10_of_q);
1930 }
1931
1932}
1933
1935 int *At, int *As, int f_switch, int *B)
1936{
1937 int a, b, c, d, e, f, g, h;
1938
1939 a = At[3];
1940 b = At[1];
1941 c = At[2];
1942 d = At[0];
1943 e = As[3];
1944 f = As[1];
1945 g = As[2];
1946 h = As[0];
1947 if (f_switch) {
1948 B[0 * 4 + 0] = F->mult(h, d);
1949 B[0 * 4 + 1] = F->mult(f, b);
1950 B[0 * 4 + 2] = F->negate(F->mult(f, d));
1951 B[0 * 4 + 3] = F->mult(h, b);
1952 B[1 * 4 + 0] = F->mult(g, c);
1953 B[1 * 4 + 1] = F->mult(e, a);
1954 B[1 * 4 + 2] = F->negate(F->mult(e, c));
1955 B[1 * 4 + 3] = F->mult(g, a);
1956 B[2 * 4 + 0] = F->negate(F->mult(h, c));
1957 B[2 * 4 + 1] = F->negate(F->mult(f, a));
1958 B[2 * 4 + 2] = F->mult(f, c);
1959 B[2 * 4 + 3] = F->negate(F->mult(h, a));
1960 B[3 * 4 + 0] = F->mult(g, d);
1961 B[3 * 4 + 1] = F->mult(e, b);
1962 B[3 * 4 + 2] = F->negate(F->mult(e, d));
1963 B[3 * 4 + 3] = F->mult(g, b);
1964 }
1965 else {
1966 B[0 * 4 + 0] = F->mult(h, d);
1967 B[0 * 4 + 1] = F->mult(f, b);
1968 B[0 * 4 + 2] = F->negate(F->mult(f, d));
1969 B[0 * 4 + 3] = F->mult(h, b);
1970 B[1 * 4 + 0] = F->mult(g, c);
1971 B[1 * 4 + 1] = F->mult(e, a);
1972 B[1 * 4 + 2] = F->negate(F->mult(e, c));
1973 B[1 * 4 + 3] = F->mult(g, a);
1974 B[2 * 4 + 0] = F->negate(F->mult(g, d));
1975 B[2 * 4 + 1] = F->negate(F->mult(e, b));
1976 B[2 * 4 + 2] = F->mult(e, d);
1977 B[2 * 4 + 3] = F->negate(F->mult(g, b));
1978 B[3 * 4 + 0] = F->mult(h, c);
1979 B[3 * 4 + 1] = F->mult(f, a);
1980 B[3 * 4 + 2] = F->negate(F->mult(f, c));
1981 B[3 * 4 + 3] = F->mult(h, a);
1982 }
1983}
1984
1986 int x1, int x2, int x3, int x4, int &grid_x, int &grid_y,
1987 int verbose_level)
1988{
1989 int f_v = (verbose_level >= 1);
1990 int a, b, c, d, av, e;
1991 int v[2], w[2];
1992
1993 a = x1;
1994 b = x4;
1995 c = F->negate(x3);
1996 d = x2;
1997
1998 if (a) {
1999 if (a != 1) {
2000 av = F->inverse(a);
2001 b = F->mult(b, av);
2002 c = F->mult(c, av);
2003 d = F->mult(d, av);
2004 }
2005 v[0] = 1;
2006 w[0] = 1;
2007 v[1] = c;
2008 w[1] = b;
2009 e = F->mult(c, b);
2010 if (e != d) {
2011 cout << "algebra_global::O4_grid_coordinates_rank "
2012 "e != d" << endl;
2013 exit(1);
2014 }
2015 }
2016 else if (b == 0) {
2017 v[0] = 0;
2018 v[1] = 1;
2019 w[0] = c;
2020 w[1] = d;
2021 }
2022 else {
2023 if (c) {
2024 cout << "a is zero, b and c are not" << endl;
2025 exit(1);
2026 }
2027 w[0] = 0;
2028 w[1] = 1;
2029 v[0] = b;
2030 v[1] = d;
2031 }
2034 if (f_v) {
2035 Int_vec_print(cout, v, 2);
2036 Int_vec_print(cout, w, 2);
2037 cout << endl;
2038 }
2039
2040 F->PG_element_rank_modified(v, 1, 2, grid_x);
2041 F->PG_element_rank_modified(w, 1, 2, grid_y);
2042}
2043
2045 int &x1, int &x2, int &x3, int &x4,
2046 int grid_x, int grid_y,
2047 int verbose_level)
2048{
2049 int f_v = (verbose_level >= 1);
2050 int a, b, c, d;
2051 int v[2], w[2];
2052
2053 F->PG_element_unrank_modified(v, 1, 2, grid_x);
2054 F->PG_element_unrank_modified(w, 1, 2, grid_y);
2057 if (f_v) {
2058 Int_vec_print(cout, v, 2);
2059 Int_vec_print(cout, w, 2);
2060 cout << endl;
2061 }
2062
2063 a = F->mult(v[0], w[0]);
2064 b = F->mult(v[0], w[1]);
2065 c = F->mult(v[1], w[0]);
2066 d = F->mult(v[1], w[1]);
2067 x1 = a;
2068 x2 = d;
2069 x3 = F->negate(c);
2070 x4 = b;
2071}
2072
2074 int pt_x1, int pt_x2, int pt_x3, int pt_x4,
2075 int *tangent_plane,
2076 int verbose_level)
2077{
2078 int f_v = (verbose_level >= 1);
2079 //int A[4];
2080 int C[3 * 4];
2081 int size, x, y, z, xx, yy, zz, h, k;
2082 int x1, x2, x3, x4;
2083 int y1, y2, y3, y4;
2084 int f_special = FALSE;
2085 int f_complete = FALSE;
2086 int base_cols[4];
2087 int f_P = FALSE;
2088 int rk, det;
2089 int vec2[2];
2090
2091
2092 if (f_v) {
2093 cout << "algebra_global::O4_find_tangent_plane pt_x1=" << pt_x1
2094 << " pt_x2=" << pt_x2
2095 << " pt_x3=" << pt_x3
2096 << " pt_x4=" << pt_x4 << endl;
2097 }
2098 size = F->q + 1;
2099#if 0
2100 A[0] = pt_x1;
2101 A[3] = pt_x2;
2102 A[2] = negate(pt_x3);
2103 A[1] = pt_x4;
2104#endif
2105
2106 int *secants1;
2107 int *secants2;
2108 int nb_secants = 0;
2109 int *complement;
2110 int nb_complement = 0;
2111
2112 secants1 = NEW_int(size * size);
2113 secants2 = NEW_int(size * size);
2114 complement = NEW_int(size * size);
2115 for (x = 0; x < size; x++) {
2116 for (y = 0; y < size; y++) {
2117 z = x * size + y;
2118
2119 //cout << "trying grid point (" << x << "," << y << ")" << endl;
2120 //cout << "nb_secants=" << nb_secants << endl;
2121 O4_grid_coordinates_unrank(F, x1, x2, x3, x4, x, y, 0);
2122
2123 //cout << "x1=" << x1 << " x2=" << x2
2124 //<< " x3=" << x3 << " x4=" << x4 << endl;
2125
2126
2127
2128
2129 for (k = 0; k < size; k++) {
2130 F->PG_element_unrank_modified(vec2, 1, 2, k);
2131 y1 = F->add(F->mult(pt_x1, vec2[0]), F->mult(x1, vec2[1]));
2132 y2 = F->add(F->mult(pt_x2, vec2[0]), F->mult(x2, vec2[1]));
2133 y3 = F->add(F->mult(pt_x3, vec2[0]), F->mult(x3, vec2[1]));
2134 y4 = F->add(F->mult(pt_x4, vec2[0]), F->mult(x4, vec2[1]));
2135 det = F->add(F->mult(y1, y2), F->mult(y3, y4));
2136 if (det != 0) {
2137 continue;
2138 }
2139 O4_grid_coordinates_rank(F, y1, y2, y3, y4, xx, yy, 0);
2140 zz = xx * size + yy;
2141 if (zz == z) {
2142 continue;
2143 }
2144 C[0] = pt_x1;
2145 C[1] = pt_x2;
2146 C[2] = pt_x3;
2147 C[3] = pt_x4;
2148
2149 C[4] = x1;
2150 C[5] = x2;
2151 C[6] = x3;
2152 C[7] = x4;
2153
2154 C[8] = y1;
2155 C[9] = y2;
2156 C[10] = y3;
2157 C[11] = y4;
2158
2159 rk = F->Linear_algebra->Gauss_int(C,
2160 f_special, f_complete, base_cols,
2161 f_P, NULL, 3, 4, 4, 0);
2162 if (rk < 3) {
2163 secants1[nb_secants] = z;
2164 secants2[nb_secants] = zz;
2165 nb_secants++;
2166 }
2167
2168 }
2169
2170#if 0
2171
2172 for (xx = 0; xx < size; xx++) {
2173 for (yy = 0; yy < size; yy++) {
2174 zz = xx * size + yy;
2175 if (zz == z)
2176 continue;
2177 O4_grid_coordinates_unrank(F, y1, y2, y3, y4, xx, yy, 0);
2178 //cout << "y1=" << y1 << " y2=" << y2
2179 //<< " y3=" << y3 << " y4=" << y4 << endl;
2180 C[0] = pt_x1;
2181 C[1] = pt_x2;
2182 C[2] = pt_x3;
2183 C[3] = pt_x4;
2184
2185 C[4] = x1;
2186 C[5] = x2;
2187 C[6] = x3;
2188 C[7] = x4;
2189
2190 C[8] = y1;
2191 C[9] = y2;
2192 C[10] = y3;
2193 C[11] = y4;
2194
2195 rk = F.Gauss_int(C, f_special, f_complete, base_cols,
2196 f_P, NULL, 3, 4, 4, 0);
2197 if (rk < 3) {
2198 secants1[nb_secants] = z;
2199 secants2[nb_secants] = zz;
2200 nb_secants++;
2201 }
2202 }
2203 }
2204#endif
2205
2206
2207 }
2208 }
2209 if (f_v) {
2210 cout << "nb_secants=" << nb_secants << endl;
2211 Int_vec_print(cout, secants1, nb_secants);
2212 cout << endl;
2213 Int_vec_print(cout, secants2, nb_secants);
2214 cout << endl;
2215 }
2216 h = 0;
2217 for (zz = 0; zz < size * size; zz++) {
2218 if (secants1[h] > zz) {
2219 complement[nb_complement++] = zz;
2220 }
2221 else {
2222 h++;
2223 }
2224 }
2225 if (f_v) {
2226 cout << "complement = tangents:" << endl;
2227 Int_vec_print(cout, complement, nb_complement);
2228 cout << endl;
2229 }
2230
2231 int *T;
2232 T = NEW_int(4 * nb_complement);
2233
2234 for (h = 0; h < nb_complement; h++) {
2235 z = complement[h];
2236 x = z / size;
2237 y = z % size;
2238 if (f_v) {
2239 cout << setw(3) << h << " : " << setw(4) << z
2240 << " : " << x << "," << y << " : ";
2241 }
2242 O4_grid_coordinates_unrank(F, y1, y2, y3, y4,
2243 x, y, verbose_level);
2244 if (f_v) {
2245 cout << "y1=" << y1 << " y2=" << y2
2246 << " y3=" << y3 << " y4=" << y4 << endl;
2247 }
2248 T[h * 4 + 0] = y1;
2249 T[h * 4 + 1] = y2;
2250 T[h * 4 + 2] = y3;
2251 T[h * 4 + 3] = y4;
2252 }
2253
2254
2255 rk = F->Linear_algebra->Gauss_int(T, f_special, f_complete, base_cols,
2256 f_P, NULL, nb_complement, 4, 4, 0);
2257 if (f_v) {
2258 cout << "the rank of the tangent space is " << rk << endl;
2259 cout << "basis:" << endl;
2260 Int_vec_print_integer_matrix_width(cout, T, rk, 4, 4, F->log10_of_q);
2261 }
2262
2263 if (rk != 3) {
2264 cout << "rk = " << rk << " not equal to 3" << endl;
2265 exit(1);
2266 }
2267 int i;
2268 for (i = 0; i < 12; i++) {
2269 tangent_plane[i] = T[i];
2270 }
2271 FREE_int(secants1);
2272 FREE_int(secants2);
2273 FREE_int(complement);
2274 FREE_int(T);
2275
2276#if 0
2277 for (h = 0; h < nb_secants; h++) {
2278 z = secants1[h];
2279 zz = secants2[h];
2280 x = z / size;
2281 y = z % size;
2282 xx = zz / size;
2283 yy = zz % size;
2284 cout << "(" << x << "," << y << "),(" << xx
2285 << "," << yy << ")" << endl;
2286 O4_grid_coordinates_unrank(F, x1, x2, x3, x4,
2287 x, y, verbose_level);
2288 cout << "x1=" << x1 << " x2=" << x2
2289 << " x3=" << x3 << " x4=" << x4 << endl;
2290 O4_grid_coordinates_unrank(F, y1, y2, y3, y4, xx, yy, verbose_level);
2291 cout << "y1=" << y1 << " y2=" << y2
2292 << " y3=" << y3 << " y4=" << y4 << endl;
2293 }
2294#endif
2295}
2296
2297
2298
2299
2300
2301}}}
2302
void O4_isomorphism_4to2(field_theory::finite_field *F, int *At, int *As, int &f_switch, int *B, int verbose_level)
void search_APN_recursion(field_theory::finite_field *F, int *f, int depth, int &delta_min, int &nb_times, std::vector< std::vector< int > > &Solutions, int verbose_level)
void O4_grid_coordinates_rank(field_theory::finite_field *F, int x1, int x2, int x3, int x4, int &grid_x, int &grid_y, int verbose_level)
void do_equivalence_class_of_fractions(int N, int verbose_level)
void O4_isomorphism_2to4(field_theory::finite_field *F, int *At, int *As, int f_switch, int *B)
void apply_power_function(field_theory::finite_field *F, std::string &fname_csv_in, long int d, int verbose_level)
void Walsh_matrix(field_theory::finite_field *F, int n, int *&W, int verbose_level)
void longinteger_collect_print(std::ostream &ost, int &nb_agos, ring_theory::longinteger_object *&agos, int *&multiplicities)
void O4_grid_coordinates_unrank(field_theory::finite_field *F, int &x1, int &x2, int &x3, int &x4, int grid_x, int grid_y, int verbose_level)
void do_norm(field_theory::finite_field *F, int verbose_level)
void algebraic_normal_form(field_theory::finite_field *F, std::string &fname_csv_in, int n, int verbose_level)
void longinteger_collect_setup(int &nb_agos, ring_theory::longinteger_object *&agos, int *&multiplicities)
void search_APN(field_theory::finite_field *F, int verbose_level)
void formula_subprimitive(int d, int q, ring_theory::longinteger_object &Rdq, int &g, int verbose_level)
void longinteger_collect_add(int &nb_agos, ring_theory::longinteger_object *&agos, int *&multiplicities, ring_theory::longinteger_object &ago)
void O4_find_tangent_plane(field_theory::finite_field *F, int pt_x1, int pt_x2, int pt_x3, int pt_x4, int *tangent_plane, int verbose_level)
void power_function_mod_n(int k, int n, int verbose_level)
void do_cheat_sheet_GF(field_theory::finite_field *F, int verbose_level)
void apply_trace_function(field_theory::finite_field *F, std::string &fname_csv_in, int verbose_level)
void gl_random_matrix(field_theory::finite_field *F, int k, int verbose_level)
void subexponent(int q, int Q, int h, int f, int j, int k, int &s, int &c)
void apply_Walsh_Hadamard_transform(field_theory::finite_field *F, std::string &fname_csv_in, int n, int verbose_level)
void longinteger_collect_free(int &nb_agos, ring_theory::longinteger_object *&agos, int *&multiplicities)
void Vandermonde_matrix(field_theory::finite_field *F, int *&W, int *&W_inv, int verbose_level)
void formula(int d, int q, ring_theory::longinteger_object &Rdq, int verbose_level)
void do_trace(field_theory::finite_field *F, int verbose_level)
int non_linearity(field_theory::finite_field *F, int *f, int verbose_level)
void order_of_q_mod_n(int q, int n_min, int n_max, int verbose_level)
void identity_function(field_theory::finite_field *F, std::string &fname_csv_out, int verbose_level)
ring_theory::homogeneous_polynomial_domain * Poly
Definition: combinatorics.h:43
void compute_polynomial_representation(int *func, int *coeff, int verbose_level)
void binomial(ring_theory::longinteger_object &a, int n, int k, int verbose_level)
void krawtchouk(ring_theory::longinteger_object &a, int n, int q, int k, int x)
a collection of functions related to cryptography
Definition: cryptography.h:25
void find_probable_prime_above(ring_theory::longinteger_object &a, int nb_solovay_strassen_tests, int f_miller_rabin_test, int verbose_level)
functions related to strings and character arrays
void cheat_sheet_main_table(std::ostream &f, int verbose_level)
void PG_element_rank_modified(int *v, int stride, int len, int &a)
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 cheat_sheet(std::ostream &f, int verbose_level)
void PG_element_unrank_modified(int *v, int stride, int len, int a)
void finite_field_init(int q, int f_without_tables, int verbose_level)
void cheat_sheet_multiplication_table(std::ostream &f, int verbose_level)
various functions related to geometries
Definition: geometry.h:721
void AG_element_unrank(int q, int *v, int stride, int len, long int a)
void mult_vector_from_the_left(int *v, int *A, int *vA, int m, int n)
int Gauss_int(int *A, int f_special, int f_complete, int *base_cols, int f_P, int *P, int m, int n, int Pn, int verbose_level)
void random_invertible_matrix(int *M, int k, int verbose_level)
void invert_matrix(int *A, int *A_inv, int n, int verbose_level)
void print_factorization(int nb_primes, int *primes, int *exponents)
void int_matrix_write_csv(std::string &fname, int *M, int m, int n)
Definition: file_io.cpp:1300
void int_vec_write_csv(int *v, int len, std::string &fname, const char *label)
Definition: file_io.cpp:1175
void int_matrix_read_csv(std::string &fname, int *&M, int &m, int &n, int verbose_level)
Definition: file_io.cpp:1477
void vector_matrix_write_csv(std::string &fname, std::vector< std::vector< int > > &V)
Definition: file_io.cpp:1369
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)
int PHG_element_rank(int *v, int stride, int len)
void PHG_element_unrank(int *v, int stride, int len, int rk)
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)
int jacobi(longinteger_object &a, longinteger_object &m, int verbose_level)
void base_b_representation(longinteger_object &a, int b, int *&rep, int &len)
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 mult(longinteger_object &a, longinteger_object &b, longinteger_object &c)
void random_number_less_than_n(longinteger_object &n, longinteger_object &r)
void integral_division(longinteger_object &a, longinteger_object &b, longinteger_object &q, longinteger_object &r, int verbose_level)
void factor(longinteger_object &a, int &nb_primes, int *&primes, int *&exponents, int verbose_level)
int compare_unsigned(longinteger_object &a, longinteger_object &b)
a class to represent arbitrary precision integers
Definition: ring_theory.h:366
void create_from_base_10_string(const char *str, int verbose_level)
void create(long int i, const char *file, int line)
domain of polynomials in one variable over a finite field
Definition: ring_theory.h:691
void substitute_matrix_in_polynomial(unipoly_object &p, int *Mtx_in, int *Mtx_out, int k, int verbose_level)
void mult(unipoly_object a, unipoly_object b, unipoly_object &c, int verbose_level)
void create_object_by_rank(unipoly_object &p, long int rk, const char *file, int line, int verbose_level)
void characteristic_polynomial(int *Mtx, int k, unipoly_object &char_poly, int verbose_level)
void minimum_polynomial(unipoly_object &a, int alpha, int p, int verbose_level)
void print_object(unipoly_object p, std::ostream &ost)
#define FREE_OBJECTS(p)
Definition: foundations.h:652
#define FREE_int(p)
Definition: foundations.h:640
#define Int_vec_zero(A, B)
Definition: foundations.h:713
#define Int_vec_print_fully(A, B, C)
Definition: foundations.h:687
#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_vec_print_integer_matrix_width(A, B, C, D, E, F)
Definition: foundations.h:691
#define NEW_OBJECTS(type, n)
Definition: foundations.h:639
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define EVEN(x)
Definition: foundations.h:221
#define ODD(x)
Definition: foundations.h:222
#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