aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano.tronto@gmail.com>2021-11-12 12:42:58 +0100
committerSebastiano Tronto <sebastiano.tronto@gmail.com>2021-11-12 12:42:58 +0100
commit66f99d367c21bee30d1fca2b4384065049a91edc (patch)
treeddff1b62f5cf85034da7517bd19ec6ed8b06ad45 /src
parent64bf37ea33e3878f30ced0f427a9a6c29f2b45be (diff)
downloadnissy-66f99d367c21bee30d1fca2b4384065049a91edc.tar.gz
nissy-66f99d367c21bee30d1fca2b4384065049a91edc.zip
Some cleanup for antindeces; pointed out which return a consistent cube and which do not
Diffstat (limited to '')
-rw-r--r--src/coord.c74
1 files changed, 54 insertions, 20 deletions
diff --git a/src/coord.c b/src/coord.c
index a53dacc..7e691ef 100644
--- a/src/coord.c
+++ b/src/coord.c
@@ -148,11 +148,12 @@ coord_drud_eofb = {
148 .ntrans = 1, 148 .ntrans = 1,
149}; 149};
150 150
151/* Functions *****************************************************************/ 151/* Antindexers ***************************************************************/
152 152
153static Cube 153static Cube
154antindex_eofb(uint64_t ind) 154antindex_eofb(uint64_t ind)
155{ 155{
156 /* The returned cube is consistent */
156 Cube ret = {0}; 157 Cube ret = {0};
157 158
158 ret.eofb = ind; 159 ret.eofb = ind;
@@ -165,6 +166,7 @@ antindex_eofb(uint64_t ind)
165static Cube 166static Cube
166antindex_eofbepos(uint64_t ind) 167antindex_eofbepos(uint64_t ind)
167{ 168{
169 /* The returned cube is NOT consistent: eoud can be wrong */
168 Cube ret = {0}; 170 Cube ret = {0};
169 171
170 /* We need eorl for sym16 coordinate */ 172 /* We need eorl for sym16 coordinate */
@@ -197,6 +199,7 @@ antindex_eofbepos(uint64_t ind)
197static Cube 199static Cube
198antindex_epud(uint64_t ind) 200antindex_epud(uint64_t ind)
199{ 201{
202 /* The returned cube is consistent */
200 static bool initialized = false; 203 static bool initialized = false;
201 static Cube epud_aux[FACTORIAL8]; 204 static Cube epud_aux[FACTORIAL8];
202 int a[12]; 205 int a[12];
@@ -223,77 +226,105 @@ antindex_epud(uint64_t ind)
223static Cube 226static Cube
224antindex_coud(uint64_t ind) 227antindex_coud(uint64_t ind)
225{ 228{
226 return (Cube){ .coud = ind, .corl = ind, .cofb = ind }; 229 /* The returned cube is consistent */
230 Cube ret = {0};
231
232 ret.coud = ind;
233 ret.corl = ind;
234 ret.cofb = ind;
235
236 return ret;
227} 237}
228 238
229static Cube 239static Cube
230antindex_corners(uint64_t ind) 240antindex_corners(uint64_t ind)
231{ 241{
232 Cube c = {0}; 242 /* The returned cube is NOT consistent: corl and cofb can be wrong */
243 /* TODO: remember to make this consistent if I use this for symcoord */
244 Cube ret = {0};
233 245
234 c.coud = ind / FACTORIAL8; 246 ret.coud = ind / FACTORIAL8;
235 c.cp = ind % FACTORIAL8; 247 ret.cp = ind % FACTORIAL8;
236 248
237 return c; 249 return ret;
238} 250}
239 251
240static Cube 252static Cube
241antindex_cp(uint64_t ind) 253antindex_cp(uint64_t ind)
242{ 254{
243 Cube c = {0}; 255 /* The returned cube is NOT consistent: co can be wrong in all axes */
256 Cube ret = {0};
244 257
245 c.cp = ind; 258 ret.cp = ind;
246 259
247 return c; 260 return ret;
248} 261}
249 262
250static Cube 263static Cube
251antindex_cphtr(uint64_t ind) 264antindex_cphtr(uint64_t ind)
252{ 265{
253 return (Cube) { .cp = cphtr_right_rep[ind] }; 266 /* The returned cube is NOT consistent: co can be wrong in all axes */
267 Cube ret = {0};
268
269 ret.cp = cphtr_right_rep[ind];
270
271 return ret;
254} 272}
255 273
256static Cube 274static Cube
257antindex_cornershtr(uint64_t ind) 275antindex_cornershtr(uint64_t ind)
258{ 276{
259 Cube c = antindex_cphtr(ind % (BINOM8ON4 * 6)); 277 /* The returned cube is NOT consistent: corl and cofb can be wrong */
278 Cube ret = antindex_cphtr(ind % (BINOM8ON4 * 6));
260 279
261 c.coud = ind / (BINOM8ON4 * 6); 280 ret.coud = ind / (BINOM8ON4 * 6);
262 281
263 return c; 282 return ret;
264} 283}
265 284
266static Cube 285static Cube
267antindex_cornershtrfin(uint64_t ind) 286antindex_cornershtrfin(uint64_t ind)
268{ 287{
269 return (Cube){ .cp = cornershtrfin_ant[ind] }; 288 /* The returned cube is consistent */
289 Cube ret = {0};
290
291 ret.cp = cornershtrfin_ant[ind];
292
293 return ret;
270} 294}
271 295
272static Cube 296static Cube
273antindex_drud(uint64_t ind) 297antindex_drud(uint64_t ind)
274{ 298{
299 /* The returned cube is NOT consistent in the same way as eofbepos */
300 /* (see above). It works with sym16 coordinates */
275 uint64_t epos, eofb; 301 uint64_t epos, eofb;
276 Cube c; 302 Cube ret = {0};
277 303
278 eofb = ind % POW2TO11; 304 eofb = ind % POW2TO11;
279 epos = ind / (POW2TO11 * POW3TO7); 305 epos = ind / (POW2TO11 * POW3TO7);
280 c = antindex_eofbepos(eofb + POW2TO11 * epos); 306 ret = antindex_eofbepos(eofb + POW2TO11 * epos);
281 307
282 c.coud = (ind / POW2TO11) % POW3TO7; 308 ret.coud = (ind / POW2TO11) % POW3TO7;
309 ret.corl = ret.coud;
310 ret.cofb = ret.coud;
283 311
284 return c; 312 return ret;
285} 313}
286 314
287static Cube 315static Cube
288antindex_drud_eofb(uint64_t ind) 316antindex_drud_eofb(uint64_t ind)
289{ 317{
318 /* The returned cube is NOT consistent (see antindex_drud) */
290 return antindex_drud(ind * POW2TO11); 319 return antindex_drud(ind * POW2TO11);
291} 320}
292 321
293static Cube 322static Cube
294antindex_htr_drud(uint64_t ind) 323antindex_htr_drud(uint64_t ind)
295{ 324{
296 Cube ret; 325 /* The returned cube is NOT consistent: corl and cofb can be wrong */
326 /* (see cphtr) and eposm can be wrong too (not epose because dr). */
327 Cube ret = {0};
297 328
298 ret = antindex_cphtr(ind / BINOM8ON4); 329 ret = antindex_cphtr(ind / BINOM8ON4);
299 ret.eposs = (ind % BINOM8ON4) * FACTORIAL4; 330 ret.eposs = (ind % BINOM8ON4) * FACTORIAL4;
@@ -304,7 +335,8 @@ antindex_htr_drud(uint64_t ind)
304static Cube 335static Cube
305antindex_htrfin(uint64_t ind) 336antindex_htrfin(uint64_t ind)
306{ 337{
307 Cube ret; 338 /* The returned cube is consistent */
339 Cube ret = {0};
308 340
309 ret = antindex_cornershtrfin(ind/(24*24*24)); 341 ret = antindex_cornershtrfin(ind/(24*24*24));
310 342
@@ -317,6 +349,8 @@ antindex_htrfin(uint64_t ind)
317 return ret; 349 return ret;
318} 350}
319 351
352/* Indexers ******************************************************************/
353
320static uint64_t 354static uint64_t
321index_eofb(Cube cube) 355index_eofb(Cube cube)
322{ 356{

Generated with cgit - Back to sebastiano.tronto.net