coordinate.h (1647B)
1 STATIC_INLINE uint64_t coord_h48( 2 cube_t, const uint32_t [static COCSEP_TABLESIZE], uint8_t); 3 STATIC_INLINE uint64_t coord_h48_edges(cube_t, uint64_t, uint8_t, uint8_t); 4 STATIC_INLINE cube_t invcoord_h48( 5 uint64_t, const cube_t [static COCSEP_CLASSES], uint8_t); 6 7 STATIC_INLINE uint64_t 8 coord_h48( 9 cube_t c, 10 const uint32_t cocsepdata[static COCSEP_TABLESIZE], 11 uint8_t h 12 ) 13 { 14 uint64_t cocsep, coclass; 15 uint32_t data; 16 uint8_t ttrep; 17 18 DBG_ASSERT(h <= 11, "coord_h48: h must be between 0 and 11\n"); 19 20 cocsep = coord_cocsep(c); 21 data = cocsepdata[cocsep]; 22 coclass = COCLASS(data); 23 ttrep = TTREP(data); 24 25 return coord_h48_edges(c, coclass, ttrep, h); 26 } 27 28 STATIC_INLINE uint64_t 29 coord_h48_edges(cube_t c, uint64_t coclass, uint8_t ttrep, uint8_t h) 30 { 31 cube_t d; 32 uint64_t esep, eo, edges; 33 34 d = transform_edges(c, ttrep); 35 esep = coord_esep(d); 36 eo = coord_eo(d); 37 edges = (esep << 11) + eo; 38 39 return (coclass * H48_ESIZE(11) + edges) >> (11 - (uint64_t)h); 40 } 41 42 /* 43 This function does not necessarily return a cube whose coordinate is 44 the given value, because it works up to symmetry. This means that the 45 returned cube is a transformed cube of one that gives the correct value. 46 */ 47 STATIC_INLINE cube_t 48 invcoord_h48( 49 uint64_t i, 50 const cube_t crep[static COCSEP_CLASSES], 51 uint8_t h 52 ) 53 { 54 cube_t ret; 55 uint64_t hh, coclass, ee, esep, eo; 56 57 DBG_ASSERT(h <= 11, "invcoord_h48: h must be between 0 and 11\n"); 58 59 hh = (uint64_t)h; 60 coclass = i / H48_ESIZE(h); 61 ee = i % H48_ESIZE(h); 62 esep = ee >> hh; 63 eo = (ee & ((1 << hh) - 1)) << (11 - hh); 64 65 ret = invcoord_esep(esep); 66 copy_corners(&ret, crep[coclass]); 67 set_eo(&ret, eo); 68 69 return ret; 70 }