From 7b1836b35e4e4e275c093f1a120db8006108b90d Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 20 May 2024 11:00:48 +0200 Subject: Added tests for h48 invcoord --- TODO.txt | 2 +- src/solve_h48.h | 30 +++++++++------- test/001_cube_conversion/cube_conversion_tests.c | 2 -- test/071_coord_eo/coord_eo_tests.c | 1 - test/072_coord_co/coord_co_tests.c | 1 - test/073_coord_csep/coord_csep_tests.c | 1 - test/074_coord_esep/coord_esep_tests.c | 1 - test/075_set_eo/set_eo_tests.c | 2 -- test/076_copy_corners/copy_corners_tests.c | 2 -- test/077_copy_edges/copy_edges_tests.c | 2 -- test/078_invcoord_esep/invcoord_esep_tests.c | 1 - test/101_coord_invcoord_h48/00_all.in | 8 +++++ test/101_coord_invcoord_h48/00_all.out | 8 +++++ .../coord_invcoord_h48_tests.c | 40 ++++++++++++++++++++++ test/101_gendata_esep/00_all.in | 0 test/101_gendata_esep/00_all.out | 1 - test/101_gendata_esep/gendata_esep_tests.c | 22 ------------ test/102_gendata_esep/00_all.in | 0 test/102_gendata_esep/00_all.out | 1 + test/102_gendata_esep/gendata_esep_tests.c | 22 ++++++++++++ test/test.h | 2 ++ 21 files changed, 99 insertions(+), 50 deletions(-) create mode 100644 test/101_coord_invcoord_h48/00_all.in create mode 100644 test/101_coord_invcoord_h48/00_all.out create mode 100644 test/101_coord_invcoord_h48/coord_invcoord_h48_tests.c delete mode 100644 test/101_gendata_esep/00_all.in delete mode 100644 test/101_gendata_esep/00_all.out delete mode 100644 test/101_gendata_esep/gendata_esep_tests.c create mode 100644 test/102_gendata_esep/00_all.in create mode 100644 test/102_gendata_esep/00_all.out create mode 100644 test/102_gendata_esep/gendata_esep_tests.c diff --git a/TODO.txt b/TODO.txt index 30d0247..a93be99 100644 --- a/TODO.txt +++ b/TODO.txt @@ -2,7 +2,7 @@ In progress: go back to nissy-style BFS for eosep data computation - (done) compute selfsim and cocsep representatives - (done) implement set_eo_fast for invcoord_h48 - (done) for invcoord_h48 remove erep, implement inverse esep coord - - add unit tests for invcoord_h48 (compute tables, if needed) + - (done) add unit tests for invcoord_h48 (compute tables, if needed) - change to BFS TODO pruning tables: diff --git a/src/solve_h48.h b/src/solve_h48.h index d4a018b..b04ae47 100644 --- a/src/solve_h48.h +++ b/src/solve_h48.h @@ -8,13 +8,13 @@ #define ESEP_VISITEDSIZE ((ESEP_TABLESIZE * 2U + 7U) / 8U) #define ESEP_INFOSIZE 25 /* TODO unknown yet */ -#define H48_ESIZE ((_12c4 * _8c4) << h) +#define H48_ESIZE(h) ((_12c4 * _8c4) << (h)) -#define _esep_ind(i) (i / 8U) -#define _esep_shift(i) (4U * (i % 8U)) -#define _esep_mask(i) (((1U << 4U) - 1U) << _esep_shift(i)) -#define _visited_ind(i) (i / 8U) -#define _visited_mask(i) (1U << (i % 8U)) +#define _esep_ind(i) (i / 8U) +#define _esep_shift(i) (4U * (i % 8U)) +#define _esep_mask(i) (((1U << 4U) - 1U) << _esep_shift(i)) +#define _visited_ind(i) (i / 8U) +#define _visited_mask(i) (1U << (i % 8U)) typedef struct { cube_fast_t cube; @@ -70,22 +70,26 @@ coord_h48(cube_fast_t c, const uint32_t *cocsepdata, uint8_t h) esep = coord_fast_esep(d); eo = coord_fast_eo(d); - ret = (coclass * H48_ESIZE) + (esep << h) + (eo >> (11-h)); + ret = (coclass * H48_ESIZE(h)) + (esep << h) + (eo >> (11-h)); return ret; } +/* + +This function does not necessarily return a cube whose coordinate is +the given value, because it works up to symmetry. This means that the +returned cube is a transformed cube of one that gives the correct value. +*/ _static_inline cube_fast_t -invcoord_h48(int64_t i, const cube_fast_t *crep, uint8_t h) -{ - cube_fast_t ret; - int64_t coclass, ee, esep, eo; +invcoord_h48(int64_t i, const cube_fast_t *crep, uint8_t h) { + cube_fast_t ret; int64_t coclass, ee, esep, eo; DBG_ASSERT(h <= 11, cubetofast(zero), "invcoord_h48: h must be between 0 and 11\n"); - coclass = i / H48_ESIZE; - ee = i % H48_ESIZE; + coclass = i / H48_ESIZE(h); + ee = i % H48_ESIZE(h); esep = ee >> h; eo = (ee & ((1<