Orbiter 2022
Combinatorial Objects
int_vec.cpp
Go to the documentation of this file.
1/*
2 * int_vec.cpp
3 *
4 * Created on: Feb 27, 2021
5 * Author: betten
6 */
7
8
9#include "foundations.h"
10
11
12using namespace std;
13
14
15namespace orbiter {
16namespace layer1_foundations {
17namespace data_structures {
18
19
21{
22
23}
24
26{
27
28}
29
30void int_vec::add(int *v1, int *v2, int *w, int len)
31{
32 int i;
33
34 for (i = 0; i < len; i++) {
35 w[i] = v1[i] + v2[i];
36 }
37}
38
39void int_vec::add3(int *v1, int *v2, int *v3, int *w, int len)
40{
41 int i;
42
43 for (i = 0; i < len; i++) {
44 w[i] = v1[i] + v2[i] + v3[i];
45 }
46}
47
48void int_vec::apply(int *from, int *through, int *to, int len)
49{
50 int i;
51
52 for (i = 0; i < len; i++) {
53 to[i] = through[from[i]];
54 }
55}
56
57void int_vec::apply_lint(int *from, long int *through, long int *to, int len)
58{
59 int i;
60
61 for (i = 0; i < len; i++) {
62 to[i] = through[from[i]];
63 }
64}
65
66
68 int *subset, int sz, int &value)
69{
70 int a, i;
71
72 if (sz == 0) {
73 cout << "int_vec::is_costant_on_subset sz == 0" << endl;
74 exit(1);
75 }
76 a = v[subset[0]];
77 if (sz == 1) {
78 value = a;
79 return TRUE;
80 }
81 for (i = 1; i < sz; i++) {
82 if (v[subset[i]] != a) {
83 return FALSE;
84 }
85 }
86 value = a;
87 return TRUE;
88}
89
90void int_vec::take_away(int *v, int &len,
91 int *take_away, int nb_take_away)
92 // v must be sorted
93{
94 int i, j, idx;
95 sorting Sorting;
96
97 for (i = 0; i < nb_take_away; i++) {
98 if (!Sorting.int_vec_search(v, len, take_away[i], idx)) {
99 continue;
100 }
101 for (j = idx; j < len; j++) {
102 v[j] = v[j + 1];
103 }
104 len--;
105 }
106}
107
109{
110 int i, n;
111
112 n = 0;
113 for (i = 0; i < len; i++) {
114 if (v[i]) {
115 n++;
116 }
117 }
118 return n;
119}
120
122{
123 int i;
124
125 for (i = 0; i < len; i++) {
126 if (v[i]) {
127 return i;
128 }
129 }
130 cout << "int_vec::find_first_nonzero_entry the vector is all zero" << endl;
131 exit(1);
132}
133
134void int_vec::zero(int *v, long int len)
135{
136 int i;
137 int *p;
138
139 for (p = v, i = 0; i < len; p++, i++) {
140 *p = 0;
141 }
142}
143
144int int_vec::is_zero(int *v, long int len)
145{
146 int i;
147
148 for (i = 0; i < len; i++) {
149 if (v[i]) {
150 return FALSE;
151 }
152 }
153 return TRUE;
154}
155
156
157void int_vec::mone(int *v, long int len)
158{
159 int i;
160 int *p;
161
162 for (p = v, i = 0; i < len; p++, i++) {
163 *p = -1;
164 }
165}
166
167void int_vec::copy(int *from, int *to, long int len)
168{
169 int i;
170 int *p, *q;
171
172 for (p = from, q = to, i = 0; i < len; p++, q++, i++) {
173 *q = *p;
174 }
175}
176
177void int_vec::copy_to_lint(int *from, long int *to, long int len)
178{
179 int i;
180 int *p;
181 long int *q;
182
183 for (p = from, q = to, i = 0; i < len; p++, q++, i++) {
184 *q = *p;
185 }
186}
187
188void int_vec::swap(int *v1, int *v2, long int len)
189{
190 int i, a;
191 int *p, *q;
192
193 for (p = v1, q = v2, i = 0; i < len; p++, q++, i++) {
194 a = *q;
195 *q = *p;
196 *p = a;
197 }
198}
199
201 int &len, int a)
202{
203 int idx, i;
204 sorting Sorting;
205
206 if (!Sorting.int_vec_search(v, len, a, idx)) {
207 cout << "int_vec::delete_element_assume_sorted "
208 "cannot find the element" << endl;
209 exit(1);
210 }
211 for (i = idx + 1; i < len; i++) {
212 v[i - 1] = v[i];
213 }
214 len--;
215}
216
217
218
219void int_vec::complement(int *v, int n, int k)
220// computes the complement to v + k (v must be allocated to n elements)
221// the first k elements of v[] must be in increasing order.
222{
223 int *w;
224 int j1, j2, i;
225
226 w = v + k;
227 j1 = 0;
228 j2 = 0;
229 for (i = 0; i < n; i++) {
230 if (j1 < k && v[j1] == i) {
231 j1++;
232 continue;
233 }
234 w[j2] = i;
235 j2++;
236 }
237 if (j2 != n - k) {
238 cout << "int_vec::complement j2 != n - k" << endl;
239 exit(1);
240 }
241}
242
243void int_vec::complement(int *v, int *w, int n, int k)
244// computes the complement of v[k] in the set {0,...,n-1} to w[n - k]
245{
246 int j1, j2, i;
247
248 j1 = 0;
249 j2 = 0;
250 for (i = 0; i < n; i++) {
251 if (j1 < k && v[j1] == i) {
252 j1++;
253 continue;
254 }
255 w[j2] = i;
256 j2++;
257 }
258 if (j2 != n - k) {
259 cout << "int_vec::complement j2 != n - k" << endl;
260 exit(1);
261 }
262}
263
264void int_vec::init5(int *v, int a0, int a1, int a2, int a3, int a4)
265{
266 v[0] = a0;
267 v[1] = a1;
268 v[2] = a2;
269 v[3] = a3;
270 v[4] = a4;
271}
272
273int int_vec::minimum(int *v, int len)
274{
275 int i, m;
276
277 if (len == 0) {
278 cout << "int_vec::minimum len == 0" << endl;
279 exit(1);
280 }
281 m = v[0];
282 for (i = 1; i < len; i++) {
283 if (v[i] < m) {
284 m = v[i];
285 }
286 }
287 return m;
288}
289
290int int_vec::maximum(int *v, int len)
291{
292 int m, i;
293
294 if (len == 0) {
295 cout << "int_vec::maximum len == 0" << endl;
296 exit(1);
297 }
298 m = v[0];
299 for (i = 1; i < len; i++) {
300 if (v[i] > m) {
301 m = v[i];
302 }
303 }
304 return m;
305}
306
307void int_vec::copy(int len, int *from, int *to)
308{
309 int i;
310
311 for (i = 0; i < len; i++) {
312 to[i] = from[i];
313 }
314}
315
316int int_vec::first_difference(int *p, int *q, int len)
317{
318 int i;
319
320 for (i = 0; i < len; i++) {
321 if (p[i] != q[i]) {
322 return i;
323 }
324 }
325 return i;
326}
327
328int int_vec::vec_max_log_of_entries(std::vector<std::vector<int>> &p)
329{
330 int i, j, a, w = 1, w1;
332
333 for (i = 0; i < p.size(); i++) {
334 for (j = 0; j < p[i].size(); j++) {
335 a = p[i][j];
336 if (a > 0) {
337 w1 = NT.int_log10(a);
338 }
339 else if (a < 0) {
340 w1 = NT.int_log10(-a) + 1;
341 }
342 else {
343 w1 = 1;
344 }
345 w = MAXIMUM(w, w1);
346 }
347 }
348 return w;
349}
350
351void int_vec::vec_print(std::vector<std::vector<int>> &p)
352{
353 int w;
354
356 vec_print(p, w);
357}
358
359void int_vec::vec_print(std::vector<std::vector<int>> &p, int w)
360{
361 int i, j;
362
363 for (i = 0; i < p.size(); i++) {
364 for (j = 0; j < p[i].size(); j++) {
365 cout << setw((int) w) << p[i][j];
366 if (w) {
367 cout << " ";
368 }
369 }
370 cout << endl;
371 }
372}
373
375 int *v, int v_len)
376{
377 int *val, *mult, len;
378
379 distribution(v, v_len, val, mult, len);
380 distribution_print(ost, val, mult, len);
381 ost << endl;
382
383 FREE_int(val);
384 FREE_int(mult);
385}
386
388 int len_v, int *&val, int *&mult, int &len)
389{
390 sorting Sorting;
391 int i, j, a, idx;
392
393 val = NEW_int(len_v);
394 mult = NEW_int(len_v);
395 len = 0;
396 for (i = 0; i < len_v; i++) {
397 a = v[i];
398 if (Sorting.int_vec_search(val, len, a, idx)) {
399 mult[idx]++;
400 }
401 else {
402 for (j = len; j > idx; j--) {
403 val[j] = val[j - 1];
404 mult[j] = mult[j - 1];
405 }
406 val[idx] = a;
407 mult[idx] = 1;
408 len++;
409 }
410 }
411}
412
413void int_vec::print(std::ostream &ost, std::vector<int> &v)
414{
415 int i;
416 int len;
417
418 len = v.size();
419 if (len > 50) {
420 ost << "( ";
421 for (i = 0; i < 50; i++) {
422 ost << v[i];
423 if (i < len - 1) {
424 ost << ", ";
425 }
426 }
427 ost << "...";
428 for (i = len - 3; i < len; i++) {
429 ost << v[i];
430 if (i < len - 1) {
431 ost << ", ";
432 }
433 }
434 ost << " )";
435 }
436 else {
437 print_fully(ost, v);
438 }
439}
440
441void int_vec::print(std::ostream &ost, int *v, int len)
442{
443 int i;
444
445 if (len > 50) {
446 ost << "( ";
447 for (i = 0; i < 50; i++) {
448 ost << v[i];
449 if (i < len - 1) {
450 ost << ", ";
451 }
452 }
453 ost << "...";
454 for (i = len - 3; i < len; i++) {
455 ost << v[i];
456 if (i < len - 1) {
457 ost << ", ";
458 }
459 }
460 ost << " )";
461 }
462 else {
463 print_fully(ost, v, len);
464 }
465}
466
467void int_vec::print_str(std::stringstream &ost, int *v, int len)
468{
469 int i;
470
471 ost << "(";
472 for (i = 0; i < len; i++) {
473 ost << v[i];
474 if (i < len - 1) {
475 ost << ", ";
476 }
477 }
478 ost << ")";
479}
480
481void int_vec::print_str_naked(std::stringstream &ost, int *v, int len)
482{
483 int i;
484
485 //ost << "(";
486 for (i = 0; i < len; i++) {
487 ost << v[i];
488 if (i < len - 1) {
489 ost << ",";
490 }
491 }
492 //ost << ")";
493}
494
495
496
497void int_vec::print_as_table(std::ostream &ost, int *v, int len, int width)
498{
499 int i;
500
501 for (i = 0; i < len; i++) {
502 ost << v[i];
503 if (i < len - 1) {
504 ost << ", ";
505 }
506 if (((i + 1) % 10) == 0) {
507 ost << endl;
508 }
509 }
510 ost << endl;
511}
512
513void int_vec::print_fully(std::ostream &ost, std::vector<int> &v)
514{
515 int i;
516 int len;
517
518
519 len = v.size();
520 ost << "( ";
521 for (i = 0; i < len; i++) {
522 ost << v[i];
523 if (i < len - 1) {
524 ost << ", ";
525 }
526 }
527 ost << " )";
528}
529
530void int_vec::print_fully(std::ostream &ost, int *v, int len)
531{
532 int i;
533
534 ost << "( ";
535 for (i = 0; i < len; i++) {
536 ost << v[i];
537 if (i < len - 1) {
538 ost << ", ";
539 }
540 }
541 ost << " )";
542}
543
544void int_vec::print_dense(std::ostream &ost, int *v, int len)
545{
546 int i;
547
548 ost << "(";
549 for (i = 0; i < len; i++) {
550 ost << v[i];
551 }
552 ost << ")";
553}
554
555
556void int_vec::print_Cpp(ostream &ost, int *v, int len)
557{
558 int i;
559
560 ost << "{ " << endl;
561 ost << "\t";
562 for (i = 0; i < len; i++) {
563 ost << v[i];
564 if (i < len - 1) {
565 ost << ", ";
566 }
567 if ((i + 1) % 10 == 0) {
568 ost << endl;
569 ost << "\t";
570 }
571 }
572 ost << " }";
573}
574
575void int_vec::print_GAP(ostream &ost, int *v, int len)
576{
577 int i;
578
579 ost << "[ ";
580 for (i = 0; i < len; i++) {
581 ost << v[i];
582 if (i < len - 1) {
583 ost << ", ";
584 }
585 }
586 ost << " ]";
587}
588
589void int_vec::print_classified(int *v, int len)
590{
591 tally C;
592
593 C.init(v, len, FALSE /*f_second */, 0);
594 C.print(TRUE /* f_backwards*/);
595 cout << endl;
596}
597
598void int_vec::print_classified_str(stringstream &sstr,
599 int *v, int len, int f_backwards)
600{
601 tally C;
602
603 C.init(v, len, FALSE /*f_second */, 0);
604 //C.print(TRUE /* f_backwards*/);
605 C.print_naked_stringstream(sstr, f_backwards);
606}
607
608void int_vec::scan(std::string &s, int *&v, int &len)
609{
610 int verbose_level = 0;
611
612 int f_v = (verbose_level >= 1);
613 if (f_v) {
614 cout << "int_vec::scan: " << s << endl;
615 }
616 istringstream ins(s);
617 scan_from_stream(ins, v, len);
618 if (f_v) {
619 cout << "int_vec::scan done, len = " << len << endl;
620 cout << "v = ";
621 print(cout, v, len);
622 cout << endl;
623 }
624}
625
626
627
628void int_vec::scan(const char *s, int *&v, int &len)
629{
630 int verbose_level = 1;
631
632 int f_v = (verbose_level >= 1);
633 if (f_v) {
634 cout << "int_vec::scan: " << s << endl;
635 }
636 istringstream ins(s);
637 scan_from_stream(ins, v, len);
638 if (f_v) {
639 cout << "int_vec::scan done, len = " << len << endl;
640 }
641}
642
643void int_vec::scan_from_stream(istream & is, int *&v, int &len)
644{
645 int verbose_level = 0;
646 int a;
647 char s[10000], c;
648 int l, h;
649 int f_v = (verbose_level >= 1);
650
651 if (f_v) {
652 cout << "int_vec::scan_from_stream" << endl;
653 }
654 len = 20;
655 v = NEW_int(len);
656 h = 0;
657 l = 0;
658
659 while (TRUE) {
660 if (!is) {
661 len = h;
662 if (f_v) {
663 cout << "int_vec::scan_from_stream done" << endl;
664 }
665 return;
666 }
667 l = 0;
668 if (is.eof()) {
669 if (f_v) {
670 cout << "breaking off because of eof" << endl;
671 }
672 len = h;
673 if (f_v) {
674 cout << "int_vec::scan_from_stream done" << endl;
675 }
676 return;
677 }
678 is >> c;
679 if (f_v) {
680 cout << "c='" << c << "'" << endl;
681 }
682 //c = get_character(is, verbose_level - 2);
683 if (c == 0) {
684 len = h;
685 if (f_v) {
686 cout << "int_vec::scan_from_stream done" << endl;
687 }
688 return;
689 }
690 while (TRUE) {
691 // read digits:
692 //cout << "int_vec_scan_from_stream: \"" << c
693 //<< "\", ascii=" << (int)c << endl;
694 l = 0;
695 while (c != 0) {
696 if (c == ' ') {
697 is >> c;
698 if (f_v) {
699 cout << "int_vec::scan_from_stream skipping space" << endl;
700 }
701 continue;
702 }
703 if (c == '-') {
704 if (f_v) {
705 cout << "c='" << c << "'" << endl;
706 }
707 if (is.eof()) {
708 if (f_v) {
709 cout << "breaking off because of eof" << endl;
710 }
711 break;
712 }
713 s[l++] = c;
714 is >> c;
715 //c = get_character(is, verbose_level - 2);
716 }
717 else if (c >= '0' && c <= '9') {
718 //cout << "c='" << c << "'" << endl;
719 if (is.eof()) {
720 //cout << "breaking off because of eof" << endl;
721 break;
722 }
723 s[l++] = c;
724 is >> c;
725 //c = get_character(is, verbose_level - 2);
726 }
727 else {
728 if (f_v) {
729 cout << "breaking off because c='" << c << "'" << endl;
730 }
731 break;
732 }
733 if (c == 0) {
734 break;
735 }
736 if (f_v) {
737 cout << "int_vec::scan_from_stream inside loop: \""
738 << c << "\", ascii=" << (int)c << endl;
739 }
740 }
741 s[l] = 0;
742 a = atoi(s);
743 if (f_v) {
744 cout << "h=" << h << ", len=" << len << ", digit as string: " << s
745 << ", numeric: " << a << endl;
746 }
747 if (h == len) {
748 len += 20;
749 int *v2;
750
751 if (f_v) {
752 cout << "int_vec::scan_from_stream reallocating to length " << len << endl;
753 }
754
755 v2 = NEW_int(len);
756 copy(v, v2, h);
757 FREE_int(v);
758 v = v2;
759 }
760 v[h++] = a;
761 l = 0;
762 if (!is) {
763 len = h;
764 if (f_v) {
765 cout << "int_vec::scan_from_stream done" << endl;
766 }
767 return;
768 }
769 if (c == 0) {
770 len = h;
771 if (f_v) {
772 cout << "int_vec::scan_from_stream done" << endl;
773 }
774 return;
775 }
776 if (is.eof()) {
777 if (f_v) {
778 cout << "breaking off because of eof" << endl;
779 }
780 len = h;
781 if (f_v) {
782 cout << "int_vec::scan_from_stream done" << endl;
783 }
784 return;
785 }
786 is >> c;
787 //c = get_character(is, verbose_level - 2);
788 if (c == 0) {
789 len = h;
790 if (f_v) {
791 cout << "int_vec::scan_from_stream done" << endl;
792 }
793 return;
794 }
795 }
796 }
797}
798
799void int_vec::print_to_str(char *str, int *data, int len)
800{
801 int i, a;
802
803 str[0] = 0;
804 strcat(str, "\" ");
805 for (i = 0; i < len; i++) {
806 a = data[i];
807 sprintf(str + strlen(str), "%d", a);
808 if (i < len - 1) {
809 strcat(str, ", ");
810 }
811 }
812 strcat(str, "\"");
813}
814
815void int_vec::print_to_str_naked(char *str, int *data, int len)
816{
817 int i, a;
818
819 str[0] = 0;
820 for (i = 0; i < len; i++) {
821 a = data[i];
822 sprintf(str + strlen(str), "%d", a);
823 if (i < len - 1) {
824 strcat(str, ", ");
825 }
826 }
827}
828
829void int_vec::print(int *v, int len)
830{
831 int i;
832
833 for (i = 0; i < len; i++) {
834 cout << i << " : " << v[i] << endl;
835 }
836}
837
838
839void int_vec::print_integer_matrix(std::ostream &ost,
840 int *p, int m, int n)
841{
842 int i, j;
843
844 for (i = 0; i < m; i++) {
845 for (j = 0; j < n; j++) {
846 ost << p[i * n + j] << " ";
847 }
848 ost << endl;
849 }
850}
851
853 int *p, int m, int n, int dim_n, int w)
854{
855 int i, j;
856
857 for (i = 0; i < m; i++) {
858 for (j = 0; j < n; j++) {
859 ost << setw((int) w) << p[i * dim_n + j];
860 if (w) {
861 ost << " ";
862 }
863 }
864 ost << endl;
865 }
866}
867
869 int *p, int m, int n)
870{
871 int i, j;
872
873 ost << "{" << endl;
874 for (i = 0; i < m; i++) {
875 ost << "\t";
876 for (j = 0; j < n; j++) {
877 ost << p[i * n + j] << ", ";
878 }
879 ost << endl;
880 }
881 ost << "};" << endl;
882}
883
884
886 int k, int *A, int *B, int *C, int *D)
887// makes the 2k x 2k block matrix
888// (A B)
889// (C D)
890{
891 int i, j, n;
892
893 n = 2 * k;
894 for (i = 0; i < k; i++) {
895 for (j = 0; j < k; j++) {
896 Mtx[i * n + j] = A[i * k + j];
897 }
898 }
899 for (i = 0; i < k; i++) {
900 for (j = 0; j < k; j++) {
901 Mtx[i * n + k + j] = B[i * k + j];
902 }
903 }
904 for (i = 0; i < k; i++) {
905 for (j = 0; j < k; j++) {
906 Mtx[(k + i) * n + j] = C[i * k + j];
907 }
908 }
909 for (i = 0; i < k; i++) {
910 for (j = 0; j < k; j++) {
911 Mtx[(k + i) * n + k + j] = D[i * k + j];
912 }
913 }
914}
915
917 int k, int n, int pivot)
918// afterwards, the matrix is k x (n - 1)
919{
920 int i, j, jj;
921
922 for (i = 0; i < k; i++) {
923 jj = 0;
924 for (j = 0; j < n; j++) {
925 if (j == pivot) {
926 continue;
927 }
928 Mtx[i * (n - 1) + jj] = Mtx[i * n + j];
929 jj++;
930 }
931 }
932}
933
934
935int int_vec::matrix_max_log_of_entries(int *p, int m, int n)
936{
937 int i, j, a, w = 1, w1;
939
940 for (i = 0; i < m; i++) {
941 for (j = 0; j < n; j++) {
942 a = p[i * n + j];
943 if (a > 0) {
944 w1 = NT.int_log10(a);
945 }
946 else if (a < 0) {
947 w1 = NT.int_log10(-a) + 1;
948 }
949 else {
950 w1 = 1;
951 }
952 w = MAXIMUM(w, w1);
953 }
954 }
955 return w;
956}
957
958void int_vec::matrix_print_ost(ostream &ost, int *p, int m, int n)
959{
960 int w;
961
962 w = matrix_max_log_of_entries(p, m, n);
963 matrix_print_ost(ost, p, m, n, w);
964}
965
966void int_vec::matrix_print(int *p, int m, int n)
967{
968 int w;
969
970 w = matrix_max_log_of_entries(p, m, n);
971 matrix_print(p, m, n, w);
972}
973
974void int_vec::matrix_print_tight(int *p, int m, int n)
975{
976 matrix_print(p, m, n, 0);
977}
978
979void int_vec::matrix_print_ost(std::ostream &ost, int *p, int m, int n, int w)
980{
981 int i, j;
982
983 for (i = 0; i < m; i++) {
984 for (j = 0; j < n; j++) {
985 ost << setw((int) w) << p[i * n + j];
986 if (w) {
987 ost << " ";
988 }
989 }
990 ost << endl;
991 }
992}
993
994void int_vec::matrix_print(int *p, int m, int n, int w)
995{
996 int i, j;
997
998 for (i = 0; i < m; i++) {
999 for (j = 0; j < n; j++) {
1000 cout << setw((int) w) << p[i * n + j];
1001 if (w) {
1002 cout << " ";
1003 }
1004 }
1005 cout << endl;
1006 }
1007}
1008
1009void int_vec::matrix_print_bitwise(int *p, int m, int n)
1010{
1011 int i, j;
1012
1013 for (i = 0; i < m; i++) {
1014 for (j = 0; j < n; j++) {
1015 cout << p[i * n + j];
1016 }
1017 cout << endl;
1018 }
1019}
1020
1021void int_vec::distribution_print(std::ostream &ost,
1022 int *val, int *mult, int len)
1023{
1024 int i;
1025
1026 for (i = 0; i < len; i++) {
1027 ost << val[i];
1028 if (mult[i] > 1) {
1029 ost << "^";
1030 if (mult[i] >= 10) {
1031 ost << "{" << mult[i] << "}";
1032 }
1033 else {
1034 ost << mult[i];
1035 }
1036 }
1037 if (i < len - 1) {
1038 ost << ", ";
1039 }
1040 }
1041}
1042
1043void int_vec::set_print(std::ostream &ost, int *v, int len)
1044{
1045 int i;
1046
1047 ost << "{ ";
1048 for (i = 0; i < len; i++) {
1049 ost << v[i];
1050 if (i < len - 1) {
1051 ost << ", ";
1052 }
1053 }
1054 ost << " }";
1055}
1056
1057
1058void int_vec::integer_vec_print(std::ostream &ost, int *v, int len)
1059{
1060 int i;
1061
1062 ost << "( ";
1063 for (i = 0; i < len; i++) {
1064 ost << v[i];
1065 if (i < len - 1) {
1066 ost << ", ";
1067 }
1068 }
1069 ost << " )";
1070}
1071
1072
1073
1074int int_vec::hash(int *v, int len, int bit_length)
1075{
1076 int h = 0;
1077 int i;
1078 algorithms Algo;
1079
1080 for (i = 0; i < len; i++) {
1081 //h = hashing(h, v[i]);
1082 h = Algo.hashing_fixed_width(h, v[i], bit_length);
1083 }
1084 return h;
1085}
1086
1087
1088void int_vec::create_string_with_quotes(std::string &str, int *v, int len)
1089{
1090 ostringstream s;
1091 int i;
1092
1093 s << "\"";
1094 for (i = 0; i < len; i++) {
1095 s << v[i];
1096 if (i < len - 1) {
1097 s << ",";
1098 }
1099 }
1100 s << "\"";
1101 str.assign(s.str());
1102}
1103
1104void int_vec::transpose(int *M, int m, int n, int *Mt)
1105// Mt must point to the right amount of memory (n * m int's)
1106{
1107 int i, j;
1108
1109 for (i = 0; i < m; i++) {
1110 for (j = 0; j < n; j++) {
1111 Mt[j * m + i] = M[i * n + j];
1112 }
1113 }
1114}
1115
1116
1117}}}
1118
1119
1120
int hashing_fixed_width(int hash0, int a, int bit_length)
Definition: algorithms.cpp:58
void take_away(int *v, int &len, int *take_away, int nb_take_away)
Definition: int_vec.cpp:90
void init5(int *v, int a0, int a1, int a2, int a3, int a4)
Definition: int_vec.cpp:264
void print_dense(std::ostream &ost, int *v, int len)
Definition: int_vec.cpp:544
void add3(int *v1, int *v2, int *v3, int *w, int len)
Definition: int_vec.cpp:39
void matrix_make_block_matrix_2x2(int *Mtx, int k, int *A, int *B, int *C, int *D)
Definition: int_vec.cpp:885
void apply(int *from, int *through, int *to, int len)
Definition: int_vec.cpp:48
void print_classified_str(std::stringstream &sstr, int *v, int len, int f_backwards)
Definition: int_vec.cpp:598
void delete_element_assume_sorted(int *v, int &len, int a)
Definition: int_vec.cpp:200
void distribution_print(std::ostream &ost, int *val, int *mult, int len)
Definition: int_vec.cpp:1021
void print_integer_matrix_in_C_source(std::ostream &ost, int *p, int m, int n)
Definition: int_vec.cpp:868
void add(int *v1, int *v2, int *w, int len)
Definition: int_vec.cpp:30
int is_constant_on_subset(int *v, int *subset, int sz, int &value)
Definition: int_vec.cpp:67
void print_integer_matrix(std::ostream &ost, int *p, int m, int n)
Definition: int_vec.cpp:839
void matrix_print_ost(std::ostream &ost, int *p, int m, int n)
void print_integer_matrix_width(std::ostream &ost, int *p, int m, int n, int dim_n, int w)
Definition: int_vec.cpp:852
void create_string_with_quotes(std::string &str, int *v, int len)
Definition: int_vec.cpp:1088
void print_fully(std::ostream &ost, std::vector< int > &v)
Definition: int_vec.cpp:513
int vec_max_log_of_entries(std::vector< std::vector< int > > &p)
Definition: int_vec.cpp:328
void transpose(int *M, int m, int n, int *Mt)
Definition: int_vec.cpp:1104
void set_print(std::ostream &ost, int *v, int len)
Definition: int_vec.cpp:1043
void distribution(int *v, int len_v, int *&val, int *&mult, int &len)
Definition: int_vec.cpp:387
void matrix_delete_column_in_place(int *Mtx, int k, int n, int pivot)
Definition: int_vec.cpp:916
void print_to_str_naked(char *str, int *data, int len)
Definition: int_vec.cpp:815
void distribution_compute_and_print(std::ostream &ost, int *v, int v_len)
Definition: int_vec.cpp:374
void vec_print(std::vector< std::vector< int > > &p)
Definition: int_vec.cpp:351
void print_to_str(char *str, int *data, int len)
Definition: int_vec.cpp:799
void print_Cpp(std::ostream &ost, int *v, int len)
Definition: int_vec.cpp:556
void copy(int *from, int *to, long int len)
Definition: int_vec.cpp:167
void print_str(std::stringstream &ost, int *v, int len)
Definition: int_vec.cpp:467
void scan_from_stream(std::istream &is, int *&v, int &len)
Definition: int_vec.cpp:643
void integer_vec_print(std::ostream &ost, int *v, int len)
Definition: int_vec.cpp:1058
void copy_to_lint(int *from, long int *to, long int len)
Definition: int_vec.cpp:177
void print_str_naked(std::stringstream &ost, int *v, int len)
Definition: int_vec.cpp:481
void print(std::ostream &ost, std::vector< int > &v)
Definition: int_vec.cpp:413
void apply_lint(int *from, long int *through, long int *to, int len)
Definition: int_vec.cpp:57
void print_as_table(std::ostream &ost, int *v, int len, int width)
Definition: int_vec.cpp:497
int hash(int *v, int len, int bit_length)
Definition: int_vec.cpp:1074
void swap(int *v1, int *v2, long int len)
Definition: int_vec.cpp:188
void print_GAP(std::ostream &ost, int *v, int len)
Definition: int_vec.cpp:575
void scan(std::string &s, int *&v, int &len)
Definition: int_vec.cpp:608
a collection of functions related to sorted vectors
int int_vec_search(int *v, int len, int a, int &idx)
Definition: sorting.cpp:1094
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 print_naked_stringstream(std::stringstream &sstr, int f_backwards)
Definition: tally.cpp:378
#define FREE_int(p)
Definition: foundations.h:640
#define NEW_int(n)
Definition: foundations.h:625
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define MAXIMUM(x, y)
Definition: foundations.h:217
the orbiter library for the classification of combinatorial objects