aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-03-14 16:46:50 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-03-14 16:46:50 +0100
commit9e6465bcc8f0d9bd1d78ad357a623452358ba7f2 (patch)
treee5c43d89de835424445be9935e9c9dbd1933085d
parent1e1fd628207034b0412c50e289f146d34c5baf71 (diff)
downloadnissy-core-9e6465bcc8f0d9bd1d78ad357a623452358ba7f2.tar.gz
nissy-core-9e6465bcc8f0d9bd1d78ad357a623452358ba7f2.zip
Added checkdata for coord EO
-rw-r--r--TODO_COORDINATES4
-rw-r--r--src/nissy.c5
-rw-r--r--src/solvers/coord/gendata.h24
-rw-r--r--src/solvers/h48/gendata_h48.h1
-rw-r--r--tools/expected_distributions.h45
5 files changed, 67 insertions, 12 deletions
diff --git a/TODO_COORDINATES b/TODO_COORDINATES
index 5aa0544..f2e4a25 100644
--- a/TODO_COORDINATES
+++ b/TODO_COORDINATES
@@ -1,8 +1,4 @@
1- coord solver 1- coord solver
2 - add checkdata for coord
3 - return to fully qualified solver name
4 x undo chnages to API
5 - add a parameter to gendata to get a shortname (filename) for the table
6 - there is an error (try R B2 as scramble, EO on RL) 2 - there is an error (try R B2 as scramble, EO on RL)
7 - debug 3 - debug
8 - fix 4 - fix
diff --git a/src/nissy.c b/src/nissy.c
index 2766b12..431362d 100644
--- a/src/nissy.c
+++ b/src/nissy.c
@@ -80,8 +80,13 @@ checkdata(const char *buf, const tableinfo_t *info)
80 } else if (!strncmp(info->solver, "h48", 3)) { 80 } else if (!strncmp(info->solver, "h48", 3)) {
81 getdistribution_h48((uint8_t *)buf + INFOSIZE, distr, 81 getdistribution_h48((uint8_t *)buf + INFOSIZE, distr,
82 info->h48h, info->bits); 82 info->h48h, info->bits);
83 } else if (!strncmp(info->solver, "coordinate solver for ", 22)) {
84 getdistribution_coord((uint8_t *)buf + INFOSIZE,
85 info->solver + 22, distr);
83 } else if (!strncmp(info->solver, "eoesep data for h48", 19)) { 86 } else if (!strncmp(info->solver, "eoesep data for h48", 19)) {
84 return true; 87 return true;
88 } else if (!strncmp(info->solver, "coord helper table for ", 23)) {
89 return true;
85 } else { 90 } else {
86 LOG("checkdata: unknown solver %s\n", info->solver); 91 LOG("checkdata: unknown solver %s\n", info->solver);
87 return false; 92 return false;
diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h
index 9512b93..93ffc65 100644
--- a/src/solvers/coord/gendata.h
+++ b/src/solvers/coord/gendata.h
@@ -1,6 +1,8 @@
1STATIC size_t gendata_coord(const coord_t *, void *); 1STATIC size_t gendata_coord(const coord_t *, void *);
2STATIC int64_t gendata_coord_dispatch(const char *, void *); 2STATIC int64_t gendata_coord_dispatch(const char *, void *);
3STATIC tableinfo_t genptable_coord(const coord_t *, const void *, uint8_t *); 3STATIC tableinfo_t genptable_coord(const coord_t *, const void *, uint8_t *);
4STATIC void getdistribution_coord(
5 const uint8_t *, const char *, uint64_t [static INFO_DISTRIBUTION_LEN]);
4STATIC uint8_t get_coord_pval(const coord_t *, const uint8_t *, uint64_t); 6STATIC uint8_t get_coord_pval(const coord_t *, const uint8_t *, uint64_t);
5STATIC void set_coord_pval(const coord_t *, uint8_t *, uint64_t, uint8_t); 7STATIC void set_coord_pval(const coord_t *, uint8_t *, uint64_t, uint8_t);
6 8
@@ -122,6 +124,28 @@ genptable_coord(const coord_t *coord, const void *data, uint8_t *table)
122 return info; 124 return info;
123} 125}
124 126
127STATIC void
128getdistribution_coord(
129 const uint8_t *table,
130 const char *coord,
131 uint64_t distr[static INFO_DISTRIBUTION_LEN]
132)
133{
134 uint8_t v;
135 uint64_t i;
136 coord_t *c;
137
138 memset(distr, 0, INFO_DISTRIBUTION_LEN * sizeof(uint64_t));
139
140 if((c = parse_coord(coord, strlen(coord))) == NULL)
141 return;
142
143 for (i = 0; i < c->max; i++) {
144 v = get_coord_pval(c, table, i);
145 distr[v]++;
146 }
147}
148
125STATIC uint8_t 149STATIC uint8_t
126get_coord_pval(const coord_t *coord, const uint8_t *table, uint64_t i) 150get_coord_pval(const coord_t *coord, const uint8_t *table, uint64_t i)
127{ 151{
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h
index fe4b259..55db1be 100644
--- a/src/solvers/h48/gendata_h48.h
+++ b/src/solvers/h48/gendata_h48.h
@@ -682,6 +682,7 @@ getdistribution_h48(
682 distr[val]++; 682 distr[val]++;
683 } 683 }
684} 684}
685
685STATIC const uint32_t * 686STATIC const uint32_t *
686get_cocsepdata_constptr(const void *data) 687get_cocsepdata_constptr(const void *data)
687{ 688{
diff --git a/tools/expected_distributions.h b/tools/expected_distributions.h
index 0780cf8..60e7500 100644
--- a/tools/expected_distributions.h
+++ b/tools/expected_distributions.h
@@ -58,7 +58,6 @@ uint64_t expected_h48[12][9][21] = {
58 [2] = 392789689, 58 [2] = 392789689,
59 [3] = 477195231, 59 [3] = 477195231,
60 }, 60 },
61
62 }, 61 },
63 [4] = { 62 [4] = {
64 [2] = { 63 [2] = {
@@ -126,6 +125,17 @@ uint64_t expected_h48[12][9][21] = {
126 }, 125 },
127}; 126};
128 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
129static bool 139static bool
130distribution_equal(const uint64_t *expected, const uint64_t *actual, int n) 140distribution_equal(const uint64_t *expected, const uint64_t *actual, int n)
131{ 141{
@@ -144,6 +154,18 @@ distribution_equal(const uint64_t *expected, const uint64_t *actual, int n)
144 return equal; 154 return equal;
145} 155}
146 156
157STATIC bool
158check_table(uint64_t *exp, tableinfo_t *info)
159{
160 if (!distribution_equal(exp, info->distribution, info->maxvalue)) {
161 printf("ERROR! Distribution is incorrect\n");
162 return false;
163 }
164
165 printf("Distribution is correct\n");
166 return true;
167}
168
147static bool 169static bool
148check_cocsep(uint64_t data_size, const void *data) 170check_cocsep(uint64_t data_size, const void *data)
149{ 171{
@@ -169,6 +191,7 @@ unknown_h48(uint8_t h, uint8_t k)
169STATIC bool 191STATIC bool
170check_distribution(const char *solver, uint64_t data_size, const void *data) 192check_distribution(const char *solver, uint64_t data_size, const void *data)
171{ 193{
194 const char *str;
172 tableinfo_t info = {0}; 195 tableinfo_t info = {0};
173 196
174 if (!strncmp(solver, "h48", 3)) { 197 if (!strncmp(solver, "h48", 3)) {
@@ -184,14 +207,20 @@ check_distribution(const char *solver, uint64_t data_size, const void *data)
184 if (unknown_h48(info.h48h, info.bits)) 207 if (unknown_h48(info.h48h, info.bits))
185 goto check_distribution_unknown; 208 goto check_distribution_unknown;
186 209
187 if (!distribution_equal(expected_h48[info.h48h][info.bits], 210 return check_table(expected_h48[info.h48h][info.bits], &info);
188 info.distribution, info.maxvalue)) { 211 }
189 printf("ERROR! h48 distribution is incorrect\n");
190 return false;
191 }
192 212
193 printf("h48 distribution is correct\n"); 213 if (!strncmp(solver, "coord_", 6)) {
194 return true; 214 readtableinfo(data_size, data, &info);
215 if (!strncmp(info.solver, "coord helper table for ", 23))
216 readtableinfo_n(data_size, data, 2, &info);
217
218 str = info.solver + 22; /* "coordinate solver for COORD" */
219 if (!strcmp(str, "EO")) {
220 return check_table(expected_eo, &info);
221 } else {
222 goto check_distribution_unknown;
223 }
195 } 224 }
196 225
197check_distribution_unknown: 226check_distribution_unknown:

Generated with cgit - Back to sebastiano.tronto.net