diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-08-18 14:26:45 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-08-18 14:26:45 +0200 |
| commit | 18c9a8b8905304cf5f8fc15825769046a3144866 (patch) | |
| tree | a7807bb32b0a5d9ded7d3cedccc598f64a9b00fe /src/solvers/h48/coordinate.h | |
| parent | f25a10e19eca294c4e6a99e4f80ce5cfd11a0e5f (diff) | |
| download | nissy-core-18c9a8b8905304cf5f8fc15825769046a3144866.tar.gz nissy-core-18c9a8b8905304cf5f8fc15825769046a3144866.zip | |
Reorganized folder structure
Diffstat (limited to 'src/solvers/h48/coordinate.h')
| -rw-r--r-- | src/solvers/h48/coordinate.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/solvers/h48/coordinate.h b/src/solvers/h48/coordinate.h new file mode 100644 index 0000000..47b805d --- /dev/null +++ b/src/solvers/h48/coordinate.h | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | #define H48_ESIZE(h) ((_12c4 * _8c4) << (int64_t)(h)) | ||
| 2 | |||
| 3 | #define COCLASS_MASK (UINT32_C(0xFFFF) << UINT32_C(16)) | ||
| 4 | #define COCLASS(x) (((x) & COCLASS_MASK) >> UINT32_C(16)) | ||
| 5 | #define TTREP_MASK (UINT32_C(0xFF) << UINT32_C(8)) | ||
| 6 | #define TTREP(x) (((x) & TTREP_MASK) >> UINT32_C(8)) | ||
| 7 | |||
| 8 | _static_inline int64_t coord_h48(cube_t, const uint32_t *, uint8_t); | ||
| 9 | _static_inline int64_t coord_h48_edges(cube_t, int64_t, uint8_t, uint8_t); | ||
| 10 | _static_inline cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); | ||
| 11 | |||
| 12 | _static_inline int64_t | ||
| 13 | coord_h48(cube_t c, const uint32_t *cocsepdata, uint8_t h) | ||
| 14 | { | ||
| 15 | int64_t cocsep, coclass; | ||
| 16 | uint32_t data; | ||
| 17 | uint8_t ttrep; | ||
| 18 | |||
| 19 | DBG_ASSERT(h <= 11, -1, "coord_h48: h must be between 0 and 11\n"); | ||
| 20 | |||
| 21 | cocsep = coord_cocsep(c); | ||
| 22 | data = cocsepdata[cocsep]; | ||
| 23 | coclass = (int64_t)COCLASS(data); | ||
| 24 | ttrep = (int64_t)TTREP(data); | ||
| 25 | |||
| 26 | return coord_h48_edges(c, coclass, ttrep, h); | ||
| 27 | } | ||
| 28 | |||
| 29 | _static_inline int64_t | ||
| 30 | coord_h48_edges(cube_t c, int64_t coclass, uint8_t ttrep, uint8_t h) | ||
| 31 | { | ||
| 32 | cube_t d; | ||
| 33 | int64_t esep, eo, edges; | ||
| 34 | |||
| 35 | d = transform_edges(c, ttrep); | ||
| 36 | esep = coord_esep(d); | ||
| 37 | eo = coord_eo(d); | ||
| 38 | edges = (esep << 11) + eo; | ||
| 39 | |||
| 40 | return (coclass * H48_ESIZE(11) + edges) >> (11 - (int64_t)h); | ||
| 41 | } | ||
| 42 | |||
| 43 | /* | ||
| 44 | This function does not necessarily return a cube whose coordinate is | ||
| 45 | the given value, because it works up to symmetry. This means that the | ||
| 46 | returned cube is a transformed cube of one that gives the correct value. | ||
| 47 | */ | ||
| 48 | _static_inline cube_t | ||
| 49 | invcoord_h48(int64_t i, const cube_t *crep, uint8_t h) | ||
| 50 | { | ||
| 51 | cube_t ret; | ||
| 52 | int64_t hh, coclass, ee, esep, eo; | ||
| 53 | |||
| 54 | DBG_ASSERT(h <= 11, zero, | ||
| 55 | "invcoord_h48: h must be between 0 and 11\n"); | ||
| 56 | |||
| 57 | hh = (int64_t)h; | ||
| 58 | coclass = i / H48_ESIZE(h); | ||
| 59 | ee = i % H48_ESIZE(h); | ||
| 60 | esep = ee >> hh; | ||
| 61 | eo = (ee & ((1 << hh) - 1)) << (11 - hh); | ||
| 62 | |||
| 63 | ret = invcoord_esep(esep); | ||
| 64 | copy_corners(&ret, crep[coclass]); | ||
| 65 | set_eo(&ret, eo); | ||
| 66 | |||
| 67 | return ret; | ||
| 68 | } | ||
