From 83338a2f753ebbb7ba7b154cc60b2f427b6121b0 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Wed, 26 Mar 2025 19:22:50 +0100 Subject: Added inverse coordinate for CO this is necessary for DR coordinate --- src/arch/portable.h | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'src/arch/portable.h') diff --git a/src/arch/portable.h b/src/arch/portable.h index 4ac5fe7..56d3074 100644 --- a/src/arch/portable.h +++ b/src/arch/portable.h @@ -144,8 +144,7 @@ inverse(cube_t cube) STATIC_INLINE int64_t coord_co(cube_t c) { - int i, p; - int64_t ret; + int i, p, ret; for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3) ret += p * (c.corner[i] >> COSHIFT); @@ -153,6 +152,23 @@ coord_co(cube_t c) return ret; } +STATIC_INLINE cube_t +invcoord_co(int64_t coord) +{ + int64_t i, c, p; + cube_t cube; + + cube = SOLVED_CUBE; + for (i = 0, p = 0, c = coord; i < 7; i++, c /= 3) { + p += c % 3; + cube.corner[i] |= (c % 3) << COSHIFT; + } + + cube.corner[7] |= ((3 - (p % 3)) % 3) << COSHIFT; + + return cube; +} + /* For corner separation, we consider the axis (a.k.a. tetrad) each corner belongs to as 0 or 1 and we translate this sequence into binary. @@ -226,6 +242,17 @@ coord_esep(cube_t c) return ret1 * 70 + ret2; } +STATIC_INLINE cube_t +invcoord_esep(int64_t esep) +{ + cube_t ret; + + ret = SOLVED_CUBE; + invcoord_esep_array(esep % 70, esep / 70, ret.edge); + + return ret; +} + STATIC_INLINE void copy_corners(cube_t dest[static 1], cube_t src) { @@ -250,14 +277,3 @@ set_eo(cube_t cube[static 1], int64_t eo) } cube->edge[0] = (cube->edge[0] & ~EOBIT) | (EOBIT * (sum % 2)); } - -STATIC_INLINE cube_t -invcoord_esep(int64_t esep) -{ - cube_t ret; - - ret = SOLVED_CUBE; - invcoord_esep_array(esep % 70, esep / 70, ret.edge); - - return ret; -} -- cgit v1.3