diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-11-12 12:42:58 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-11-12 12:42:58 +0100 |
| commit | 66f99d367c21bee30d1fca2b4384065049a91edc (patch) | |
| tree | ddff1b62f5cf85034da7517bd19ec6ed8b06ad45 /src | |
| parent | 64bf37ea33e3878f30ced0f427a9a6c29f2b45be (diff) | |
| download | nissy-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.c | 74 |
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 | ||
| 153 | static Cube | 153 | static Cube |
| 154 | antindex_eofb(uint64_t ind) | 154 | antindex_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) | |||
| 165 | static Cube | 166 | static Cube |
| 166 | antindex_eofbepos(uint64_t ind) | 167 | antindex_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) | |||
| 197 | static Cube | 199 | static Cube |
| 198 | antindex_epud(uint64_t ind) | 200 | antindex_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) | |||
| 223 | static Cube | 226 | static Cube |
| 224 | antindex_coud(uint64_t ind) | 227 | antindex_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 | ||
| 229 | static Cube | 239 | static Cube |
| 230 | antindex_corners(uint64_t ind) | 240 | antindex_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 | ||
| 240 | static Cube | 252 | static Cube |
| 241 | antindex_cp(uint64_t ind) | 253 | antindex_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 | ||
| 250 | static Cube | 263 | static Cube |
| 251 | antindex_cphtr(uint64_t ind) | 264 | antindex_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 | ||
| 256 | static Cube | 274 | static Cube |
| 257 | antindex_cornershtr(uint64_t ind) | 275 | antindex_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 | ||
| 266 | static Cube | 285 | static Cube |
| 267 | antindex_cornershtrfin(uint64_t ind) | 286 | antindex_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 | ||
| 272 | static Cube | 296 | static Cube |
| 273 | antindex_drud(uint64_t ind) | 297 | antindex_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 | ||
| 287 | static Cube | 315 | static Cube |
| 288 | antindex_drud_eofb(uint64_t ind) | 316 | antindex_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 | ||
| 293 | static Cube | 322 | static Cube |
| 294 | antindex_htr_drud(uint64_t ind) | 323 | antindex_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) | |||
| 304 | static Cube | 335 | static Cube |
| 305 | antindex_htrfin(uint64_t ind) | 336 | antindex_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 | |||
| 320 | static uint64_t | 354 | static uint64_t |
| 321 | index_eofb(Cube cube) | 355 | index_eofb(Cube cube) |
| 322 | { | 356 | { |
