diff options
Diffstat (limited to '')
| -rw-r--r-- | src/solvers/coord/coord.h | 1 | ||||
| -rw-r--r-- | src/solvers/coord/dr.h | 178 | ||||
| -rw-r--r-- | src/solvers/coord/eo.h | 10 | ||||
| -rw-r--r-- | src/solvers/coord/gendata.h | 54 | ||||
| -rw-r--r-- | src/solvers/coord/list.h | 1 | ||||
| -rw-r--r-- | src/solvers/coord/types_macros.h | 1 | ||||
| -rw-r--r-- | src/utils/constants.h | 7 | ||||
| -rw-r--r-- | test/121_coorddata_dr/00_all.in | 0 | ||||
| -rw-r--r-- | test/121_coorddata_dr/00_all.out | 1 | ||||
| -rw-r--r-- | test/121_coorddata_dr/coorddata_dr.c | 59 | ||||
| -rw-r--r-- | test/test.h | 2 |
11 files changed, 299 insertions, 15 deletions
diff --git a/src/solvers/coord/coord.h b/src/solvers/coord/coord.h index f42739d..11d41bc 100644 --- a/src/solvers/coord/coord.h +++ b/src/solvers/coord/coord.h | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #include "types_macros.h" | 1 | #include "types_macros.h" |
| 2 | #include "common.h" | 2 | #include "common.h" |
| 3 | #include "eo.h" | 3 | #include "eo.h" |
| 4 | #include "dr.h" | ||
| 4 | #include "list.h" | 5 | #include "list.h" |
| 5 | #include "utils.h" | 6 | #include "utils.h" |
| 6 | #include "gendata.h" | 7 | #include "gendata.h" |
diff --git a/src/solvers/coord/dr.h b/src/solvers/coord/dr.h new file mode 100644 index 0000000..5f3a99b --- /dev/null +++ b/src/solvers/coord/dr.h | |||
| @@ -0,0 +1,178 @@ | |||
| 1 | #define DREOESEP_CLASSES UINT64_C(64430) | ||
| 2 | #define DREOESEP_MAX (POW_2_11 * COMB_12_4) | ||
| 3 | |||
| 4 | #define DR_CLASS_TABLESIZE (sizeof(uint32_t) * (size_t)DREOESEP_MAX) | ||
| 5 | #define DR_REP_TABLESIZE (sizeof(uint32_t) * (size_t)DREOESEP_CLASSES) | ||
| 6 | #define DR_COORD_DATASIZE (INFOSIZE + DR_CLASS_TABLESIZE + DR_REP_TABLESIZE) | ||
| 7 | |||
| 8 | #define DR_CLASS_SHIFT UINT32_C(16) | ||
| 9 | #define DR_CLASS_MASK (UINT32_C(0xFFFF) << DR_CLASS_SHIFT) | ||
| 10 | #define DR_CLASS(d) (((d) & DR_CLASS_MASK) >> DR_CLASS_SHIFT) | ||
| 11 | |||
| 12 | #define DR_TTREP_SHIFT UINT32_C(0) | ||
| 13 | #define DR_TTREP_MASK (UINT32_C(0xFF) << DR_TTREP_SHIFT) | ||
| 14 | #define DR_TTREP(d) (((d) & DR_TTREP_MASK) >> DR_TTREP_SHIFT) | ||
| 15 | |||
| 16 | #define DR_ISNASTY_SHIFT UINT32_C(8) | ||
| 17 | #define DR_ISNASTY_MASK (UINT32_C(0xFF) << DR_ISNASTY_SHIFT) | ||
| 18 | #define DR_ISNASTY(d) (((d) & DR_ISNASTY_MASK) >> DR_ISNASTY_SHIFT) | ||
| 19 | |||
| 20 | STATIC uint64_t coord_dreoesep_nosym(cube_t); | ||
| 21 | STATIC cube_t invcoord_dreoesep_nosym(uint64_t); | ||
| 22 | |||
| 23 | STATIC uint64_t coordinate_dr_coord(cube_t, const void *); | ||
| 24 | STATIC cube_t coordinate_dr_cube(uint64_t, const void *); | ||
| 25 | STATIC bool coordinate_dr_isnasty(uint64_t, const void *); | ||
| 26 | STATIC uint64_t coordinate_dr_gendata(void *); | ||
| 27 | |||
| 28 | STATIC coord_t coordinate_dr = { | ||
| 29 | .name = "DR", | ||
| 30 | .coord = &coordinate_dr_coord, | ||
| 31 | .cube = &coordinate_dr_cube, | ||
| 32 | .isnasty = &coordinate_dr_isnasty, | ||
| 33 | .gendata = coordinate_dr_gendata, | ||
| 34 | .max = DREOESEP_CLASSES * POW_3_7, | ||
| 35 | .trans_mask = TM_UDFIX, | ||
| 36 | .moves_mask = MM_ALLMOVES, | ||
| 37 | .axistrans = { | ||
| 38 | [AXIS_UD] = TRANS_UFr, | ||
| 39 | [AXIS_RL] = TRANS_RFr, | ||
| 40 | [AXIS_FB] = TRANS_FDr, | ||
| 41 | }, | ||
| 42 | .is_admissible = &solution_lastqt_cw, | ||
| 43 | }; | ||
| 44 | |||
| 45 | STATIC uint64_t | ||
| 46 | coord_dreoesep_nosym(cube_t cube) | ||
| 47 | { | ||
| 48 | uint64_t eo, esep; | ||
| 49 | |||
| 50 | esep = coord_esep(cube) / COMB_8_4; | ||
| 51 | eo = coord_eo(cube); | ||
| 52 | |||
| 53 | return esep * POW_2_11 + eo; | ||
| 54 | } | ||
| 55 | |||
| 56 | STATIC cube_t | ||
| 57 | invcoord_dreoesep_nosym(uint64_t coord) | ||
| 58 | { | ||
| 59 | uint64_t eo, esep; | ||
| 60 | cube_t cube; | ||
| 61 | |||
| 62 | eo = coord % POW_2_11; | ||
| 63 | esep = (coord / POW_2_11) * COMB_8_4; | ||
| 64 | cube = invcoord_esep(esep); | ||
| 65 | set_eo(&cube, eo); | ||
| 66 | |||
| 67 | return cube; | ||
| 68 | } | ||
| 69 | |||
| 70 | STATIC uint64_t | ||
| 71 | coordinate_dr_coord(cube_t cube, const void *data) | ||
| 72 | { | ||
| 73 | const char *datanoinfo; | ||
| 74 | const uint32_t *data32; | ||
| 75 | uint32_t d; | ||
| 76 | cube_t transformed; | ||
| 77 | |||
| 78 | datanoinfo = (const char *)data + INFOSIZE; | ||
| 79 | data32 = (const uint32_t *)datanoinfo; | ||
| 80 | d = data32[coord_dreoesep_nosym(cube)]; | ||
| 81 | transformed = transform(cube, DR_TTREP(d)); | ||
| 82 | |||
| 83 | return DR_CLASS(d) * POW_3_7 + coord_co(transformed); | ||
| 84 | } | ||
| 85 | |||
| 86 | STATIC cube_t | ||
| 87 | coordinate_dr_cube(uint64_t coord, const void *data) | ||
| 88 | { | ||
| 89 | const char *datanoinfo; | ||
| 90 | const uint32_t *rep32; | ||
| 91 | cube_t cube; | ||
| 92 | |||
| 93 | datanoinfo = (const char *)data + INFOSIZE; | ||
| 94 | rep32 = (const uint32_t *)(datanoinfo + DR_CLASS_TABLESIZE); | ||
| 95 | cube = invcoord_dreoesep_nosym(rep32[coord / POW_3_7]); | ||
| 96 | copy_corners(&cube, invcoord_co(coord % POW_3_7)); | ||
| 97 | |||
| 98 | return cube; | ||
| 99 | } | ||
| 100 | |||
| 101 | STATIC bool | ||
| 102 | coordinate_dr_isnasty(uint64_t coord, const void *data) | ||
| 103 | { | ||
| 104 | const char *datanoinfo; | ||
| 105 | const uint32_t *classttrep; | ||
| 106 | |||
| 107 | datanoinfo = (const char *)data + INFOSIZE; | ||
| 108 | classttrep = (const uint32_t *)datanoinfo; | ||
| 109 | |||
| 110 | return DR_ISNASTY(classttrep[coord]); | ||
| 111 | } | ||
| 112 | |||
| 113 | STATIC size_t | ||
| 114 | coordinate_dr_gendata(void *data) | ||
| 115 | { | ||
| 116 | uint64_t i, ii, j, n, t, nasty; | ||
| 117 | char *datanoinfo; | ||
| 118 | uint32_t *classttrep, *rep; | ||
| 119 | cube_t c; | ||
| 120 | tableinfo_t info; | ||
| 121 | |||
| 122 | if (data == NULL) | ||
| 123 | goto coordinate_dr_gendata_returnsize; | ||
| 124 | |||
| 125 | datanoinfo = (char *)data + INFOSIZE; | ||
| 126 | classttrep = (uint32_t *)datanoinfo; | ||
| 127 | rep = classttrep + (DR_CLASS_TABLESIZE / sizeof(uint32_t)); | ||
| 128 | memset(data, 0xFF, DR_COORD_DATASIZE); | ||
| 129 | |||
| 130 | info = (tableinfo_t) { | ||
| 131 | .solver = "coord data for DR", | ||
| 132 | .type = TABLETYPE_SPECIAL, | ||
| 133 | .infosize = INFOSIZE, | ||
| 134 | .fullsize = DR_COORD_DATASIZE, | ||
| 135 | .hash = 0, | ||
| 136 | .entries = DREOESEP_CLASSES + DREOESEP_MAX, | ||
| 137 | .classes = DREOESEP_CLASSES, | ||
| 138 | .bits = 32, | ||
| 139 | .base = 0, | ||
| 140 | .maxvalue = 0, | ||
| 141 | .next = 0 | ||
| 142 | }; | ||
| 143 | |||
| 144 | for (i = 0, n = 0; i < COMB_12_4 * POW_2_11; i++) { | ||
| 145 | if (classttrep[i] != 0xFFFFFFFF) | ||
| 146 | continue; | ||
| 147 | |||
| 148 | c = invcoord_dreoesep_nosym(i); | ||
| 149 | ii = coord_dreoesep_nosym(c); | ||
| 150 | for (t = 0, nasty = 0; t < NTRANS && !nasty; t++) { | ||
| 151 | if (!((UINT64_C(1) << t) & coordinate_dr.trans_mask)) | ||
| 152 | continue; | ||
| 153 | |||
| 154 | nasty = ii == coord_dreoesep_nosym(transform(c, t)); | ||
| 155 | } | ||
| 156 | |||
| 157 | for (t = 0; t < NTRANS; t++) { | ||
| 158 | if (!((UINT64_C(1) << t) & coordinate_dr.trans_mask)) | ||
| 159 | continue; | ||
| 160 | |||
| 161 | j = coord_dreoesep_nosym(transform(c, t)); | ||
| 162 | classttrep[j] = | ||
| 163 | (n << DR_CLASS_SHIFT) | | ||
| 164 | (nasty << DR_ISNASTY_SHIFT) | | ||
| 165 | (inverse_trans(t) << DR_TTREP_SHIFT); | ||
| 166 | } | ||
| 167 | rep[n++] = i; | ||
| 168 | } | ||
| 169 | |||
| 170 | writetableinfo(&info, DR_COORD_DATASIZE, data); | ||
| 171 | |||
| 172 | DBG_ASSERT(n == DREOESEP_CLASSES, 0, | ||
| 173 | "dr coordinate data: computed %" PRIu64 " classes, " | ||
| 174 | "expected %" PRIu64 "\n", n, DREOESEP_CLASSES); | ||
| 175 | |||
| 176 | coordinate_dr_gendata_returnsize: | ||
| 177 | return DR_COORD_DATASIZE; | ||
| 178 | } | ||
diff --git a/src/solvers/coord/eo.h b/src/solvers/coord/eo.h index ef9b27a..3fabf9f 100644 --- a/src/solvers/coord/eo.h +++ b/src/solvers/coord/eo.h | |||
| @@ -1,14 +1,16 @@ | |||
| 1 | STATIC uint64_t coordinate_eo_coord(cube_t, const void *); | 1 | STATIC uint64_t coordinate_eo_coord(cube_t, const void *); |
| 2 | STATIC cube_t coordinate_eo_cube(uint64_t, const void *); | 2 | STATIC cube_t coordinate_eo_cube(uint64_t, const void *); |
| 3 | STATIC bool coordinate_eo_isnasty(uint64_t, const void *); | ||
| 3 | STATIC uint64_t coordinate_eo_gendata(void *); | 4 | STATIC uint64_t coordinate_eo_gendata(void *); |
| 4 | 5 | ||
| 5 | STATIC coord_t coordinate_eo = { | 6 | STATIC coord_t coordinate_eo = { |
| 6 | .name = "EO", | 7 | .name = "EO", |
| 7 | .coord = &coordinate_eo_coord, | 8 | .coord = &coordinate_eo_coord, |
| 8 | .cube = &coordinate_eo_cube, | 9 | .cube = &coordinate_eo_cube, |
| 10 | .isnasty = &coordinate_eo_isnasty, | ||
| 9 | .gendata = coordinate_eo_gendata, | 11 | .gendata = coordinate_eo_gendata, |
| 10 | .max = POW_2_11, | 12 | .max = POW_2_11, |
| 11 | .trans_mask = TM_ALLTRANS, | 13 | .trans_mask = TM_SINGLE(TRANS_UFr), |
| 12 | .moves_mask = MM_ALLMOVES, | 14 | .moves_mask = MM_ALLMOVES, |
| 13 | .axistrans = { | 15 | .axistrans = { |
| 14 | [AXIS_UD] = TRANS_FDr, | 16 | [AXIS_UD] = TRANS_FDr, |
| @@ -32,6 +34,12 @@ coordinate_eo_cube(uint64_t c, const void *data) | |||
| 32 | return cube; | 34 | return cube; |
| 33 | } | 35 | } |
| 34 | 36 | ||
| 37 | STATIC bool | ||
| 38 | coordinate_eo_isnasty(uint64_t c, const void *data) | ||
| 39 | { | ||
| 40 | return false; | ||
| 41 | } | ||
| 42 | |||
| 35 | STATIC size_t | 43 | STATIC size_t |
| 36 | coordinate_eo_gendata(void *data) | 44 | coordinate_eo_gendata(void *data) |
| 37 | { | 45 | { |
diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h index ca058b0..5e40575 100644 --- a/src/solvers/coord/gendata.h +++ b/src/solvers/coord/gendata.h | |||
| @@ -2,6 +2,8 @@ STATIC size_t gendata_coord(const coord_t [static 1], void *); | |||
| 2 | STATIC int64_t gendata_coord_dispatch(const char *, void *); | 2 | STATIC int64_t gendata_coord_dispatch(const char *, void *); |
| 3 | STATIC tableinfo_t genptable_coord( | 3 | STATIC tableinfo_t genptable_coord( |
| 4 | const coord_t [static 1], const void *, uint8_t *); | 4 | const coord_t [static 1], const void *, uint8_t *); |
| 5 | STATIC uint64_t genptable_coord_fillneighbors( | ||
| 6 | const coord_t [static 1], const void *, uint64_t, uint8_t, uint8_t *); | ||
| 5 | STATIC void getdistribution_coord( | 7 | STATIC void getdistribution_coord( |
| 6 | const uint8_t *, const char *, uint64_t [static INFO_DISTRIBUTION_LEN]); | 8 | const uint8_t *, const char *, uint64_t [static INFO_DISTRIBUTION_LEN]); |
| 7 | STATIC uint8_t get_coord_pval( | 9 | STATIC uint8_t get_coord_pval( |
| @@ -81,10 +83,8 @@ genptable_coord( | |||
| 81 | uint8_t *table | 83 | uint8_t *table |
| 82 | ) | 84 | ) |
| 83 | { | 85 | { |
| 84 | uint64_t tablesize, i, j, d, tot; | 86 | uint64_t tablesize, i, d, tot, t; |
| 85 | tableinfo_t info; | 87 | tableinfo_t info; |
| 86 | uint8_t m; | ||
| 87 | cube_t c, cc; | ||
| 88 | 88 | ||
| 89 | tablesize = DIV_ROUND_UP(coord->max, 2); | 89 | tablesize = DIV_ROUND_UP(coord->max, 2); |
| 90 | 90 | ||
| @@ -113,24 +113,52 @@ genptable_coord( | |||
| 113 | for (d = 1, tot = 1; tot < coord->max; d++) { | 113 | for (d = 1, tot = 1; tot < coord->max; d++) { |
| 114 | for (i = 0; i < coord->max; i++) { | 114 | for (i = 0; i < coord->max; i++) { |
| 115 | if (get_coord_pval(coord, table, i) == d-1) { | 115 | if (get_coord_pval(coord, table, i) == d-1) { |
| 116 | c = coord->cube(i, data); | 116 | t = genptable_coord_fillneighbors( |
| 117 | for (m = 0; m < 18; m++) { | 117 | coord, data, i, d, table); |
| 118 | cc = move(c, m); | 118 | tot += t; |
| 119 | j = coord->coord(cc, data); | 119 | info.distribution[d] += t; |
| 120 | if (get_coord_pval(coord, table, j) > d) { | ||
| 121 | set_coord_pval(coord, table, j, d); | ||
| 122 | tot++; | ||
| 123 | info.distribution[d]++; | ||
| 124 | } | ||
| 125 | } | ||
| 126 | } | 120 | } |
| 127 | } | 121 | } |
| 122 | LOG("Depth %" PRIu64 ": %" PRIu64 " of %" PRIu64 "\n", | ||
| 123 | d, tot, coord->max); | ||
| 128 | } | 124 | } |
| 129 | info.maxvalue = d-1; | 125 | info.maxvalue = d-1; |
| 130 | 126 | ||
| 131 | return info; | 127 | return info; |
| 132 | } | 128 | } |
| 133 | 129 | ||
| 130 | STATIC uint64_t | ||
| 131 | genptable_coord_fillneighbors( | ||
| 132 | const coord_t coord[static 1], | ||
| 133 | const void *data, | ||
| 134 | uint64_t i, | ||
| 135 | uint8_t d, | ||
| 136 | uint8_t *table | ||
| 137 | ) | ||
| 138 | { | ||
| 139 | uint8_t m; | ||
| 140 | uint64_t j, t, tot; | ||
| 141 | cube_t c, moved; | ||
| 142 | |||
| 143 | c = coord->cube(i, data); | ||
| 144 | tot = 0; | ||
| 145 | for (m = 0; m < NMOVES; m++) { | ||
| 146 | moved = move(c, m); | ||
| 147 | for (t = 0; t < NTRANS; t++) { | ||
| 148 | if (!((UINT64_C(1) << t) & coord->trans_mask)) | ||
| 149 | continue; | ||
| 150 | |||
| 151 | j = coord->coord(transform(moved, t), data); | ||
| 152 | if (get_coord_pval(coord, table, j) > d) { | ||
| 153 | set_coord_pval(coord, table, j, d); | ||
| 154 | tot++; | ||
| 155 | } | ||
| 156 | } | ||
| 157 | } | ||
| 158 | |||
| 159 | return tot; | ||
| 160 | } | ||
| 161 | |||
| 134 | STATIC void | 162 | STATIC void |
| 135 | getdistribution_coord( | 163 | getdistribution_coord( |
| 136 | const uint8_t *table, | 164 | const uint8_t *table, |
diff --git a/src/solvers/coord/list.h b/src/solvers/coord/list.h index 32c94a4..7d43d45 100644 --- a/src/solvers/coord/list.h +++ b/src/solvers/coord/list.h | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | coord_t *all_coordinates[] = { | 1 | coord_t *all_coordinates[] = { |
| 2 | &coordinate_eo, | 2 | &coordinate_eo, |
| 3 | &coordinate_dr, | ||
| 3 | NULL | 4 | NULL |
| 4 | }; | 5 | }; |
diff --git a/src/solvers/coord/types_macros.h b/src/solvers/coord/types_macros.h index 9eaeca0..8741e27 100644 --- a/src/solvers/coord/types_macros.h +++ b/src/solvers/coord/types_macros.h | |||
| @@ -6,6 +6,7 @@ typedef struct { | |||
| 6 | const char name[255]; | 6 | const char name[255]; |
| 7 | uint64_t (*coord)(cube_t, const void *); | 7 | uint64_t (*coord)(cube_t, const void *); |
| 8 | cube_t (*cube)(uint64_t, const void *); | 8 | cube_t (*cube)(uint64_t, const void *); |
| 9 | bool (*isnasty)(uint64_t, const void *); | ||
| 9 | size_t (*gendata)(void *); | 10 | size_t (*gendata)(void *); |
| 10 | uint64_t max; | 11 | uint64_t max; |
| 11 | uint32_t moves_mask; | 12 | uint32_t moves_mask; |
diff --git a/src/utils/constants.h b/src/utils/constants.h index ef8c7e0..a6c6b7a 100644 --- a/src/utils/constants.h +++ b/src/utils/constants.h | |||
| @@ -106,6 +106,13 @@ STATIC int64_t binomial[12][12] = { | |||
| 106 | 106 | ||
| 107 | #define TM_ALLTRANS UINT64_C(0xFFFFFFFFFFFF) | 107 | #define TM_ALLTRANS UINT64_C(0xFFFFFFFFFFFF) |
| 108 | #define TM_SINGLE(t) (UINT64_C(1) << (uint64_t)(t)) | 108 | #define TM_SINGLE(t) (UINT64_C(1) << (uint64_t)(t)) |
| 109 | #define TM_UDFIX (\ | ||
| 110 | TM_SINGLE(TRANS_UFr) | TM_SINGLE(TRANS_UBr) | TM_SINGLE(TRANS_URr) | \ | ||
| 111 | TM_SINGLE(TRANS_ULr) | TM_SINGLE(TRANS_UFm) | TM_SINGLE(TRANS_UBm) | \ | ||
| 112 | TM_SINGLE(TRANS_URm) | TM_SINGLE(TRANS_ULm) | TM_SINGLE(TRANS_DFr) | \ | ||
| 113 | TM_SINGLE(TRANS_DBr) | TM_SINGLE(TRANS_DRr) | TM_SINGLE(TRANS_DLr) | \ | ||
| 114 | TM_SINGLE(TRANS_DFm) | TM_SINGLE(TRANS_DBm) | TM_SINGLE(TRANS_DRm) | \ | ||
| 115 | TM_SINGLE(TRANS_DLm)) | ||
| 109 | 116 | ||
| 110 | #define CORNER_UFR UINT8_C(0) | 117 | #define CORNER_UFR UINT8_C(0) |
| 111 | #define CORNER_UBL UINT8_C(1) | 118 | #define CORNER_UBL UINT8_C(1) |
diff --git a/test/121_coorddata_dr/00_all.in b/test/121_coorddata_dr/00_all.in new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/121_coorddata_dr/00_all.in | |||
diff --git a/test/121_coorddata_dr/00_all.out b/test/121_coorddata_dr/00_all.out new file mode 100644 index 0000000..d6109db --- /dev/null +++ b/test/121_coorddata_dr/00_all.out | |||
| @@ -0,0 +1 @@ | |||
| All good | |||
diff --git a/test/121_coorddata_dr/coorddata_dr.c b/test/121_coorddata_dr/coorddata_dr.c new file mode 100644 index 0000000..92e7c2a --- /dev/null +++ b/test/121_coorddata_dr/coorddata_dr.c | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | #include "../test.h" | ||
| 2 | |||
| 3 | #define POW_3_7 2187 | ||
| 4 | #define BOUND (64430 * POW_3_7 / 100) | ||
| 5 | #define TGROUP UINT64_C(4278190335) | ||
| 6 | |||
| 7 | cube_t transform(cube_t, uint8_t); | ||
| 8 | uint64_t coordinate_dr_coord(cube_t, const void *); | ||
| 9 | cube_t coordinate_dr_cube(uint64_t, const void *); | ||
| 10 | uint64_t coordinate_dr_gendata(void *); | ||
| 11 | |||
| 12 | void run(void) { | ||
| 13 | bool found; | ||
| 14 | uint64_t t; | ||
| 15 | char str[STRLENMAX]; | ||
| 16 | void *data; | ||
| 17 | size_t size; | ||
| 18 | cube_t cube; | ||
| 19 | uint64_t coord, coord2; | ||
| 20 | |||
| 21 | size = coordinate_dr_gendata(NULL); | ||
| 22 | data = malloc(size); | ||
| 23 | coordinate_dr_gendata(data); | ||
| 24 | |||
| 25 | /* Test all possible values for CO coordinate */ | ||
| 26 | for (coord = 0; coord < BOUND; coord++) { | ||
| 27 | cube = coordinate_dr_cube(coord, data); | ||
| 28 | |||
| 29 | if (!isconsistent(cube)) { | ||
| 30 | printf("Error: invcoord of %" PRId64 | ||
| 31 | " is not consistent\n", coord); | ||
| 32 | goto cleanup; | ||
| 33 | } | ||
| 34 | |||
| 35 | for (t = 0, found = false; t < 48; t++) { | ||
| 36 | if (!((UINT64_C(1) << t) & TGROUP)) | ||
| 37 | continue; | ||
| 38 | |||
| 39 | coord2 = coordinate_dr_coord(transform(cube, t), data); | ||
| 40 | if (coord == coord2) { | ||
| 41 | found = true; | ||
| 42 | break; | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | if (!found) { | ||
| 47 | printf("Error: invcoord of %" PRId64 " returns %" | ||
| 48 | PRId64 " with cube:\n", coord, coord2); | ||
| 49 | writecube("H48", cube, STRLENMAX, str); | ||
| 50 | printf("%s\n", str); | ||
| 51 | goto cleanup; | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 55 | printf("All good\n"); | ||
| 56 | |||
| 57 | cleanup: | ||
| 58 | free(data); | ||
| 59 | } | ||
diff --git a/test/test.h b/test/test.h index e753977..615402b 100644 --- a/test/test.h +++ b/test/test.h | |||
| @@ -26,7 +26,7 @@ bool isconsistent(cube_t); | |||
| 26 | bool issolvable(cube_t); | 26 | bool issolvable(cube_t); |
| 27 | bool issolved(cube_t); | 27 | bool issolved(cube_t); |
| 28 | cube_t readcube(char *, char *); | 28 | cube_t readcube(char *, char *); |
| 29 | int64_t writecube(char *, cube_t, size_t n, char [n]); | 29 | int64_t writecube(const char *, cube_t, size_t n, char [n]); |
| 30 | 30 | ||
| 31 | /* Test function to be implemented by all tests */ | 31 | /* Test function to be implemented by all tests */ |
| 32 | void run(void); | 32 | void run(void); |
