aboutsummaryrefslogtreecommitdiff
path: root/tools/expected_distributions.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/expected_distributions.h')
-rw-r--r--tools/expected_distributions.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/tools/expected_distributions.h b/tools/expected_distributions.h
index 535cab2..0f3fec3 100644
--- a/tools/expected_distributions.h
+++ b/tools/expected_distributions.h
@@ -1,3 +1,16 @@
1uint64_t expected_cocsep[21] = {
2 [0] = 1,
3 [1] = 6,
4 [2] = 63,
5 [3] = 468,
6 [4] = 3068,
7 [5] = 15438,
8 [6] = 53814,
9 [7] = 71352,
10 [8] = 8784,
11 [9] = 96
12};
13
1uint64_t expected_h48[12][9][21] = { 14uint64_t expected_h48[12][9][21] = {
2 [0] = { 15 [0] = {
3 [2] = { 16 [2] = {
@@ -31,3 +44,76 @@ uint64_t expected_h48[12][9][21] = {
31 }, 44 },
32 }, 45 },
33}; 46};
47
48static bool
49distribution_equal(const uint64_t *expected, const uint64_t *actual, int n)
50{
51 bool equal;
52 int i;
53
54 for (i = 0, equal = true; i <= n; i++) {
55 if (expected[i] != actual[i]) {
56 equal = false;
57 printf("Wrong value for %d: expected %" PRIu64
58 ", actual %" PRIu64 "\n",
59 i, expected[i], actual[i]);
60 }
61 }
62
63 return equal;
64}
65
66static bool
67check_cocsep(const void *data)
68{
69 tableinfo_t info;
70
71 readtableinfo(data, &info);
72 return distribution_equal(
73 expected_cocsep, info.distribution, info.maxvalue);
74}
75
76static bool
77unknown_h48(uint8_t h, uint8_t k)
78{
79 if (k != 2 && k != 4)
80 return true;
81
82 if (k == 4 && h != 0)
83 return true;
84
85 return k == 2 && h > 1;
86}
87
88STATIC bool
89check_distribution(const char *solver, const void *data)
90{
91 tableinfo_t info = {0};
92
93 if (!strcmp(solver, "h48")) {
94 readtableinfo(data, &info);
95 if (!distribution_equal(
96 expected_cocsep, info.distribution, info.maxvalue)) {
97 printf("ERROR! cocsep distribution is incorrect\n");
98 return false;
99 }
100 printf("cocsep distribution is correct\n");
101
102 readtableinfo_n(data, 2, &info);
103 if (unknown_h48(info.h48h, info.bits))
104 goto check_distribution_unknown;
105
106 if (!distribution_equal(expected_h48[info.h48h][info.bits],
107 info.distribution, info.maxvalue)) {
108 printf("ERROR! h48 distribution is incorrect\n");
109 return false;
110 }
111
112 printf("h48 distribution is correct\n");
113 return true;
114 }
115
116check_distribution_unknown:
117 printf("Distribution unknown, not checked\n");
118 return true;
119}

Generated with cgit - Back to sebastiano.tronto.net