aboutsummaryrefslogtreecommitdiff
path: root/tools/expected_distributions.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-05-19 17:45:14 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-05-19 17:45:14 +0200
commit62d87e063318cc4c842b1b2d8c184f48aeaf6659 (patch)
tree832bf338232c477975bea69f7370ca13f350fb07 /tools/expected_distributions.h
parent8b94d135429a9f3253cc7f25a1453b412065c4a0 (diff)
downloadnissy-core-62d87e063318cc4c842b1b2d8c184f48aeaf6659.tar.gz
nissy-core-62d87e063318cc4c842b1b2d8c184f48aeaf6659.zip
Refactored checkdata
Relevant changes include: - Changed the signature of nissy_checkdata(). - Removed expected_distribution.h from tools; this data is now included in each solver's src/ code. - Removed distribution check for cocsep; may add back later.
Diffstat (limited to 'tools/expected_distributions.h')
-rw-r--r--tools/expected_distributions.h267
1 files changed, 0 insertions, 267 deletions
diff --git a/tools/expected_distributions.h b/tools/expected_distributions.h
deleted file mode 100644
index 1193fb3..0000000
--- a/tools/expected_distributions.h
+++ /dev/null
@@ -1,267 +0,0 @@
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
14uint64_t expected_h48[12][9][21] = {
15 [0] = {
16 [2] = {
17 [0] = 5473562,
18 [1] = 34776317,
19 [2] = 68566704,
20 [3] = 8750867,
21 },
22 [4] = {
23 [0] = 1,
24 [1] = 1,
25 [2] = 4,
26 [3] = 34,
27 [4] = 331,
28 [5] = 3612,
29 [6] = 41605,
30 [7] = 474128,
31 [8] = 4953846,
32 [9] = 34776317,
33 [10] = 68566704,
34 [11] = 8749194,
35 [12] = 1673,
36 },
37 },
38 [1] = {
39 [2] = {
40 [0] = 6012079,
41 [1] = 45822302,
42 [2] = 142018732,
43 [3] = 41281787,
44 },
45 },
46 [2] = {
47 [2] = {
48 [0] = 6391286,
49 [1] = 55494785,
50 [2] = 252389935,
51 [3] = 155993794,
52 },
53 },
54 [3] = {
55 [2] = {
56 [0] = 6686828,
57 [1] = 63867852,
58 [2] = 392789689,
59 [3] = 477195231,
60 },
61 },
62 [4] = {
63 [2] = {
64 [0] = 77147213,
65 [1] = 543379415,
66 [2] = 1139570251,
67 [3] = 120982321,
68 },
69 },
70 [5] = {
71 [2] = {
72 [0] = 82471284,
73 [1] = 687850732,
74 [2] = 2345840746,
75 [3] = 645995638,
76 },
77 },
78 [6] = {
79 [2] = {
80 [0] = 85941099,
81 [1] = 804752968,
82 [2] = 4077248182,
83 [3] = 2556374551,
84 },
85 },
86 [7] = {
87 [2] = {
88 [0] = 88529761,
89 [1] = 897323475,
90 [2] = 6126260791,
91 [3] = 7936519573,
92 },
93 },
94 [8] = {
95 [2] = {
96 [0] = 1051579940,
97 [1] = 8136021316,
98 [2] = 19024479822,
99 [3] = 18851861220,
100 },
101 },
102 [9] = {
103 [2] = {
104 [0] = 1102038189,
105 [1] = 9888265242,
106 [2] = 38299375805,
107 [3] = 10904855164,
108 },
109 },
110 [10] = {
111 [2] = {
112 [0] = 1133240039,
113 [1] = 11196285614,
114 [2] = 64164702961,
115 [3] = 43894840186,
116 },
117 },
118 [11] = {
119 [2] = {
120 [0] = 1150763161,
121 [1] = 12045845660,
122 [2] = 91163433330,
123 [3] = 136418095449,
124 },
125 },
126};
127
128uint64_t expected_eo[21] = {
129 [0] = 1,
130 [1] = 2,
131 [2] = 25,
132 [3] = 202,
133 [4] = 620,
134 [5] = 900,
135 [6] = 285,
136 [7] = 13,
137};
138
139uint64_t expected_dr[21] = {
140 [0] = 1,
141 [1] = 1,
142 [2] = 5,
143 [3] = 44,
144 [4] = 487,
145 [5] = 5841,
146 [6] = 68364,
147 [7] = 776568,
148 [8] = 7950748,
149 [9] = 52098876,
150 [10] = 76236234,
151 [11] = 3771112,
152 [12] = 129,
153};
154
155uint64_t expected_dreo[21] = {
156 [0] = 1,
157 [1] = 1,
158 [2] = 4,
159 [3] = 22,
160 [4] = 160,
161 [5] = 1286,
162 [6] = 8550,
163 [7] = 42152,
164 [8] = 90748,
165 [9] = 33466,
166 [10] = 757,
167};
168
169static bool
170distribution_equal(const uint64_t *expected, const uint64_t *actual, int n)
171{
172 bool equal;
173 int i;
174
175 for (i = 0, equal = true; i <= n; i++) {
176 if (expected[i] != actual[i]) {
177 equal = false;
178 printf("Wrong value for %d: expected %" PRIu64
179 ", actual %" PRIu64 "\n",
180 i, expected[i], actual[i]);
181 }
182 }
183
184 return equal;
185}
186
187STATIC bool
188check_table(uint64_t *exp, tableinfo_t *info)
189{
190 if (!distribution_equal(exp, info->distribution, info->maxvalue)) {
191 printf("ERROR! Distribution is incorrect\n");
192 return false;
193 }
194
195 printf("Distribution is correct\n");
196 return true;
197}
198
199static bool
200check_cocsep(size_t data_size, const unsigned char *data)
201{
202 tableinfo_t info;
203
204 readtableinfo(data_size, data, &info);
205 return distribution_equal(
206 expected_cocsep, info.distribution, info.maxvalue);
207}
208
209static bool
210unknown_h48(uint8_t h, uint8_t k)
211{
212 if (k != 2 && k != 4)
213 return true;
214
215 if (k == 4 && h != 0)
216 return true;
217
218 return k == 2 && h > 7;
219}
220
221STATIC bool
222check_distribution(
223 const char *solver,
224 size_t data_size,
225 const unsigned char *data
226)
227{
228 const char *str;
229 tableinfo_t info = {0};
230
231 if (!strncmp(solver, "h48", 3)) {
232 readtableinfo(data_size, data, &info);
233 if (!distribution_equal(
234 expected_cocsep, info.distribution, info.maxvalue)) {
235 printf("ERROR! cocsep distribution is incorrect\n");
236 return false;
237 }
238 printf("cocsep distribution is correct\n");
239
240 readtableinfo_n(data_size, data, 2, &info);
241 if (unknown_h48(info.h48h, info.bits))
242 goto check_distribution_unknown;
243
244 return check_table(expected_h48[info.h48h][info.bits], &info);
245 }
246
247 if (!strncmp(solver, "coord_", 6)) {
248 readtableinfo(data_size, data, &info);
249 if (!strncmp(info.solver, "coord helper table for ", 23))
250 readtableinfo_n(data_size, data, 2, &info);
251
252 str = info.solver + 22; /* "coordinate solver for COORD" */
253 if (!strcmp(str, "EO")) {
254 return check_table(expected_eo, &info);
255 } else if (!strcmp(str, "DR")) {
256 return check_table(expected_dr, &info);
257 } else if (!strcmp(str, "DREO")) {
258 return check_table(expected_dreo, &info);
259 } else {
260 goto check_distribution_unknown;
261 }
262 }
263
264check_distribution_unknown:
265 printf("Distribution unknown, not checked\n");
266 return true;
267}

Generated with cgit - Back to sebastiano.tronto.net