From 455c7d9c8185acdd8c8fe74ad4a59a3e0756d75d Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 4 Feb 2023 18:00:31 +0100 Subject: Moved coordinate index consistency test to tests folder --- src/coord.c | 37 ++++--------------------------------- src/coord.h | 27 ++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 34 deletions(-) (limited to 'src') 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 @@ #include "coord.h" -static uint64_t indexers_getind(Indexer **is, Cube *c); -static uint64_t indexers_getmax(Indexer **is); -static void indexers_makecube(Indexer **is, uint64_t ind, Cube *c); static void gen_coord_comp(Coordinate *coord); static void gen_coord_sym(Coordinate *coord); static bool read_coord_mtable(Coordinate *coord); @@ -169,7 +166,7 @@ invindex_eposepe(uint64_t ind, Cube *cube) /* Other local functions *****************************************************/ -static uint64_t +uint64_t indexers_getmax(Indexer **is) { int i; @@ -181,7 +178,7 @@ indexers_getmax(Indexer **is) return max; } -static uint64_t +uint64_t indexers_getind(Indexer **is, Cube *c) { int i; @@ -195,12 +192,12 @@ indexers_getind(Indexer **is, Cube *c) return max; } -static void +void indexers_makecube(Indexer **is, uint64_t ind, Cube *c) { /* Warning: anti-indexers are applied in the same order as indexers. */ /* We assume order does not matter, but it would make more sense to */ - /* Apply them in reverse. */ + /* apply them in reverse. */ int i; uint64_t m; @@ -629,32 +626,6 @@ move_coord(Coordinate *coord, Move m, uint64_t ind, Trans *offtrans) return coord->max; /* Only reached in case of error */ } -bool -test_coord(Coordinate *coord) -{ - uint64_t ui, uj; - Cube c; - - if (coord->type != COMP_COORD) { - fprintf(stderr, "Can only test COMP_COORD\n"); - return false; - } - - gen_coord(coord); - for (ui = 0; ui < coord->max; ui++) { - indexers_makecube(coord->i, ui, &c); - uj = indexers_getind(coord->i, &c); - if (ui != uj) { - fprintf(stderr, "%s: error: %" PRIu64 " different" - " from %" PRIu64 "\n", coord->name, uj, ui); - return false; - } - } - - fprintf(stderr, "%s: test passed\n", coord->name); - return true; -} - uint64_t trans_coord(Coordinate *coord, Trans t, uint64_t ind) { 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 @@ void gen_coord(Coordinate *coord); uint64_t index_coord(Coordinate *coord, Cube *cube, Trans *offtrans); +uint64_t indexers_getind(Indexer **is, Cube *c); +void indexers_makecube(Indexer **is, uint64_t ind, Cube *c); uint64_t move_coord(Coordinate *coord, Move m, uint64_t ind, Trans *offtrans); -bool test_coord(Coordinate *coord); uint64_t trans_coord(Coordinate *coord, Trans t, uint64_t ind); /* Base coordinates and their index functions ********************************/ @@ -32,6 +33,8 @@ extern Coordinate coord_drud_sym16; extern Coordinate coord_drudfin_noE_sym16; extern Coordinate coord_nxopt31; +extern Coordinate *all_coordinates[]; + #else /* Indexers ******************************************************************/ @@ -228,6 +231,28 @@ coord_nxopt31 = { .base = {&coord_eofbepos_sym16, &coord_coud_cpudsep}, }; +/* All coordinates ***********************************************************/ + +Coordinate *all_coordinates[] = { + &coord_eofb, + &coord_coud, + &coord_cp, + &coord_cpudsep, + &coord_epos, + &coord_epe, + &coord_eposepe, + &coord_epud, + &coord_eofbepos, + &coord_coud_cpudsep, + &coord_eofbepos_sym16, + &coord_cp_sym16, + &coord_corners_sym16, + &coord_drud_sym16, + &coord_drudfin_noE_sym16, + &coord_nxopt31, + NULL +}; + #endif #endif -- cgit v1.3