aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2023-02-04 18:00:31 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2023-02-04 18:00:31 +0100
commit455c7d9c8185acdd8c8fe74ad4a59a3e0756d75d (patch)
treef31a8eb3426a593c0fb49dfaf744db2eaeeb049d /src
parent092270834eac54ed33e634494f9f38ba7fd38fd4 (diff)
downloadnissy-455c7d9c8185acdd8c8fe74ad4a59a3e0756d75d.tar.gz
nissy-455c7d9c8185acdd8c8fe74ad4a59a3e0756d75d.zip
Moved coordinate index consistency test to tests folder
Diffstat (limited to 'src')
-rw-r--r--src/coord.c37
-rw-r--r--src/coord.h27
2 files changed, 30 insertions, 34 deletions
diff --git a/src/coord.c b/src/coord.c
index 06f7474..673434f 100644
--- a/src/coord.c
+++ b/src/coord.c
@@ -2,9 +2,6 @@
2 2
3#include "coord.h" 3#include "coord.h"
4 4
5static uint64_t indexers_getind(Indexer **is, Cube *c);
6static uint64_t indexers_getmax(Indexer **is);
7static void indexers_makecube(Indexer **is, uint64_t ind, Cube *c);
8static void gen_coord_comp(Coordinate *coord); 5static void gen_coord_comp(Coordinate *coord);
9static void gen_coord_sym(Coordinate *coord); 6static void gen_coord_sym(Coordinate *coord);
10static bool read_coord_mtable(Coordinate *coord); 7static bool read_coord_mtable(Coordinate *coord);
@@ -169,7 +166,7 @@ invindex_eposepe(uint64_t ind, Cube *cube)
169 166
170/* Other local functions *****************************************************/ 167/* Other local functions *****************************************************/
171 168
172static uint64_t 169uint64_t
173indexers_getmax(Indexer **is) 170indexers_getmax(Indexer **is)
174{ 171{
175 int i; 172 int i;
@@ -181,7 +178,7 @@ indexers_getmax(Indexer **is)
181 return max; 178 return max;
182} 179}
183 180
184static uint64_t 181uint64_t
185indexers_getind(Indexer **is, Cube *c) 182indexers_getind(Indexer **is, Cube *c)
186{ 183{
187 int i; 184 int i;
@@ -195,12 +192,12 @@ indexers_getind(Indexer **is, Cube *c)
195 return max; 192 return max;
196} 193}
197 194
198static void 195void
199indexers_makecube(Indexer **is, uint64_t ind, Cube *c) 196indexers_makecube(Indexer **is, uint64_t ind, Cube *c)
200{ 197{
201 /* Warning: anti-indexers are applied in the same order as indexers. */ 198 /* Warning: anti-indexers are applied in the same order as indexers. */
202 /* We assume order does not matter, but it would make more sense to */ 199 /* We assume order does not matter, but it would make more sense to */
203 /* Apply them in reverse. */ 200 /* apply them in reverse. */
204 201
205 int i; 202 int i;
206 uint64_t m; 203 uint64_t m;
@@ -629,32 +626,6 @@ move_coord(Coordinate *coord, Move m, uint64_t ind, Trans *offtrans)
629 return coord->max; /* Only reached in case of error */ 626 return coord->max; /* Only reached in case of error */
630} 627}
631 628
632bool
633test_coord(Coordinate *coord)
634{
635 uint64_t ui, uj;
636 Cube c;
637
638 if (coord->type != COMP_COORD) {
639 fprintf(stderr, "Can only test COMP_COORD\n");
640 return false;
641 }
642
643 gen_coord(coord);
644 for (ui = 0; ui < coord->max; ui++) {
645 indexers_makecube(coord->i, ui, &c);
646 uj = indexers_getind(coord->i, &c);
647 if (ui != uj) {
648 fprintf(stderr, "%s: error: %" PRIu64 " different"
649 " from %" PRIu64 "\n", coord->name, uj, ui);
650 return false;
651 }
652 }
653
654 fprintf(stderr, "%s: test passed\n", coord->name);
655 return true;
656}
657
658uint64_t 629uint64_t
659trans_coord(Coordinate *coord, Trans t, uint64_t ind) 630trans_coord(Coordinate *coord, Trans t, uint64_t ind)
660{ 631{
diff --git a/src/coord.h b/src/coord.h
index 47c0579..4cd7e47 100644
--- a/src/coord.h
+++ b/src/coord.h
@@ -6,9 +6,10 @@
6void gen_coord(Coordinate *coord); 6void gen_coord(Coordinate *coord);
7uint64_t index_coord(Coordinate *coord, Cube *cube, 7uint64_t index_coord(Coordinate *coord, Cube *cube,
8 Trans *offtrans); 8 Trans *offtrans);
9uint64_t indexers_getind(Indexer **is, Cube *c);
10void indexers_makecube(Indexer **is, uint64_t ind, Cube *c);
9uint64_t move_coord(Coordinate *coord, Move m, 11uint64_t move_coord(Coordinate *coord, Move m,
10 uint64_t ind, Trans *offtrans); 12 uint64_t ind, Trans *offtrans);
11bool test_coord(Coordinate *coord);
12uint64_t trans_coord(Coordinate *coord, Trans t, uint64_t ind); 13uint64_t trans_coord(Coordinate *coord, Trans t, uint64_t ind);
13 14
14/* Base coordinates and their index functions ********************************/ 15/* Base coordinates and their index functions ********************************/
@@ -32,6 +33,8 @@ extern Coordinate coord_drud_sym16;
32extern Coordinate coord_drudfin_noE_sym16; 33extern Coordinate coord_drudfin_noE_sym16;
33extern Coordinate coord_nxopt31; 34extern Coordinate coord_nxopt31;
34 35
36extern Coordinate *all_coordinates[];
37
35#else 38#else
36 39
37/* Indexers ******************************************************************/ 40/* Indexers ******************************************************************/
@@ -228,6 +231,28 @@ coord_nxopt31 = {
228 .base = {&coord_eofbepos_sym16, &coord_coud_cpudsep}, 231 .base = {&coord_eofbepos_sym16, &coord_coud_cpudsep},
229}; 232};
230 233
234/* All coordinates ***********************************************************/
235
236Coordinate *all_coordinates[] = {
237 &coord_eofb,
238 &coord_coud,
239 &coord_cp,
240 &coord_cpudsep,
241 &coord_epos,
242 &coord_epe,
243 &coord_eposepe,
244 &coord_epud,
245 &coord_eofbepos,
246 &coord_coud_cpudsep,
247 &coord_eofbepos_sym16,
248 &coord_cp_sym16,
249 &coord_corners_sym16,
250 &coord_drud_sym16,
251 &coord_drudfin_noE_sym16,
252 &coord_nxopt31,
253 NULL
254};
255
231#endif 256#endif
232 257
233#endif 258#endif

Generated with cgit - Back to sebastiano.tronto.net