diff options
| -rw-r--r-- | TODO.txt | 4 | ||||
| -rw-r--r-- | cube.c | 1081 | ||||
| -rw-r--r-- | test/061_coord_eo/00_solved.in (renamed from old/061_coord_eo/00_solved.in) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/00_solved.out (renamed from old/061_coord_eo/00_solved.out) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/01_U.in (renamed from old/061_coord_eo/01_U.in) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/01_U.out (renamed from old/061_coord_eo/01_U.out) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/02_U2.in (renamed from old/061_coord_eo/02_U2.in) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/02_U2.out (renamed from old/061_coord_eo/02_U2.out) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/03_U3.in (renamed from old/061_coord_eo/03_U3.in) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/03_U3.out (renamed from old/061_coord_eo/03_U3.out) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/04_D.in (renamed from old/061_coord_eo/04_D.in) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/04_D.out (renamed from old/061_coord_eo/04_D.out) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/07_R.in (renamed from old/061_coord_eo/07_R.in) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/07_R.out (renamed from old/061_coord_eo/07_R.out) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/08_R2.in (renamed from old/061_coord_eo/08_R2.in) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/08_R2.out (renamed from old/061_coord_eo/08_R2.out) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/10_L.in (renamed from old/061_coord_eo/10_L.in) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/10_L.out (renamed from old/061_coord_eo/10_L.out) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/13_F.in (renamed from old/061_coord_eo/13_F.in) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/13_F.out (renamed from old/061_coord_eo/13_F.out) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/14_F2.in (renamed from old/061_coord_eo/14_F2.in) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/14_F2.out (renamed from old/061_coord_eo/14_F2.out) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/15_F3.in (renamed from old/061_coord_eo/15_F3.in) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/15_F3.out (renamed from old/061_coord_eo/15_F3.out) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/16_B.in (renamed from old/061_coord_eo/16_B.in) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/16_B.out (renamed from old/061_coord_eo/16_B.out) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/17_B2.in (renamed from old/061_coord_eo/17_B2.in) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/17_B2.out (renamed from old/061_coord_eo/17_B2.out) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/18_B3.in (renamed from old/061_coord_eo/18_B3.in) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/18_B3.out (renamed from old/061_coord_eo/18_B3.out) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/20_scrambled.in (renamed from old/061_coord_eo/20_scrambled.in) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/20_scrambled.out (renamed from old/061_coord_eo/20_scrambled.out) | 0 | ||||
| -rw-r--r-- | test/061_coord_eo/coord_eo_tests.c (renamed from old/061_coord_eo/coord_eo_tests.c) | 9 | ||||
| -rw-r--r-- | test/070_solve_simple/01_U_U3.in (renamed from test/060_solve_simple/01_U_U3.in) | 0 | ||||
| -rw-r--r-- | test/070_solve_simple/01_U_U3.out (renamed from test/060_solve_simple/01_U_U3.out) | 0 | ||||
| -rw-r--r-- | test/070_solve_simple/02_MUMU_alloptimal.in (renamed from test/060_solve_simple/02_MUMU_alloptimal.in) | 0 | ||||
| -rw-r--r-- | test/070_solve_simple/02_MUMU_alloptimal.out (renamed from test/060_solve_simple/02_MUMU_alloptimal.out) | 0 | ||||
| -rw-r--r-- | test/070_solve_simple/solve_simple_tests.c (renamed from test/060_solve_simple/solve_simple_tests.c) | 0 | ||||
| -rw-r--r-- | test/test.h | 7 |
39 files changed, 579 insertions, 522 deletions
| @@ -19,6 +19,10 @@ See the sections below for details | |||
| 19 | * Rename to libnissy | 19 | * Rename to libnissy |
| 20 | * Release 1.0 | 20 | * Release 1.0 |
| 21 | 21 | ||
| 22 | ## Small change | ||
| 23 | |||
| 24 | * add lots of tests for things that were static, now visible | ||
| 25 | |||
| 22 | ## Solving | 26 | ## Solving |
| 23 | 27 | ||
| 24 | ### Simple (slow, light) solver | 28 | ### Simple (slow, light) solver |
| @@ -8,6 +8,8 @@ | |||
| 8 | 8 | ||
| 9 | #ifdef DEBUG | 9 | #ifdef DEBUG |
| 10 | #include <stdio.h> | 10 | #include <stdio.h> |
| 11 | #define _static | ||
| 12 | #define _static_inline | ||
| 11 | #define DBG_LOG(...) fprintf(stderr, __VA_ARGS__) | 13 | #define DBG_LOG(...) fprintf(stderr, __VA_ARGS__) |
| 12 | #define DBG_WARN(condition, ...) if (!(condition)) DBG_LOG(__VA_ARGS__); | 14 | #define DBG_WARN(condition, ...) if (!(condition)) DBG_LOG(__VA_ARGS__); |
| 13 | #define DBG_ASSERT(condition, retval, ...) \ | 15 | #define DBG_ASSERT(condition, retval, ...) \ |
| @@ -16,6 +18,8 @@ | |||
| 16 | return retval; \ | 18 | return retval; \ |
| 17 | } | 19 | } |
| 18 | #else | 20 | #else |
| 21 | #define _static static | ||
| 22 | #define _static_inline static inline | ||
| 19 | #define DBG_LOG(...) | 23 | #define DBG_LOG(...) |
| 20 | #define DBG_WARN(condition, ...) | 24 | #define DBG_WARN(condition, ...) |
| 21 | #define DBG_ASSERT(condition, retval, ...) | 25 | #define DBG_ASSERT(condition, retval, ...) |
| @@ -130,7 +134,7 @@ Section: constants, strings and other stuff | |||
| 130 | #define _eflip 0x10U | 134 | #define _eflip 0x10U |
| 131 | #define _error 0xFFU | 135 | #define _error 0xFFU |
| 132 | 136 | ||
| 133 | static char *cornerstr[] = { | 137 | _static char *cornerstr[] = { |
| 134 | [_c_ufr] = "UFR", | 138 | [_c_ufr] = "UFR", |
| 135 | [_c_ubl] = "UBL", | 139 | [_c_ubl] = "UBL", |
| 136 | [_c_dfl] = "DFL", | 140 | [_c_dfl] = "DFL", |
| @@ -141,7 +145,7 @@ static char *cornerstr[] = { | |||
| 141 | [_c_dbl] = "DBL" | 145 | [_c_dbl] = "DBL" |
| 142 | }; | 146 | }; |
| 143 | 147 | ||
| 144 | static char *cornerstralt[] = { | 148 | _static char *cornerstralt[] = { |
| 145 | [_c_ufr] = "URF", | 149 | [_c_ufr] = "URF", |
| 146 | [_c_ubl] = "ULB", | 150 | [_c_ubl] = "ULB", |
| 147 | [_c_dfl] = "DLF", | 151 | [_c_dfl] = "DLF", |
| @@ -152,7 +156,7 @@ static char *cornerstralt[] = { | |||
| 152 | [_c_dbl] = "DLB" | 156 | [_c_dbl] = "DLB" |
| 153 | }; | 157 | }; |
| 154 | 158 | ||
| 155 | static char *edgestr[] = { | 159 | _static char *edgestr[] = { |
| 156 | [_e_uf] = "UF", | 160 | [_e_uf] = "UF", |
| 157 | [_e_ub] = "UB", | 161 | [_e_ub] = "UB", |
| 158 | [_e_db] = "DB", | 162 | [_e_db] = "DB", |
| @@ -167,7 +171,7 @@ static char *edgestr[] = { | |||
| 167 | [_e_br] = "BR" | 171 | [_e_br] = "BR" |
| 168 | }; | 172 | }; |
| 169 | 173 | ||
| 170 | static char *movestr[] = { | 174 | _static char *movestr[] = { |
| 171 | [U] = "U", | 175 | [U] = "U", |
| 172 | [U2] = "U2", | 176 | [U2] = "U2", |
| 173 | [U3] = "U'", | 177 | [U3] = "U'", |
| @@ -188,7 +192,7 @@ static char *movestr[] = { | |||
| 188 | [B3] = "B'", | 192 | [B3] = "B'", |
| 189 | }; | 193 | }; |
| 190 | 194 | ||
| 191 | static char *transstr[] = { | 195 | _static char *transstr[] = { |
| 192 | [UFr] = "rotation UF", | 196 | [UFr] = "rotation UF", |
| 193 | [UFm] = "mirrored UF", | 197 | [UFm] = "mirrored UF", |
| 194 | [ULr] = "rotation UL", | 198 | [ULr] = "rotation UL", |
| @@ -252,7 +256,6 @@ Note: the #ifdef below is closed in the next section. | |||
| 252 | 256 | ||
| 253 | typedef __m256i cube_fast_t; | 257 | typedef __m256i cube_fast_t; |
| 254 | 258 | ||
| 255 | #define _co_avx2 _mm256_set_epi64x(0, 0, 0, 0xF0F0F0F0F0F0F0F0) | ||
| 256 | #define _co2_avx2 _mm256_set_epi64x(0, 0, 0, 0x6060606060606060) | 259 | #define _co2_avx2 _mm256_set_epi64x(0, 0, 0, 0x6060606060606060) |
| 257 | #define _cocw_avx2 _mm256_set_epi64x(0, 0, 0, 0x2020202020202020) | 260 | #define _cocw_avx2 _mm256_set_epi64x(0, 0, 0, 0x2020202020202020) |
| 258 | #define _eo_avx2 _mm256_set_epi64x(0x10101010, 0x1010101010101010, 0, 0) | 261 | #define _eo_avx2 _mm256_set_epi64x(0x10101010, 0x1010101010101010, 0, 0) |
| @@ -262,14 +265,17 @@ typedef __m256i cube_fast_t; | |||
| 262 | 0, 0, 0, 0, 0, 0, 0, 0, 7, 6, 5, 4, 3, 2, 1, 0 \ | 265 | 0, 0, 0, 0, 0, 0, 0, 0, 7, 6, 5, 4, 3, 2, 1, 0 \ |
| 263 | ) | 266 | ) |
| 264 | 267 | ||
| 265 | static cube_fast_t cubetofast(cube_t); | 268 | _static cube_fast_t cubetofast(cube_t); |
| 266 | static cube_t fasttocube(cube_fast_t); | 269 | _static cube_t fasttocube(cube_fast_t); |
| 267 | static inline bool equal_fast(cube_fast_t, cube_fast_t); | 270 | _static_inline bool equal_fast(cube_fast_t, cube_fast_t); |
| 268 | static inline cube_fast_t invertco_fast(cube_fast_t); | 271 | _static_inline bool issolved_fast(cube_fast_t); |
| 269 | static inline cube_fast_t inverse_fast(cube_fast_t); | 272 | _static_inline cube_fast_t invertco_fast(cube_fast_t); |
| 270 | static inline cube_fast_t compose_fast(cube_fast_t, cube_fast_t); | 273 | _static_inline cube_fast_t cleanaftershuffle(cube_fast_t); |
| 274 | _static_inline cube_fast_t inverse_fast(cube_fast_t); | ||
| 275 | _static_inline cube_fast_t compose_fast(cube_fast_t, cube_fast_t); | ||
| 276 | _static_inline int64_t coord_fast_eo(cube_fast_t); | ||
| 271 | 277 | ||
| 272 | static inline cube_fast_t | 278 | _static_inline cube_fast_t |
| 273 | _move_U(cube_fast_t c) | 279 | _move_U(cube_fast_t c) |
| 274 | { | 280 | { |
| 275 | cube_fast_t m = _mm256_set_epi8( | 281 | cube_fast_t m = _mm256_set_epi8( |
| @@ -280,7 +286,7 @@ _move_U(cube_fast_t c) | |||
| 280 | return compose_fast(c, m); | 286 | return compose_fast(c, m); |
| 281 | } | 287 | } |
| 282 | 288 | ||
| 283 | static inline cube_fast_t | 289 | _static_inline cube_fast_t |
| 284 | _move_U2(cube_fast_t c) | 290 | _move_U2(cube_fast_t c) |
| 285 | { | 291 | { |
| 286 | cube_fast_t m = _mm256_set_epi8( | 292 | cube_fast_t m = _mm256_set_epi8( |
| @@ -291,7 +297,7 @@ _move_U2(cube_fast_t c) | |||
| 291 | return compose_fast(c, m); | 297 | return compose_fast(c, m); |
| 292 | } | 298 | } |
| 293 | 299 | ||
| 294 | static inline cube_fast_t | 300 | _static_inline cube_fast_t |
| 295 | _move_U3(cube_fast_t c) | 301 | _move_U3(cube_fast_t c) |
| 296 | { | 302 | { |
| 297 | cube_fast_t m = _mm256_set_epi8( | 303 | cube_fast_t m = _mm256_set_epi8( |
| @@ -302,7 +308,7 @@ _move_U3(cube_fast_t c) | |||
| 302 | return compose_fast(c, m); | 308 | return compose_fast(c, m); |
| 303 | } | 309 | } |
| 304 | 310 | ||
| 305 | static inline cube_fast_t | 311 | _static_inline cube_fast_t |
| 306 | _move_D(cube_fast_t c) | 312 | _move_D(cube_fast_t c) |
| 307 | { | 313 | { |
| 308 | cube_fast_t m = _mm256_set_epi8( | 314 | cube_fast_t m = _mm256_set_epi8( |
| @@ -313,7 +319,7 @@ _move_D(cube_fast_t c) | |||
| 313 | return compose_fast(c, m); | 319 | return compose_fast(c, m); |
| 314 | } | 320 | } |
| 315 | 321 | ||
| 316 | static inline cube_fast_t | 322 | _static_inline cube_fast_t |
| 317 | _move_D2(cube_fast_t c) | 323 | _move_D2(cube_fast_t c) |
| 318 | { | 324 | { |
| 319 | cube_fast_t m = _mm256_set_epi8( | 325 | cube_fast_t m = _mm256_set_epi8( |
| @@ -324,7 +330,7 @@ _move_D2(cube_fast_t c) | |||
| 324 | return compose_fast(c, m); | 330 | return compose_fast(c, m); |
| 325 | } | 331 | } |
| 326 | 332 | ||
| 327 | static inline cube_fast_t | 333 | _static_inline cube_fast_t |
| 328 | _move_D3(cube_fast_t c) | 334 | _move_D3(cube_fast_t c) |
| 329 | { | 335 | { |
| 330 | cube_fast_t m = _mm256_set_epi8( | 336 | cube_fast_t m = _mm256_set_epi8( |
| @@ -335,7 +341,7 @@ _move_D3(cube_fast_t c) | |||
| 335 | return compose_fast(c, m); | 341 | return compose_fast(c, m); |
| 336 | } | 342 | } |
| 337 | 343 | ||
| 338 | static inline cube_fast_t | 344 | _static_inline cube_fast_t |
| 339 | _move_R(cube_fast_t c) | 345 | _move_R(cube_fast_t c) |
| 340 | { | 346 | { |
| 341 | cube_fast_t m = _mm256_set_epi8( | 347 | cube_fast_t m = _mm256_set_epi8( |
| @@ -346,7 +352,7 @@ _move_R(cube_fast_t c) | |||
| 346 | return compose_fast(c, m); | 352 | return compose_fast(c, m); |
| 347 | } | 353 | } |
| 348 | 354 | ||
| 349 | static inline cube_fast_t | 355 | _static_inline cube_fast_t |
| 350 | _move_R2(cube_fast_t c) | 356 | _move_R2(cube_fast_t c) |
| 351 | { | 357 | { |
| 352 | cube_fast_t m = _mm256_set_epi8( | 358 | cube_fast_t m = _mm256_set_epi8( |
| @@ -357,7 +363,7 @@ _move_R2(cube_fast_t c) | |||
| 357 | return compose_fast(c, m); | 363 | return compose_fast(c, m); |
| 358 | } | 364 | } |
| 359 | 365 | ||
| 360 | static inline cube_fast_t | 366 | _static_inline cube_fast_t |
| 361 | _move_R3(cube_fast_t c) | 367 | _move_R3(cube_fast_t c) |
| 362 | { | 368 | { |
| 363 | cube_fast_t m = _mm256_set_epi8( | 369 | cube_fast_t m = _mm256_set_epi8( |
| @@ -368,7 +374,7 @@ _move_R3(cube_fast_t c) | |||
| 368 | return compose_fast(c, m); | 374 | return compose_fast(c, m); |
| 369 | } | 375 | } |
| 370 | 376 | ||
| 371 | static inline cube_fast_t | 377 | _static_inline cube_fast_t |
| 372 | _move_L(cube_fast_t c) | 378 | _move_L(cube_fast_t c) |
| 373 | { | 379 | { |
| 374 | cube_fast_t m = _mm256_set_epi8( | 380 | cube_fast_t m = _mm256_set_epi8( |
| @@ -379,7 +385,7 @@ _move_L(cube_fast_t c) | |||
| 379 | return compose_fast(c, m); | 385 | return compose_fast(c, m); |
| 380 | } | 386 | } |
| 381 | 387 | ||
| 382 | static inline cube_fast_t | 388 | _static_inline cube_fast_t |
| 383 | _move_L2(cube_fast_t c) | 389 | _move_L2(cube_fast_t c) |
| 384 | { | 390 | { |
| 385 | cube_fast_t m = _mm256_set_epi8( | 391 | cube_fast_t m = _mm256_set_epi8( |
| @@ -390,7 +396,7 @@ _move_L2(cube_fast_t c) | |||
| 390 | return compose_fast(c, m); | 396 | return compose_fast(c, m); |
| 391 | } | 397 | } |
| 392 | 398 | ||
| 393 | static inline cube_fast_t | 399 | _static_inline cube_fast_t |
| 394 | _move_L3(cube_fast_t c) | 400 | _move_L3(cube_fast_t c) |
| 395 | { | 401 | { |
| 396 | cube_fast_t m = _mm256_set_epi8( | 402 | cube_fast_t m = _mm256_set_epi8( |
| @@ -401,7 +407,7 @@ _move_L3(cube_fast_t c) | |||
| 401 | return compose_fast(c, m); | 407 | return compose_fast(c, m); |
| 402 | } | 408 | } |
| 403 | 409 | ||
| 404 | static inline cube_fast_t | 410 | _static_inline cube_fast_t |
| 405 | _move_F(cube_fast_t c) | 411 | _move_F(cube_fast_t c) |
| 406 | { | 412 | { |
| 407 | cube_fast_t m = _mm256_set_epi8( | 413 | cube_fast_t m = _mm256_set_epi8( |
| @@ -412,7 +418,7 @@ _move_F(cube_fast_t c) | |||
| 412 | return compose_fast(c, m); | 418 | return compose_fast(c, m); |
| 413 | } | 419 | } |
| 414 | 420 | ||
| 415 | static inline cube_fast_t | 421 | _static_inline cube_fast_t |
| 416 | _move_F2(cube_fast_t c) | 422 | _move_F2(cube_fast_t c) |
| 417 | { | 423 | { |
| 418 | cube_fast_t m = _mm256_set_epi8( | 424 | cube_fast_t m = _mm256_set_epi8( |
| @@ -423,7 +429,7 @@ _move_F2(cube_fast_t c) | |||
| 423 | return compose_fast(c, m); | 429 | return compose_fast(c, m); |
| 424 | } | 430 | } |
| 425 | 431 | ||
| 426 | static inline cube_fast_t | 432 | _static_inline cube_fast_t |
| 427 | _move_F3(cube_fast_t c) | 433 | _move_F3(cube_fast_t c) |
| 428 | { | 434 | { |
| 429 | cube_fast_t m = _mm256_set_epi8( | 435 | cube_fast_t m = _mm256_set_epi8( |
| @@ -434,7 +440,7 @@ _move_F3(cube_fast_t c) | |||
| 434 | return compose_fast(c, m); | 440 | return compose_fast(c, m); |
| 435 | } | 441 | } |
| 436 | 442 | ||
| 437 | static inline cube_fast_t | 443 | _static_inline cube_fast_t |
| 438 | _move_B(cube_fast_t c) | 444 | _move_B(cube_fast_t c) |
| 439 | { | 445 | { |
| 440 | cube_fast_t m = _mm256_set_epi8( | 446 | cube_fast_t m = _mm256_set_epi8( |
| @@ -445,7 +451,7 @@ _move_B(cube_fast_t c) | |||
| 445 | return compose_fast(c, m); | 451 | return compose_fast(c, m); |
| 446 | } | 452 | } |
| 447 | 453 | ||
| 448 | static inline cube_fast_t | 454 | _static_inline cube_fast_t |
| 449 | _move_B2(cube_fast_t c) | 455 | _move_B2(cube_fast_t c) |
| 450 | { | 456 | { |
| 451 | cube_fast_t m = _mm256_set_epi8( | 457 | cube_fast_t m = _mm256_set_epi8( |
| @@ -456,7 +462,7 @@ _move_B2(cube_fast_t c) | |||
| 456 | return compose_fast(c, m); | 462 | return compose_fast(c, m); |
| 457 | } | 463 | } |
| 458 | 464 | ||
| 459 | static inline cube_fast_t | 465 | _static_inline cube_fast_t |
| 460 | _move_B3(cube_fast_t c) | 466 | _move_B3(cube_fast_t c) |
| 461 | { | 467 | { |
| 462 | cube_fast_t m = _mm256_set_epi8( | 468 | cube_fast_t m = _mm256_set_epi8( |
| @@ -467,7 +473,7 @@ _move_B3(cube_fast_t c) | |||
| 467 | return compose_fast(c, m); | 473 | return compose_fast(c, m); |
| 468 | } | 474 | } |
| 469 | 475 | ||
| 470 | static inline cube_fast_t | 476 | _static_inline cube_fast_t |
| 471 | _trans_UFr(cube_fast_t c) | 477 | _trans_UFr(cube_fast_t c) |
| 472 | { | 478 | { |
| 473 | cube_fast_t ret; | 479 | cube_fast_t ret; |
| @@ -487,7 +493,7 @@ _trans_UFr(cube_fast_t c) | |||
| 487 | return ret; | 493 | return ret; |
| 488 | } | 494 | } |
| 489 | 495 | ||
| 490 | static inline cube_fast_t | 496 | _static_inline cube_fast_t |
| 491 | _trans_ULr(cube_fast_t c) | 497 | _trans_ULr(cube_fast_t c) |
| 492 | { | 498 | { |
| 493 | cube_fast_t ret; | 499 | cube_fast_t ret; |
| @@ -507,7 +513,7 @@ _trans_ULr(cube_fast_t c) | |||
| 507 | return ret; | 513 | return ret; |
| 508 | } | 514 | } |
| 509 | 515 | ||
| 510 | static inline cube_fast_t | 516 | _static_inline cube_fast_t |
| 511 | _trans_UBr(cube_fast_t c) | 517 | _trans_UBr(cube_fast_t c) |
| 512 | { | 518 | { |
| 513 | cube_fast_t ret; | 519 | cube_fast_t ret; |
| @@ -527,7 +533,7 @@ _trans_UBr(cube_fast_t c) | |||
| 527 | return ret; | 533 | return ret; |
| 528 | } | 534 | } |
| 529 | 535 | ||
| 530 | static inline cube_fast_t | 536 | _static_inline cube_fast_t |
| 531 | _trans_URr(cube_fast_t c) | 537 | _trans_URr(cube_fast_t c) |
| 532 | { | 538 | { |
| 533 | cube_fast_t ret; | 539 | cube_fast_t ret; |
| @@ -547,7 +553,7 @@ _trans_URr(cube_fast_t c) | |||
| 547 | return ret; | 553 | return ret; |
| 548 | } | 554 | } |
| 549 | 555 | ||
| 550 | static inline cube_fast_t | 556 | _static_inline cube_fast_t |
| 551 | _trans_DFr(cube_fast_t c) | 557 | _trans_DFr(cube_fast_t c) |
| 552 | { | 558 | { |
| 553 | cube_fast_t ret; | 559 | cube_fast_t ret; |
| @@ -567,7 +573,7 @@ _trans_DFr(cube_fast_t c) | |||
| 567 | return ret; | 573 | return ret; |
| 568 | } | 574 | } |
| 569 | 575 | ||
| 570 | static inline cube_fast_t | 576 | _static_inline cube_fast_t |
| 571 | _trans_DLr(cube_fast_t c) | 577 | _trans_DLr(cube_fast_t c) |
| 572 | { | 578 | { |
| 573 | cube_fast_t ret; | 579 | cube_fast_t ret; |
| @@ -587,7 +593,7 @@ _trans_DLr(cube_fast_t c) | |||
| 587 | return ret; | 593 | return ret; |
| 588 | } | 594 | } |
| 589 | 595 | ||
| 590 | static inline cube_fast_t | 596 | _static_inline cube_fast_t |
| 591 | _trans_DBr(cube_fast_t c) | 597 | _trans_DBr(cube_fast_t c) |
| 592 | { | 598 | { |
| 593 | cube_fast_t ret; | 599 | cube_fast_t ret; |
| @@ -607,7 +613,7 @@ _trans_DBr(cube_fast_t c) | |||
| 607 | return ret; | 613 | return ret; |
| 608 | } | 614 | } |
| 609 | 615 | ||
| 610 | static inline cube_fast_t | 616 | _static_inline cube_fast_t |
| 611 | _trans_DRr(cube_fast_t c) | 617 | _trans_DRr(cube_fast_t c) |
| 612 | { | 618 | { |
| 613 | cube_fast_t ret; | 619 | cube_fast_t ret; |
| @@ -627,7 +633,7 @@ _trans_DRr(cube_fast_t c) | |||
| 627 | return ret; | 633 | return ret; |
| 628 | } | 634 | } |
| 629 | 635 | ||
| 630 | static inline cube_fast_t | 636 | _static_inline cube_fast_t |
| 631 | _trans_RUr(cube_fast_t c) | 637 | _trans_RUr(cube_fast_t c) |
| 632 | { | 638 | { |
| 633 | cube_fast_t ret; | 639 | cube_fast_t ret; |
| @@ -647,7 +653,7 @@ _trans_RUr(cube_fast_t c) | |||
| 647 | return ret; | 653 | return ret; |
| 648 | } | 654 | } |
| 649 | 655 | ||
| 650 | static inline cube_fast_t | 656 | _static_inline cube_fast_t |
| 651 | _trans_RFr(cube_fast_t c) | 657 | _trans_RFr(cube_fast_t c) |
| 652 | { | 658 | { |
| 653 | cube_fast_t ret; | 659 | cube_fast_t ret; |
| @@ -667,7 +673,7 @@ _trans_RFr(cube_fast_t c) | |||
| 667 | return ret; | 673 | return ret; |
| 668 | } | 674 | } |
| 669 | 675 | ||
| 670 | static inline cube_fast_t | 676 | _static_inline cube_fast_t |
| 671 | _trans_RDr(cube_fast_t c) | 677 | _trans_RDr(cube_fast_t c) |
| 672 | { | 678 | { |
| 673 | cube_fast_t ret; | 679 | cube_fast_t ret; |
| @@ -687,7 +693,7 @@ _trans_RDr(cube_fast_t c) | |||
| 687 | return ret; | 693 | return ret; |
| 688 | } | 694 | } |
| 689 | 695 | ||
| 690 | static inline cube_fast_t | 696 | _static_inline cube_fast_t |
| 691 | _trans_RBr(cube_fast_t c) | 697 | _trans_RBr(cube_fast_t c) |
| 692 | { | 698 | { |
| 693 | cube_fast_t ret; | 699 | cube_fast_t ret; |
| @@ -707,7 +713,7 @@ _trans_RBr(cube_fast_t c) | |||
| 707 | return ret; | 713 | return ret; |
| 708 | } | 714 | } |
| 709 | 715 | ||
| 710 | static inline cube_fast_t | 716 | _static_inline cube_fast_t |
| 711 | _trans_LUr(cube_fast_t c) | 717 | _trans_LUr(cube_fast_t c) |
| 712 | { | 718 | { |
| 713 | cube_fast_t ret; | 719 | cube_fast_t ret; |
| @@ -727,7 +733,7 @@ _trans_LUr(cube_fast_t c) | |||
| 727 | return ret; | 733 | return ret; |
| 728 | } | 734 | } |
| 729 | 735 | ||
| 730 | static inline cube_fast_t | 736 | _static_inline cube_fast_t |
| 731 | _trans_LFr(cube_fast_t c) | 737 | _trans_LFr(cube_fast_t c) |
| 732 | { | 738 | { |
| 733 | cube_fast_t ret; | 739 | cube_fast_t ret; |
| @@ -747,7 +753,7 @@ _trans_LFr(cube_fast_t c) | |||
| 747 | return ret; | 753 | return ret; |
| 748 | } | 754 | } |
| 749 | 755 | ||
| 750 | static inline cube_fast_t | 756 | _static_inline cube_fast_t |
| 751 | _trans_LDr(cube_fast_t c) | 757 | _trans_LDr(cube_fast_t c) |
| 752 | { | 758 | { |
| 753 | cube_fast_t ret; | 759 | cube_fast_t ret; |
| @@ -767,7 +773,7 @@ _trans_LDr(cube_fast_t c) | |||
| 767 | return ret; | 773 | return ret; |
| 768 | } | 774 | } |
| 769 | 775 | ||
| 770 | static inline cube_fast_t | 776 | _static_inline cube_fast_t |
| 771 | _trans_LBr(cube_fast_t c) | 777 | _trans_LBr(cube_fast_t c) |
| 772 | { | 778 | { |
| 773 | cube_fast_t ret; | 779 | cube_fast_t ret; |
| @@ -787,7 +793,7 @@ _trans_LBr(cube_fast_t c) | |||
| 787 | return ret; | 793 | return ret; |
| 788 | } | 794 | } |
| 789 | 795 | ||
| 790 | static inline cube_fast_t | 796 | _static_inline cube_fast_t |
| 791 | _trans_FUr(cube_fast_t c) | 797 | _trans_FUr(cube_fast_t c) |
| 792 | { | 798 | { |
| 793 | cube_fast_t ret; | 799 | cube_fast_t ret; |
| @@ -807,7 +813,7 @@ _trans_FUr(cube_fast_t c) | |||
| 807 | return ret; | 813 | return ret; |
| 808 | } | 814 | } |
| 809 | 815 | ||
| 810 | static inline cube_fast_t | 816 | _static_inline cube_fast_t |
| 811 | _trans_FRr(cube_fast_t c) | 817 | _trans_FRr(cube_fast_t c) |
| 812 | { | 818 | { |
| 813 | cube_fast_t ret; | 819 | cube_fast_t ret; |
| @@ -827,7 +833,7 @@ _trans_FRr(cube_fast_t c) | |||
| 827 | return ret; | 833 | return ret; |
| 828 | } | 834 | } |
| 829 | 835 | ||
| 830 | static inline cube_fast_t | 836 | _static_inline cube_fast_t |
| 831 | _trans_FDr(cube_fast_t c) | 837 | _trans_FDr(cube_fast_t c) |
| 832 | { | 838 | { |
| 833 | cube_fast_t ret; | 839 | cube_fast_t ret; |
| @@ -847,7 +853,7 @@ _trans_FDr(cube_fast_t c) | |||
| 847 | return ret; | 853 | return ret; |
| 848 | } | 854 | } |
| 849 | 855 | ||
| 850 | static inline cube_fast_t | 856 | _static_inline cube_fast_t |
| 851 | _trans_FLr(cube_fast_t c) | 857 | _trans_FLr(cube_fast_t c) |
| 852 | { | 858 | { |
| 853 | cube_fast_t ret; | 859 | cube_fast_t ret; |
| @@ -867,7 +873,7 @@ _trans_FLr(cube_fast_t c) | |||
| 867 | return ret; | 873 | return ret; |
| 868 | } | 874 | } |
| 869 | 875 | ||
| 870 | static inline cube_fast_t | 876 | _static_inline cube_fast_t |
| 871 | _trans_BUr(cube_fast_t c) | 877 | _trans_BUr(cube_fast_t c) |
| 872 | { | 878 | { |
| 873 | cube_fast_t ret; | 879 | cube_fast_t ret; |
| @@ -887,7 +893,7 @@ _trans_BUr(cube_fast_t c) | |||
| 887 | return ret; | 893 | return ret; |
| 888 | } | 894 | } |
| 889 | 895 | ||
| 890 | static inline cube_fast_t | 896 | _static_inline cube_fast_t |
| 891 | _trans_BRr(cube_fast_t c) | 897 | _trans_BRr(cube_fast_t c) |
| 892 | { | 898 | { |
| 893 | cube_fast_t ret; | 899 | cube_fast_t ret; |
| @@ -907,7 +913,7 @@ _trans_BRr(cube_fast_t c) | |||
| 907 | return ret; | 913 | return ret; |
| 908 | } | 914 | } |
| 909 | 915 | ||
| 910 | static inline cube_fast_t | 916 | _static_inline cube_fast_t |
| 911 | _trans_BDr(cube_fast_t c) | 917 | _trans_BDr(cube_fast_t c) |
| 912 | { | 918 | { |
| 913 | cube_fast_t ret; | 919 | cube_fast_t ret; |
| @@ -927,7 +933,7 @@ _trans_BDr(cube_fast_t c) | |||
| 927 | return ret; | 933 | return ret; |
| 928 | } | 934 | } |
| 929 | 935 | ||
| 930 | static inline cube_fast_t | 936 | _static_inline cube_fast_t |
| 931 | _trans_BLr(cube_fast_t c) | 937 | _trans_BLr(cube_fast_t c) |
| 932 | { | 938 | { |
| 933 | cube_fast_t ret; | 939 | cube_fast_t ret; |
| @@ -947,7 +953,7 @@ _trans_BLr(cube_fast_t c) | |||
| 947 | return ret; | 953 | return ret; |
| 948 | } | 954 | } |
| 949 | 955 | ||
| 950 | static inline cube_fast_t | 956 | _static_inline cube_fast_t |
| 951 | _trans_UFm(cube_fast_t c) | 957 | _trans_UFm(cube_fast_t c) |
| 952 | { | 958 | { |
| 953 | cube_fast_t ret; | 959 | cube_fast_t ret; |
| @@ -968,7 +974,7 @@ _trans_UFm(cube_fast_t c) | |||
| 968 | return ret; | 974 | return ret; |
| 969 | } | 975 | } |
| 970 | 976 | ||
| 971 | static inline cube_fast_t | 977 | _static_inline cube_fast_t |
| 972 | _trans_ULm(cube_fast_t c) | 978 | _trans_ULm(cube_fast_t c) |
| 973 | { | 979 | { |
| 974 | cube_fast_t ret; | 980 | cube_fast_t ret; |
| @@ -989,7 +995,7 @@ _trans_ULm(cube_fast_t c) | |||
| 989 | return ret; | 995 | return ret; |
| 990 | } | 996 | } |
| 991 | 997 | ||
| 992 | static inline cube_fast_t | 998 | _static_inline cube_fast_t |
| 993 | _trans_UBm(cube_fast_t c) | 999 | _trans_UBm(cube_fast_t c) |
| 994 | { | 1000 | { |
| 995 | cube_fast_t ret; | 1001 | cube_fast_t ret; |
| @@ -1010,7 +1016,7 @@ _trans_UBm(cube_fast_t c) | |||
| 1010 | return ret; | 1016 | return ret; |
| 1011 | } | 1017 | } |
| 1012 | 1018 | ||
| 1013 | static inline cube_fast_t | 1019 | _static_inline cube_fast_t |
| 1014 | _trans_URm(cube_fast_t c) | 1020 | _trans_URm(cube_fast_t c) |
| 1015 | { | 1021 | { |
| 1016 | cube_fast_t ret; | 1022 | cube_fast_t ret; |
| @@ -1031,7 +1037,7 @@ _trans_URm(cube_fast_t c) | |||
| 1031 | return ret; | 1037 | return ret; |
| 1032 | } | 1038 | } |
| 1033 | 1039 | ||
| 1034 | static inline cube_fast_t | 1040 | _static_inline cube_fast_t |
| 1035 | _trans_DFm(cube_fast_t c) | 1041 | _trans_DFm(cube_fast_t c) |
| 1036 | { | 1042 | { |
| 1037 | cube_fast_t ret; | 1043 | cube_fast_t ret; |
| @@ -1052,7 +1058,7 @@ _trans_DFm(cube_fast_t c) | |||
| 1052 | return ret; | 1058 | return ret; |
| 1053 | } | 1059 | } |
| 1054 | 1060 | ||
| 1055 | static inline cube_fast_t | 1061 | _static_inline cube_fast_t |
| 1056 | _trans_DLm(cube_fast_t c) | 1062 | _trans_DLm(cube_fast_t c) |
| 1057 | { | 1063 | { |
| 1058 | cube_fast_t ret; | 1064 | cube_fast_t ret; |
| @@ -1073,7 +1079,7 @@ _trans_DLm(cube_fast_t c) | |||
| 1073 | return ret; | 1079 | return ret; |
| 1074 | } | 1080 | } |
| 1075 | 1081 | ||
| 1076 | static inline cube_fast_t | 1082 | _static_inline cube_fast_t |
| 1077 | _trans_DBm(cube_fast_t c) | 1083 | _trans_DBm(cube_fast_t c) |
| 1078 | { | 1084 | { |
| 1079 | cube_fast_t ret; | 1085 | cube_fast_t ret; |
| @@ -1094,7 +1100,7 @@ _trans_DBm(cube_fast_t c) | |||
| 1094 | return ret; | 1100 | return ret; |
| 1095 | } | 1101 | } |
| 1096 | 1102 | ||
| 1097 | static inline cube_fast_t | 1103 | _static_inline cube_fast_t |
| 1098 | _trans_DRm(cube_fast_t c) | 1104 | _trans_DRm(cube_fast_t c) |
| 1099 | { | 1105 | { |
| 1100 | cube_fast_t ret; | 1106 | cube_fast_t ret; |
| @@ -1115,7 +1121,7 @@ _trans_DRm(cube_fast_t c) | |||
| 1115 | return ret; | 1121 | return ret; |
| 1116 | } | 1122 | } |
| 1117 | 1123 | ||
| 1118 | static inline cube_fast_t | 1124 | _static_inline cube_fast_t |
| 1119 | _trans_RUm(cube_fast_t c) | 1125 | _trans_RUm(cube_fast_t c) |
| 1120 | { | 1126 | { |
| 1121 | cube_fast_t ret; | 1127 | cube_fast_t ret; |
| @@ -1136,7 +1142,7 @@ _trans_RUm(cube_fast_t c) | |||
| 1136 | return ret; | 1142 | return ret; |
| 1137 | } | 1143 | } |
| 1138 | 1144 | ||
| 1139 | static inline cube_fast_t | 1145 | _static_inline cube_fast_t |
| 1140 | _trans_RFm(cube_fast_t c) | 1146 | _trans_RFm(cube_fast_t c) |
| 1141 | { | 1147 | { |
| 1142 | cube_fast_t ret; | 1148 | cube_fast_t ret; |
| @@ -1157,7 +1163,7 @@ _trans_RFm(cube_fast_t c) | |||
| 1157 | return ret; | 1163 | return ret; |
| 1158 | } | 1164 | } |
| 1159 | 1165 | ||
| 1160 | static inline cube_fast_t | 1166 | _static_inline cube_fast_t |
| 1161 | _trans_RDm(cube_fast_t c) | 1167 | _trans_RDm(cube_fast_t c) |
| 1162 | { | 1168 | { |
| 1163 | cube_fast_t ret; | 1169 | cube_fast_t ret; |
| @@ -1178,7 +1184,7 @@ _trans_RDm(cube_fast_t c) | |||
| 1178 | return ret; | 1184 | return ret; |
| 1179 | } | 1185 | } |
| 1180 | 1186 | ||
| 1181 | static inline cube_fast_t | 1187 | _static_inline cube_fast_t |
| 1182 | _trans_RBm(cube_fast_t c) | 1188 | _trans_RBm(cube_fast_t c) |
| 1183 | { | 1189 | { |
| 1184 | cube_fast_t ret; | 1190 | cube_fast_t ret; |
| @@ -1199,7 +1205,7 @@ _trans_RBm(cube_fast_t c) | |||
| 1199 | return ret; | 1205 | return ret; |
| 1200 | } | 1206 | } |
| 1201 | 1207 | ||
| 1202 | static inline cube_fast_t | 1208 | _static_inline cube_fast_t |
| 1203 | _trans_LUm(cube_fast_t c) | 1209 | _trans_LUm(cube_fast_t c) |
| 1204 | { | 1210 | { |
| 1205 | cube_fast_t ret; | 1211 | cube_fast_t ret; |
| @@ -1220,7 +1226,7 @@ _trans_LUm(cube_fast_t c) | |||
| 1220 | return ret; | 1226 | return ret; |
| 1221 | } | 1227 | } |
| 1222 | 1228 | ||
| 1223 | static inline cube_fast_t | 1229 | _static_inline cube_fast_t |
| 1224 | _trans_LFm(cube_fast_t c) | 1230 | _trans_LFm(cube_fast_t c) |
| 1225 | { | 1231 | { |
| 1226 | cube_fast_t ret; | 1232 | cube_fast_t ret; |
| @@ -1241,7 +1247,7 @@ _trans_LFm(cube_fast_t c) | |||
| 1241 | return ret; | 1247 | return ret; |
| 1242 | } | 1248 | } |
| 1243 | 1249 | ||
| 1244 | static inline cube_fast_t | 1250 | _static_inline cube_fast_t |
| 1245 | _trans_LDm(cube_fast_t c) | 1251 | _trans_LDm(cube_fast_t c) |
| 1246 | { | 1252 | { |
| 1247 | cube_fast_t ret; | 1253 | cube_fast_t ret; |
| @@ -1262,7 +1268,7 @@ _trans_LDm(cube_fast_t c) | |||
| 1262 | return ret; | 1268 | return ret; |
| 1263 | } | 1269 | } |
| 1264 | 1270 | ||
| 1265 | static inline cube_fast_t | 1271 | _static_inline cube_fast_t |
| 1266 | _trans_LBm(cube_fast_t c) | 1272 | _trans_LBm(cube_fast_t c) |
| 1267 | { | 1273 | { |
| 1268 | cube_fast_t ret; | 1274 | cube_fast_t ret; |
| @@ -1283,7 +1289,7 @@ _trans_LBm(cube_fast_t c) | |||
| 1283 | return ret; | 1289 | return ret; |
| 1284 | } | 1290 | } |
| 1285 | 1291 | ||
| 1286 | static inline cube_fast_t | 1292 | _static_inline cube_fast_t |
| 1287 | _trans_FUm(cube_fast_t c) | 1293 | _trans_FUm(cube_fast_t c) |
| 1288 | { | 1294 | { |
| 1289 | cube_fast_t ret; | 1295 | cube_fast_t ret; |
| @@ -1304,7 +1310,7 @@ _trans_FUm(cube_fast_t c) | |||
| 1304 | return ret; | 1310 | return ret; |
| 1305 | } | 1311 | } |
| 1306 | 1312 | ||
| 1307 | static inline cube_fast_t | 1313 | _static_inline cube_fast_t |
| 1308 | _trans_FRm(cube_fast_t c) | 1314 | _trans_FRm(cube_fast_t c) |
| 1309 | { | 1315 | { |
| 1310 | cube_fast_t ret; | 1316 | cube_fast_t ret; |
| @@ -1325,7 +1331,7 @@ _trans_FRm(cube_fast_t c) | |||
| 1325 | return ret; | 1331 | return ret; |
| 1326 | } | 1332 | } |
| 1327 | 1333 | ||
| 1328 | static inline cube_fast_t | 1334 | _static_inline cube_fast_t |
| 1329 | _trans_FDm(cube_fast_t c) | 1335 | _trans_FDm(cube_fast_t c) |
| 1330 | { | 1336 | { |
| 1331 | cube_fast_t ret; | 1337 | cube_fast_t ret; |
| @@ -1346,7 +1352,7 @@ _trans_FDm(cube_fast_t c) | |||
| 1346 | return ret; | 1352 | return ret; |
| 1347 | } | 1353 | } |
| 1348 | 1354 | ||
| 1349 | static inline cube_fast_t | 1355 | _static_inline cube_fast_t |
| 1350 | _trans_FLm(cube_fast_t c) | 1356 | _trans_FLm(cube_fast_t c) |
| 1351 | { | 1357 | { |
| 1352 | cube_fast_t ret; | 1358 | cube_fast_t ret; |
| @@ -1367,7 +1373,7 @@ _trans_FLm(cube_fast_t c) | |||
| 1367 | return ret; | 1373 | return ret; |
| 1368 | } | 1374 | } |
| 1369 | 1375 | ||
| 1370 | static inline cube_fast_t | 1376 | _static_inline cube_fast_t |
| 1371 | _trans_BUm(cube_fast_t c) | 1377 | _trans_BUm(cube_fast_t c) |
| 1372 | { | 1378 | { |
| 1373 | cube_fast_t ret; | 1379 | cube_fast_t ret; |
| @@ -1388,7 +1394,7 @@ _trans_BUm(cube_fast_t c) | |||
| 1388 | return ret; | 1394 | return ret; |
| 1389 | } | 1395 | } |
| 1390 | 1396 | ||
| 1391 | static inline cube_fast_t | 1397 | _static_inline cube_fast_t |
| 1392 | _trans_BRm(cube_fast_t c) | 1398 | _trans_BRm(cube_fast_t c) |
| 1393 | { | 1399 | { |
| 1394 | cube_fast_t ret; | 1400 | cube_fast_t ret; |
| @@ -1409,7 +1415,7 @@ _trans_BRm(cube_fast_t c) | |||
| 1409 | return ret; | 1415 | return ret; |
| 1410 | } | 1416 | } |
| 1411 | 1417 | ||
| 1412 | static inline cube_fast_t | 1418 | _static_inline cube_fast_t |
| 1413 | _trans_BDm(cube_fast_t c) | 1419 | _trans_BDm(cube_fast_t c) |
| 1414 | { | 1420 | { |
| 1415 | cube_fast_t ret; | 1421 | cube_fast_t ret; |
| @@ -1430,7 +1436,7 @@ _trans_BDm(cube_fast_t c) | |||
| 1430 | return ret; | 1436 | return ret; |
| 1431 | } | 1437 | } |
| 1432 | 1438 | ||
| 1433 | static inline cube_fast_t | 1439 | _static_inline cube_fast_t |
| 1434 | _trans_BLm(cube_fast_t c) | 1440 | _trans_BLm(cube_fast_t c) |
| 1435 | { | 1441 | { |
| 1436 | cube_fast_t ret; | 1442 | cube_fast_t ret; |
| @@ -1451,7 +1457,7 @@ _trans_BLm(cube_fast_t c) | |||
| 1451 | return ret; | 1457 | return ret; |
| 1452 | } | 1458 | } |
| 1453 | 1459 | ||
| 1454 | static cube_fast_t | 1460 | _static cube_fast_t |
| 1455 | cubetofast(cube_t a) | 1461 | cubetofast(cube_t a) |
| 1456 | { | 1462 | { |
| 1457 | uint8_t aux[32]; | 1463 | uint8_t aux[32]; |
| @@ -1463,7 +1469,7 @@ cubetofast(cube_t a) | |||
| 1463 | return _mm256_loadu_si256((__m256i_u *)&aux); | 1469 | return _mm256_loadu_si256((__m256i_u *)&aux); |
| 1464 | } | 1470 | } |
| 1465 | 1471 | ||
| 1466 | static cube_t | 1472 | _static cube_t |
| 1467 | fasttocube(cube_fast_t c) | 1473 | fasttocube(cube_fast_t c) |
| 1468 | { | 1474 | { |
| 1469 | cube_t a; | 1475 | cube_t a; |
| @@ -1476,7 +1482,7 @@ fasttocube(cube_fast_t c) | |||
| 1476 | return a; | 1482 | return a; |
| 1477 | } | 1483 | } |
| 1478 | 1484 | ||
| 1479 | static inline bool | 1485 | _static_inline bool |
| 1480 | equal_fast(cube_fast_t c1, cube_fast_t c2) | 1486 | equal_fast(cube_fast_t c1, cube_fast_t c2) |
| 1481 | { | 1487 | { |
| 1482 | int32_t mask; | 1488 | int32_t mask; |
| @@ -1488,13 +1494,13 @@ equal_fast(cube_fast_t c1, cube_fast_t c2) | |||
| 1488 | return mask == ~0; | 1494 | return mask == ~0; |
| 1489 | } | 1495 | } |
| 1490 | 1496 | ||
| 1491 | static inline bool | 1497 | _static_inline bool |
| 1492 | issolved_fast(cube_fast_t cube) | 1498 | issolved_fast(cube_fast_t cube) |
| 1493 | { | 1499 | { |
| 1494 | return equal_fast(cube, solved_fast); | 1500 | return equal_fast(cube, solved_fast); |
| 1495 | } | 1501 | } |
| 1496 | 1502 | ||
| 1497 | static inline cube_fast_t | 1503 | _static_inline cube_fast_t |
| 1498 | invertco_fast(cube_fast_t c) | 1504 | invertco_fast(cube_fast_t c) |
| 1499 | { | 1505 | { |
| 1500 | cube_fast_t co, shleft, shright, summed, newco, cleanco, ret; | 1506 | cube_fast_t co, shleft, shright, summed, newco, cleanco, ret; |
| @@ -1510,7 +1516,7 @@ invertco_fast(cube_fast_t c) | |||
| 1510 | return ret; | 1516 | return ret; |
| 1511 | } | 1517 | } |
| 1512 | 1518 | ||
| 1513 | static inline cube_fast_t | 1519 | _static_inline cube_fast_t |
| 1514 | cleanaftershuffle(cube_fast_t c) | 1520 | cleanaftershuffle(cube_fast_t c) |
| 1515 | { | 1521 | { |
| 1516 | __m256i b; | 1522 | __m256i b; |
| @@ -1523,7 +1529,7 @@ cleanaftershuffle(cube_fast_t c) | |||
| 1523 | return _mm256_andnot_si256(b, c); | 1529 | return _mm256_andnot_si256(b, c); |
| 1524 | } | 1530 | } |
| 1525 | 1531 | ||
| 1526 | static inline cube_fast_t | 1532 | _static_inline cube_fast_t |
| 1527 | inverse_fast(cube_fast_t c) | 1533 | inverse_fast(cube_fast_t c) |
| 1528 | { | 1534 | { |
| 1529 | /* Method taken from Andrew Skalski's vcube[1]. The addition sequence | 1535 | /* Method taken from Andrew Skalski's vcube[1]. The addition sequence |
| @@ -1562,7 +1568,7 @@ inverse_fast(cube_fast_t c) | |||
| 1562 | return invertco_fast(ret); | 1568 | return invertco_fast(ret); |
| 1563 | } | 1569 | } |
| 1564 | 1570 | ||
| 1565 | static inline cube_fast_t | 1571 | _static_inline cube_fast_t |
| 1566 | compose_fast(cube_fast_t c1, cube_fast_t c2) | 1572 | compose_fast(cube_fast_t c1, cube_fast_t c2) |
| 1567 | { | 1573 | { |
| 1568 | cube_fast_t ret; | 1574 | cube_fast_t ret; |
| @@ -1586,7 +1592,7 @@ compose_fast(cube_fast_t c1, cube_fast_t c2) | |||
| 1586 | return ret; | 1592 | return ret; |
| 1587 | } | 1593 | } |
| 1588 | 1594 | ||
| 1589 | static inline int64_t | 1595 | _static_inline int64_t |
| 1590 | coord_fast_eo(cube_fast_t c) | 1596 | coord_fast_eo(cube_fast_t c) |
| 1591 | { | 1597 | { |
| 1592 | cube_fast_t eo, shifted; | 1598 | cube_fast_t eo, shifted; |
| @@ -1641,20 +1647,22 @@ typedef cube_t cube_fast_t; | |||
| 1641 | r[k] ^= _eobit; \ | 1647 | r[k] ^= _eobit; \ |
| 1642 | r[l] ^= _eobit; | 1648 | r[l] ^= _eobit; |
| 1643 | 1649 | ||
| 1644 | static cube_fast_t zero_fast = { .corner = {0}, .edge = {0} }; | 1650 | _static cube_fast_t zero_fast = { .corner = {0}, .edge = {0} }; |
| 1645 | static cube_t solved_fast = { | 1651 | _static cube_t solved_fast = { |
| 1646 | .corner = {0, 1, 2, 3, 4, 5, 6, 7}, | 1652 | .corner = {0, 1, 2, 3, 4, 5, 6, 7}, |
| 1647 | .edge = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} | 1653 | .edge = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} |
| 1648 | }; | 1654 | }; |
| 1649 | 1655 | ||
| 1650 | static cube_fast_t cubetofast(cube_t); | 1656 | _static cube_fast_t cubetofast(cube_t); |
| 1651 | static cube_t fasttocube(cube_fast_t); | 1657 | _static cube_t fasttocube(cube_fast_t); |
| 1652 | static inline bool equal_fast(cube_fast_t, cube_fast_t); | 1658 | _static_inline bool equal_fast(cube_fast_t, cube_fast_t); |
| 1653 | static inline cube_fast_t invertco_fast(cube_fast_t); | 1659 | _static_inline bool issolved_fast(cube_fast_t); |
| 1654 | static inline cube_fast_t inverse_fast(cube_fast_t); | 1660 | _static_inline cube_fast_t invertco_fast(cube_fast_t); |
| 1655 | static inline cube_fast_t compose_fast(cube_fast_t, cube_fast_t); | 1661 | _static_inline cube_fast_t inverse_fast(cube_fast_t); |
| 1662 | _static_inline cube_fast_t compose_fast(cube_fast_t, cube_fast_t); | ||
| 1663 | _static_inline int64_t coord_fast_eo(cube_fast_t); | ||
| 1656 | 1664 | ||
| 1657 | static inline cube_fast_t | 1665 | _static_inline cube_fast_t |
| 1658 | _move_U(cube_fast_t c) | 1666 | _move_U(cube_fast_t c) |
| 1659 | { | 1667 | { |
| 1660 | uint8_t aux; | 1668 | uint8_t aux; |
| @@ -1666,7 +1674,7 @@ _move_U(cube_fast_t c) | |||
| 1666 | return ret; | 1674 | return ret; |
| 1667 | } | 1675 | } |
| 1668 | 1676 | ||
| 1669 | static inline cube_fast_t | 1677 | _static_inline cube_fast_t |
| 1670 | _move_U2(cube_fast_t c) | 1678 | _move_U2(cube_fast_t c) |
| 1671 | { | 1679 | { |
| 1672 | uint8_t aux; | 1680 | uint8_t aux; |
| @@ -1678,7 +1686,7 @@ _move_U2(cube_fast_t c) | |||
| 1678 | return ret; | 1686 | return ret; |
| 1679 | } | 1687 | } |
| 1680 | 1688 | ||
| 1681 | static inline cube_fast_t | 1689 | _static_inline cube_fast_t |
| 1682 | _move_U3(cube_fast_t c) | 1690 | _move_U3(cube_fast_t c) |
| 1683 | { | 1691 | { |
| 1684 | uint8_t aux; | 1692 | uint8_t aux; |
| @@ -1690,7 +1698,7 @@ _move_U3(cube_fast_t c) | |||
| 1690 | return ret; | 1698 | return ret; |
| 1691 | } | 1699 | } |
| 1692 | 1700 | ||
| 1693 | static inline cube_fast_t | 1701 | _static_inline cube_fast_t |
| 1694 | _move_D(cube_fast_t c) | 1702 | _move_D(cube_fast_t c) |
| 1695 | { | 1703 | { |
| 1696 | uint8_t aux; | 1704 | uint8_t aux; |
| @@ -1702,7 +1710,7 @@ _move_D(cube_fast_t c) | |||
| 1702 | return ret; | 1710 | return ret; |
| 1703 | } | 1711 | } |
| 1704 | 1712 | ||
| 1705 | static inline cube_fast_t | 1713 | _static_inline cube_fast_t |
| 1706 | _move_D2(cube_fast_t c) | 1714 | _move_D2(cube_fast_t c) |
| 1707 | { | 1715 | { |
| 1708 | uint8_t aux; | 1716 | uint8_t aux; |
| @@ -1714,7 +1722,7 @@ _move_D2(cube_fast_t c) | |||
| 1714 | return ret; | 1722 | return ret; |
| 1715 | } | 1723 | } |
| 1716 | 1724 | ||
| 1717 | static inline cube_fast_t | 1725 | _static_inline cube_fast_t |
| 1718 | _move_D3(cube_fast_t c) | 1726 | _move_D3(cube_fast_t c) |
| 1719 | { | 1727 | { |
| 1720 | uint8_t aux; | 1728 | uint8_t aux; |
| @@ -1726,7 +1734,7 @@ _move_D3(cube_fast_t c) | |||
| 1726 | return ret; | 1734 | return ret; |
| 1727 | } | 1735 | } |
| 1728 | 1736 | ||
| 1729 | static inline cube_fast_t | 1737 | _static_inline cube_fast_t |
| 1730 | _move_R(cube_fast_t c) | 1738 | _move_R(cube_fast_t c) |
| 1731 | { | 1739 | { |
| 1732 | uint8_t aux, auy, auz; | 1740 | uint8_t aux, auy, auz; |
| @@ -1740,7 +1748,7 @@ _move_R(cube_fast_t c) | |||
| 1740 | return ret; | 1748 | return ret; |
| 1741 | } | 1749 | } |
| 1742 | 1750 | ||
| 1743 | static inline cube_fast_t | 1751 | _static_inline cube_fast_t |
| 1744 | _move_R2(cube_fast_t c) | 1752 | _move_R2(cube_fast_t c) |
| 1745 | { | 1753 | { |
| 1746 | uint8_t aux; | 1754 | uint8_t aux; |
| @@ -1752,7 +1760,7 @@ _move_R2(cube_fast_t c) | |||
| 1752 | return ret; | 1760 | return ret; |
| 1753 | } | 1761 | } |
| 1754 | 1762 | ||
| 1755 | static inline cube_fast_t | 1763 | _static_inline cube_fast_t |
| 1756 | _move_R3(cube_fast_t c) | 1764 | _move_R3(cube_fast_t c) |
| 1757 | { | 1765 | { |
| 1758 | uint8_t aux, auy, auz; | 1766 | uint8_t aux, auy, auz; |
| @@ -1766,7 +1774,7 @@ _move_R3(cube_fast_t c) | |||
| 1766 | return ret; | 1774 | return ret; |
| 1767 | } | 1775 | } |
| 1768 | 1776 | ||
| 1769 | static inline cube_fast_t | 1777 | _static_inline cube_fast_t |
| 1770 | _move_L(cube_fast_t c) | 1778 | _move_L(cube_fast_t c) |
| 1771 | { | 1779 | { |
| 1772 | uint8_t aux, auy, auz; | 1780 | uint8_t aux, auy, auz; |
| @@ -1780,7 +1788,7 @@ _move_L(cube_fast_t c) | |||
| 1780 | return ret; | 1788 | return ret; |
| 1781 | } | 1789 | } |
| 1782 | 1790 | ||
| 1783 | static inline cube_fast_t | 1791 | _static_inline cube_fast_t |
| 1784 | _move_L2(cube_fast_t c) | 1792 | _move_L2(cube_fast_t c) |
| 1785 | { | 1793 | { |
| 1786 | uint8_t aux; | 1794 | uint8_t aux; |
| @@ -1792,7 +1800,7 @@ _move_L2(cube_fast_t c) | |||
| 1792 | return ret; | 1800 | return ret; |
| 1793 | } | 1801 | } |
| 1794 | 1802 | ||
| 1795 | static inline cube_fast_t | 1803 | _static_inline cube_fast_t |
| 1796 | _move_L3(cube_fast_t c) | 1804 | _move_L3(cube_fast_t c) |
| 1797 | { | 1805 | { |
| 1798 | uint8_t aux, auy, auz; | 1806 | uint8_t aux, auy, auz; |
| @@ -1806,7 +1814,7 @@ _move_L3(cube_fast_t c) | |||
| 1806 | return ret; | 1814 | return ret; |
| 1807 | } | 1815 | } |
| 1808 | 1816 | ||
| 1809 | static inline cube_fast_t | 1817 | _static_inline cube_fast_t |
| 1810 | _move_F(cube_fast_t c) | 1818 | _move_F(cube_fast_t c) |
| 1811 | { | 1819 | { |
| 1812 | uint8_t aux, auy, auz; | 1820 | uint8_t aux, auy, auz; |
| @@ -1821,7 +1829,7 @@ _move_F(cube_fast_t c) | |||
| 1821 | return ret; | 1829 | return ret; |
| 1822 | } | 1830 | } |
| 1823 | 1831 | ||
| 1824 | static inline cube_fast_t | 1832 | _static_inline cube_fast_t |
| 1825 | _move_F2(cube_fast_t c) | 1833 | _move_F2(cube_fast_t c) |
| 1826 | { | 1834 | { |
| 1827 | uint8_t aux; | 1835 | uint8_t aux; |
| @@ -1833,7 +1841,7 @@ _move_F2(cube_fast_t c) | |||
| 1833 | return ret; | 1841 | return ret; |
| 1834 | } | 1842 | } |
| 1835 | 1843 | ||
| 1836 | static inline cube_fast_t | 1844 | _static_inline cube_fast_t |
| 1837 | _move_F3(cube_fast_t c) | 1845 | _move_F3(cube_fast_t c) |
| 1838 | { | 1846 | { |
| 1839 | uint8_t aux, auy, auz; | 1847 | uint8_t aux, auy, auz; |
| @@ -1848,7 +1856,7 @@ _move_F3(cube_fast_t c) | |||
| 1848 | return ret; | 1856 | return ret; |
| 1849 | } | 1857 | } |
| 1850 | 1858 | ||
| 1851 | static inline cube_fast_t | 1859 | _static_inline cube_fast_t |
| 1852 | _move_B(cube_fast_t c) | 1860 | _move_B(cube_fast_t c) |
| 1853 | { | 1861 | { |
| 1854 | uint8_t aux, auy, auz; | 1862 | uint8_t aux, auy, auz; |
| @@ -1863,7 +1871,7 @@ _move_B(cube_fast_t c) | |||
| 1863 | return ret; | 1871 | return ret; |
| 1864 | } | 1872 | } |
| 1865 | 1873 | ||
| 1866 | static inline cube_fast_t | 1874 | _static_inline cube_fast_t |
| 1867 | _move_B2(cube_fast_t c) | 1875 | _move_B2(cube_fast_t c) |
| 1868 | { | 1876 | { |
| 1869 | uint8_t aux; | 1877 | uint8_t aux; |
| @@ -1875,7 +1883,7 @@ _move_B2(cube_fast_t c) | |||
| 1875 | return ret; | 1883 | return ret; |
| 1876 | } | 1884 | } |
| 1877 | 1885 | ||
| 1878 | static inline cube_fast_t | 1886 | _static_inline cube_fast_t |
| 1879 | _move_B3(cube_fast_t c) | 1887 | _move_B3(cube_fast_t c) |
| 1880 | { | 1888 | { |
| 1881 | uint8_t aux, auy, auz; | 1889 | uint8_t aux, auy, auz; |
| @@ -1890,23 +1898,7 @@ _move_B3(cube_fast_t c) | |||
| 1890 | return ret; | 1898 | return ret; |
| 1891 | } | 1899 | } |
| 1892 | 1900 | ||
| 1893 | static inline cube_fast_t | 1901 | _static_inline cube_fast_t |
| 1894 | invertco_fast(cube_fast_t c) | ||
| 1895 | { | ||
| 1896 | uint8_t i, piece, orien; | ||
| 1897 | cube_fast_t ret; | ||
| 1898 | |||
| 1899 | ret = c; | ||
| 1900 | for (i = 0; i < 8; i++) { | ||
| 1901 | piece = c.corner[i]; | ||
| 1902 | orien = ((piece << 1) | (piece >> 1)) & _cobits2; | ||
| 1903 | ret.corner[i] = (piece & _pbits) | orien; | ||
| 1904 | } | ||
| 1905 | |||
| 1906 | return ret; | ||
| 1907 | } | ||
| 1908 | |||
| 1909 | static inline cube_fast_t | ||
| 1910 | _trans_UFr(cube_fast_t c) | 1902 | _trans_UFr(cube_fast_t c) |
| 1911 | { | 1903 | { |
| 1912 | cube_fast_t ret; | 1904 | cube_fast_t ret; |
| @@ -1925,7 +1917,7 @@ _trans_UFr(cube_fast_t c) | |||
| 1925 | return ret; | 1917 | return ret; |
| 1926 | } | 1918 | } |
| 1927 | 1919 | ||
| 1928 | static inline cube_fast_t | 1920 | _static_inline cube_fast_t |
| 1929 | _trans_ULr(cube_fast_t c) | 1921 | _trans_ULr(cube_fast_t c) |
| 1930 | { | 1922 | { |
| 1931 | cube_fast_t ret; | 1923 | cube_fast_t ret; |
| @@ -1944,7 +1936,7 @@ _trans_ULr(cube_fast_t c) | |||
| 1944 | return ret; | 1936 | return ret; |
| 1945 | } | 1937 | } |
| 1946 | 1938 | ||
| 1947 | static inline cube_fast_t | 1939 | _static_inline cube_fast_t |
| 1948 | _trans_UBr(cube_fast_t c) | 1940 | _trans_UBr(cube_fast_t c) |
| 1949 | { | 1941 | { |
| 1950 | cube_fast_t ret; | 1942 | cube_fast_t ret; |
| @@ -1963,7 +1955,7 @@ _trans_UBr(cube_fast_t c) | |||
| 1963 | return ret; | 1955 | return ret; |
| 1964 | } | 1956 | } |
| 1965 | 1957 | ||
| 1966 | static inline cube_fast_t | 1958 | _static_inline cube_fast_t |
| 1967 | _trans_URr(cube_fast_t c) | 1959 | _trans_URr(cube_fast_t c) |
| 1968 | { | 1960 | { |
| 1969 | cube_fast_t ret; | 1961 | cube_fast_t ret; |
| @@ -1982,7 +1974,7 @@ _trans_URr(cube_fast_t c) | |||
| 1982 | return ret; | 1974 | return ret; |
| 1983 | } | 1975 | } |
| 1984 | 1976 | ||
| 1985 | static inline cube_fast_t | 1977 | _static_inline cube_fast_t |
| 1986 | _trans_DFr(cube_fast_t c) | 1978 | _trans_DFr(cube_fast_t c) |
| 1987 | { | 1979 | { |
| 1988 | cube_fast_t ret; | 1980 | cube_fast_t ret; |
| @@ -2001,7 +1993,7 @@ _trans_DFr(cube_fast_t c) | |||
| 2001 | return ret; | 1993 | return ret; |
| 2002 | } | 1994 | } |
| 2003 | 1995 | ||
| 2004 | static inline cube_fast_t | 1996 | _static_inline cube_fast_t |
| 2005 | _trans_DLr(cube_fast_t c) | 1997 | _trans_DLr(cube_fast_t c) |
| 2006 | { | 1998 | { |
| 2007 | cube_fast_t ret; | 1999 | cube_fast_t ret; |
| @@ -2020,7 +2012,7 @@ _trans_DLr(cube_fast_t c) | |||
| 2020 | return ret; | 2012 | return ret; |
| 2021 | } | 2013 | } |
| 2022 | 2014 | ||
| 2023 | static inline cube_fast_t | 2015 | _static_inline cube_fast_t |
| 2024 | _trans_DBr(cube_fast_t c) | 2016 | _trans_DBr(cube_fast_t c) |
| 2025 | { | 2017 | { |
| 2026 | cube_fast_t ret; | 2018 | cube_fast_t ret; |
| @@ -2039,7 +2031,7 @@ _trans_DBr(cube_fast_t c) | |||
| 2039 | return ret; | 2031 | return ret; |
| 2040 | } | 2032 | } |
| 2041 | 2033 | ||
| 2042 | static inline cube_fast_t | 2034 | _static_inline cube_fast_t |
| 2043 | _trans_DRr(cube_fast_t c) | 2035 | _trans_DRr(cube_fast_t c) |
| 2044 | { | 2036 | { |
| 2045 | cube_fast_t ret; | 2037 | cube_fast_t ret; |
| @@ -2058,7 +2050,7 @@ _trans_DRr(cube_fast_t c) | |||
| 2058 | return ret; | 2050 | return ret; |
| 2059 | } | 2051 | } |
| 2060 | 2052 | ||
| 2061 | static inline cube_fast_t | 2053 | _static_inline cube_fast_t |
| 2062 | _trans_RUr(cube_fast_t c) | 2054 | _trans_RUr(cube_fast_t c) |
| 2063 | { | 2055 | { |
| 2064 | cube_fast_t ret; | 2056 | cube_fast_t ret; |
| @@ -2077,7 +2069,7 @@ _trans_RUr(cube_fast_t c) | |||
| 2077 | return ret; | 2069 | return ret; |
| 2078 | } | 2070 | } |
| 2079 | 2071 | ||
| 2080 | static inline cube_fast_t | 2072 | _static_inline cube_fast_t |
| 2081 | _trans_RFr(cube_fast_t c) | 2073 | _trans_RFr(cube_fast_t c) |
| 2082 | { | 2074 | { |
| 2083 | cube_fast_t ret; | 2075 | cube_fast_t ret; |
| @@ -2096,7 +2088,7 @@ _trans_RFr(cube_fast_t c) | |||
| 2096 | return ret; | 2088 | return ret; |
| 2097 | } | 2089 | } |
| 2098 | 2090 | ||
| 2099 | static inline cube_fast_t | 2091 | _static_inline cube_fast_t |
| 2100 | _trans_RDr(cube_fast_t c) | 2092 | _trans_RDr(cube_fast_t c) |
| 2101 | { | 2093 | { |
| 2102 | cube_fast_t ret; | 2094 | cube_fast_t ret; |
| @@ -2115,7 +2107,7 @@ _trans_RDr(cube_fast_t c) | |||
| 2115 | return ret; | 2107 | return ret; |
| 2116 | } | 2108 | } |
| 2117 | 2109 | ||
| 2118 | static inline cube_fast_t | 2110 | _static_inline cube_fast_t |
| 2119 | _trans_RBr(cube_fast_t c) | 2111 | _trans_RBr(cube_fast_t c) |
| 2120 | { | 2112 | { |
| 2121 | cube_fast_t ret; | 2113 | cube_fast_t ret; |
| @@ -2134,7 +2126,7 @@ _trans_RBr(cube_fast_t c) | |||
| 2134 | return ret; | 2126 | return ret; |
| 2135 | } | 2127 | } |
| 2136 | 2128 | ||
| 2137 | static inline cube_fast_t | 2129 | _static_inline cube_fast_t |
| 2138 | _trans_LUr(cube_fast_t c) | 2130 | _trans_LUr(cube_fast_t c) |
| 2139 | { | 2131 | { |
| 2140 | cube_fast_t ret; | 2132 | cube_fast_t ret; |
| @@ -2153,7 +2145,7 @@ _trans_LUr(cube_fast_t c) | |||
| 2153 | return ret; | 2145 | return ret; |
| 2154 | } | 2146 | } |
| 2155 | 2147 | ||
| 2156 | static inline cube_fast_t | 2148 | _static_inline cube_fast_t |
| 2157 | _trans_LFr(cube_fast_t c) | 2149 | _trans_LFr(cube_fast_t c) |
| 2158 | { | 2150 | { |
| 2159 | cube_fast_t ret; | 2151 | cube_fast_t ret; |
| @@ -2172,7 +2164,7 @@ _trans_LFr(cube_fast_t c) | |||
| 2172 | return ret; | 2164 | return ret; |
| 2173 | } | 2165 | } |
| 2174 | 2166 | ||
| 2175 | static inline cube_fast_t | 2167 | _static_inline cube_fast_t |
| 2176 | _trans_LDr(cube_fast_t c) | 2168 | _trans_LDr(cube_fast_t c) |
| 2177 | { | 2169 | { |
| 2178 | cube_fast_t ret; | 2170 | cube_fast_t ret; |
| @@ -2191,7 +2183,7 @@ _trans_LDr(cube_fast_t c) | |||
| 2191 | return ret; | 2183 | return ret; |
| 2192 | } | 2184 | } |
| 2193 | 2185 | ||
| 2194 | static inline cube_fast_t | 2186 | _static_inline cube_fast_t |
| 2195 | _trans_LBr(cube_fast_t c) | 2187 | _trans_LBr(cube_fast_t c) |
| 2196 | { | 2188 | { |
| 2197 | cube_fast_t ret; | 2189 | cube_fast_t ret; |
| @@ -2210,7 +2202,7 @@ _trans_LBr(cube_fast_t c) | |||
| 2210 | return ret; | 2202 | return ret; |
| 2211 | } | 2203 | } |
| 2212 | 2204 | ||
| 2213 | static inline cube_fast_t | 2205 | _static_inline cube_fast_t |
| 2214 | _trans_FUr(cube_fast_t c) | 2206 | _trans_FUr(cube_fast_t c) |
| 2215 | { | 2207 | { |
| 2216 | cube_fast_t ret; | 2208 | cube_fast_t ret; |
| @@ -2229,7 +2221,7 @@ _trans_FUr(cube_fast_t c) | |||
| 2229 | return ret; | 2221 | return ret; |
| 2230 | } | 2222 | } |
| 2231 | 2223 | ||
| 2232 | static inline cube_fast_t | 2224 | _static_inline cube_fast_t |
| 2233 | _trans_FRr(cube_fast_t c) | 2225 | _trans_FRr(cube_fast_t c) |
| 2234 | { | 2226 | { |
| 2235 | cube_fast_t ret; | 2227 | cube_fast_t ret; |
| @@ -2248,7 +2240,7 @@ _trans_FRr(cube_fast_t c) | |||
| 2248 | return ret; | 2240 | return ret; |
| 2249 | } | 2241 | } |
| 2250 | 2242 | ||
| 2251 | static inline cube_fast_t | 2243 | _static_inline cube_fast_t |
| 2252 | _trans_FDr(cube_fast_t c) | 2244 | _trans_FDr(cube_fast_t c) |
| 2253 | { | 2245 | { |
| 2254 | cube_fast_t ret; | 2246 | cube_fast_t ret; |
| @@ -2267,7 +2259,7 @@ _trans_FDr(cube_fast_t c) | |||
| 2267 | return ret; | 2259 | return ret; |
| 2268 | } | 2260 | } |
| 2269 | 2261 | ||
| 2270 | static inline cube_fast_t | 2262 | _static_inline cube_fast_t |
| 2271 | _trans_FLr(cube_fast_t c) | 2263 | _trans_FLr(cube_fast_t c) |
| 2272 | { | 2264 | { |
| 2273 | cube_fast_t ret; | 2265 | cube_fast_t ret; |
| @@ -2286,7 +2278,7 @@ _trans_FLr(cube_fast_t c) | |||
| 2286 | return ret; | 2278 | return ret; |
| 2287 | } | 2279 | } |
| 2288 | 2280 | ||
| 2289 | static inline cube_fast_t | 2281 | _static_inline cube_fast_t |
| 2290 | _trans_BUr(cube_fast_t c) | 2282 | _trans_BUr(cube_fast_t c) |
| 2291 | { | 2283 | { |
| 2292 | cube_fast_t ret; | 2284 | cube_fast_t ret; |
| @@ -2305,7 +2297,7 @@ _trans_BUr(cube_fast_t c) | |||
| 2305 | return ret; | 2297 | return ret; |
| 2306 | } | 2298 | } |
| 2307 | 2299 | ||
| 2308 | static inline cube_fast_t | 2300 | _static_inline cube_fast_t |
| 2309 | _trans_BRr(cube_fast_t c) | 2301 | _trans_BRr(cube_fast_t c) |
| 2310 | { | 2302 | { |
| 2311 | cube_fast_t ret; | 2303 | cube_fast_t ret; |
| @@ -2324,7 +2316,7 @@ _trans_BRr(cube_fast_t c) | |||
| 2324 | return ret; | 2316 | return ret; |
| 2325 | } | 2317 | } |
| 2326 | 2318 | ||
| 2327 | static inline cube_fast_t | 2319 | _static_inline cube_fast_t |
| 2328 | _trans_BDr(cube_fast_t c) | 2320 | _trans_BDr(cube_fast_t c) |
| 2329 | { | 2321 | { |
| 2330 | cube_fast_t ret; | 2322 | cube_fast_t ret; |
| @@ -2343,7 +2335,7 @@ _trans_BDr(cube_fast_t c) | |||
| 2343 | return ret; | 2335 | return ret; |
| 2344 | } | 2336 | } |
| 2345 | 2337 | ||
| 2346 | static inline cube_fast_t | 2338 | _static_inline cube_fast_t |
| 2347 | _trans_BLr(cube_fast_t c) | 2339 | _trans_BLr(cube_fast_t c) |
| 2348 | { | 2340 | { |
| 2349 | cube_fast_t ret; | 2341 | cube_fast_t ret; |
| @@ -2362,7 +2354,7 @@ _trans_BLr(cube_fast_t c) | |||
| 2362 | return ret; | 2354 | return ret; |
| 2363 | } | 2355 | } |
| 2364 | 2356 | ||
| 2365 | static inline cube_fast_t | 2357 | _static_inline cube_fast_t |
| 2366 | _trans_UFm(cube_fast_t c) | 2358 | _trans_UFm(cube_fast_t c) |
| 2367 | { | 2359 | { |
| 2368 | cube_fast_t ret; | 2360 | cube_fast_t ret; |
| @@ -2382,7 +2374,7 @@ _trans_UFm(cube_fast_t c) | |||
| 2382 | return ret; | 2374 | return ret; |
| 2383 | } | 2375 | } |
| 2384 | 2376 | ||
| 2385 | static inline cube_fast_t | 2377 | _static_inline cube_fast_t |
| 2386 | _trans_ULm(cube_fast_t c) | 2378 | _trans_ULm(cube_fast_t c) |
| 2387 | { | 2379 | { |
| 2388 | cube_fast_t ret; | 2380 | cube_fast_t ret; |
| @@ -2402,7 +2394,7 @@ _trans_ULm(cube_fast_t c) | |||
| 2402 | return ret; | 2394 | return ret; |
| 2403 | } | 2395 | } |
| 2404 | 2396 | ||
| 2405 | static inline cube_fast_t | 2397 | _static_inline cube_fast_t |
| 2406 | _trans_UBm(cube_fast_t c) | 2398 | _trans_UBm(cube_fast_t c) |
| 2407 | { | 2399 | { |
| 2408 | cube_fast_t ret; | 2400 | cube_fast_t ret; |
| @@ -2422,7 +2414,7 @@ _trans_UBm(cube_fast_t c) | |||
| 2422 | return ret; | 2414 | return ret; |
| 2423 | } | 2415 | } |
| 2424 | 2416 | ||
| 2425 | static inline cube_fast_t | 2417 | _static_inline cube_fast_t |
| 2426 | _trans_URm(cube_fast_t c) | 2418 | _trans_URm(cube_fast_t c) |
| 2427 | { | 2419 | { |
| 2428 | cube_fast_t ret; | 2420 | cube_fast_t ret; |
| @@ -2442,7 +2434,7 @@ _trans_URm(cube_fast_t c) | |||
| 2442 | return ret; | 2434 | return ret; |
| 2443 | } | 2435 | } |
| 2444 | 2436 | ||
| 2445 | static inline cube_fast_t | 2437 | _static_inline cube_fast_t |
| 2446 | _trans_DFm(cube_fast_t c) | 2438 | _trans_DFm(cube_fast_t c) |
| 2447 | { | 2439 | { |
| 2448 | cube_fast_t ret; | 2440 | cube_fast_t ret; |
| @@ -2462,7 +2454,7 @@ _trans_DFm(cube_fast_t c) | |||
| 2462 | return ret; | 2454 | return ret; |
| 2463 | } | 2455 | } |
| 2464 | 2456 | ||
| 2465 | static inline cube_fast_t | 2457 | _static_inline cube_fast_t |
| 2466 | _trans_DLm(cube_fast_t c) | 2458 | _trans_DLm(cube_fast_t c) |
| 2467 | { | 2459 | { |
| 2468 | cube_fast_t ret; | 2460 | cube_fast_t ret; |
| @@ -2482,7 +2474,7 @@ _trans_DLm(cube_fast_t c) | |||
| 2482 | return ret; | 2474 | return ret; |
| 2483 | } | 2475 | } |
| 2484 | 2476 | ||
| 2485 | static inline cube_fast_t | 2477 | _static_inline cube_fast_t |
| 2486 | _trans_DBm(cube_fast_t c) | 2478 | _trans_DBm(cube_fast_t c) |
| 2487 | { | 2479 | { |
| 2488 | cube_fast_t ret; | 2480 | cube_fast_t ret; |
| @@ -2502,7 +2494,7 @@ _trans_DBm(cube_fast_t c) | |||
| 2502 | return ret; | 2494 | return ret; |
| 2503 | } | 2495 | } |
| 2504 | 2496 | ||
| 2505 | static inline cube_fast_t | 2497 | _static_inline cube_fast_t |
| 2506 | _trans_DRm(cube_fast_t c) | 2498 | _trans_DRm(cube_fast_t c) |
| 2507 | { | 2499 | { |
| 2508 | cube_fast_t ret; | 2500 | cube_fast_t ret; |
| @@ -2522,7 +2514,7 @@ _trans_DRm(cube_fast_t c) | |||
| 2522 | return ret; | 2514 | return ret; |
| 2523 | } | 2515 | } |
| 2524 | 2516 | ||
| 2525 | static inline cube_fast_t | 2517 | _static_inline cube_fast_t |
| 2526 | _trans_RUm(cube_fast_t c) | 2518 | _trans_RUm(cube_fast_t c) |
| 2527 | { | 2519 | { |
| 2528 | cube_fast_t ret; | 2520 | cube_fast_t ret; |
| @@ -2542,7 +2534,7 @@ _trans_RUm(cube_fast_t c) | |||
| 2542 | return ret; | 2534 | return ret; |
| 2543 | } | 2535 | } |
| 2544 | 2536 | ||
| 2545 | static inline cube_fast_t | 2537 | _static_inline cube_fast_t |
| 2546 | _trans_RFm(cube_fast_t c) | 2538 | _trans_RFm(cube_fast_t c) |
| 2547 | { | 2539 | { |
| 2548 | cube_fast_t ret; | 2540 | cube_fast_t ret; |
| @@ -2562,7 +2554,7 @@ _trans_RFm(cube_fast_t c) | |||
| 2562 | return ret; | 2554 | return ret; |
| 2563 | } | 2555 | } |
| 2564 | 2556 | ||
| 2565 | static inline cube_fast_t | 2557 | _static_inline cube_fast_t |
| 2566 | _trans_RDm(cube_fast_t c) | 2558 | _trans_RDm(cube_fast_t c) |
| 2567 | { | 2559 | { |
| 2568 | cube_fast_t ret; | 2560 | cube_fast_t ret; |
| @@ -2582,7 +2574,7 @@ _trans_RDm(cube_fast_t c) | |||
| 2582 | return ret; | 2574 | return ret; |
| 2583 | } | 2575 | } |
| 2584 | 2576 | ||
| 2585 | static inline cube_fast_t | 2577 | _static_inline cube_fast_t |
| 2586 | _trans_RBm(cube_fast_t c) | 2578 | _trans_RBm(cube_fast_t c) |
| 2587 | { | 2579 | { |
| 2588 | cube_fast_t ret; | 2580 | cube_fast_t ret; |
| @@ -2602,7 +2594,7 @@ _trans_RBm(cube_fast_t c) | |||
| 2602 | return ret; | 2594 | return ret; |
| 2603 | } | 2595 | } |
| 2604 | 2596 | ||
| 2605 | static inline cube_fast_t | 2597 | _static_inline cube_fast_t |
| 2606 | _trans_LUm(cube_fast_t c) | 2598 | _trans_LUm(cube_fast_t c) |
| 2607 | { | 2599 | { |
| 2608 | cube_fast_t ret; | 2600 | cube_fast_t ret; |
| @@ -2622,7 +2614,7 @@ _trans_LUm(cube_fast_t c) | |||
| 2622 | return ret; | 2614 | return ret; |
| 2623 | } | 2615 | } |
| 2624 | 2616 | ||
| 2625 | static inline cube_fast_t | 2617 | _static_inline cube_fast_t |
| 2626 | _trans_LFm(cube_fast_t c) | 2618 | _trans_LFm(cube_fast_t c) |
| 2627 | { | 2619 | { |
| 2628 | cube_fast_t ret; | 2620 | cube_fast_t ret; |
| @@ -2642,7 +2634,7 @@ _trans_LFm(cube_fast_t c) | |||
| 2642 | return ret; | 2634 | return ret; |
| 2643 | } | 2635 | } |
| 2644 | 2636 | ||
| 2645 | static inline cube_fast_t | 2637 | _static_inline cube_fast_t |
| 2646 | _trans_LDm(cube_fast_t c) | 2638 | _trans_LDm(cube_fast_t c) |
| 2647 | { | 2639 | { |
| 2648 | cube_fast_t ret; | 2640 | cube_fast_t ret; |
| @@ -2662,7 +2654,7 @@ _trans_LDm(cube_fast_t c) | |||
| 2662 | return ret; | 2654 | return ret; |
| 2663 | } | 2655 | } |
| 2664 | 2656 | ||
| 2665 | static inline cube_fast_t | 2657 | _static_inline cube_fast_t |
| 2666 | _trans_LBm(cube_fast_t c) | 2658 | _trans_LBm(cube_fast_t c) |
| 2667 | { | 2659 | { |
| 2668 | cube_fast_t ret; | 2660 | cube_fast_t ret; |
| @@ -2682,7 +2674,7 @@ _trans_LBm(cube_fast_t c) | |||
| 2682 | return ret; | 2674 | return ret; |
| 2683 | } | 2675 | } |
| 2684 | 2676 | ||
| 2685 | static inline cube_fast_t | 2677 | _static_inline cube_fast_t |
| 2686 | _trans_FUm(cube_fast_t c) | 2678 | _trans_FUm(cube_fast_t c) |
| 2687 | { | 2679 | { |
| 2688 | cube_fast_t ret; | 2680 | cube_fast_t ret; |
| @@ -2702,7 +2694,7 @@ _trans_FUm(cube_fast_t c) | |||
| 2702 | return ret; | 2694 | return ret; |
| 2703 | } | 2695 | } |
| 2704 | 2696 | ||
| 2705 | static inline cube_fast_t | 2697 | _static_inline cube_fast_t |
| 2706 | _trans_FRm(cube_fast_t c) | 2698 | _trans_FRm(cube_fast_t c) |
| 2707 | { | 2699 | { |
| 2708 | cube_fast_t ret; | 2700 | cube_fast_t ret; |
| @@ -2722,7 +2714,7 @@ _trans_FRm(cube_fast_t c) | |||
| 2722 | return ret; | 2714 | return ret; |
| 2723 | } | 2715 | } |
| 2724 | 2716 | ||
| 2725 | static inline cube_fast_t | 2717 | _static_inline cube_fast_t |
| 2726 | _trans_FDm(cube_fast_t c) | 2718 | _trans_FDm(cube_fast_t c) |
| 2727 | { | 2719 | { |
| 2728 | cube_fast_t ret; | 2720 | cube_fast_t ret; |
| @@ -2742,7 +2734,7 @@ _trans_FDm(cube_fast_t c) | |||
| 2742 | return ret; | 2734 | return ret; |
| 2743 | } | 2735 | } |
| 2744 | 2736 | ||
| 2745 | static inline cube_fast_t | 2737 | _static_inline cube_fast_t |
| 2746 | _trans_FLm(cube_fast_t c) | 2738 | _trans_FLm(cube_fast_t c) |
| 2747 | { | 2739 | { |
| 2748 | cube_fast_t ret; | 2740 | cube_fast_t ret; |
| @@ -2762,7 +2754,7 @@ _trans_FLm(cube_fast_t c) | |||
| 2762 | return ret; | 2754 | return ret; |
| 2763 | } | 2755 | } |
| 2764 | 2756 | ||
| 2765 | static inline cube_fast_t | 2757 | _static_inline cube_fast_t |
| 2766 | _trans_BUm(cube_fast_t c) | 2758 | _trans_BUm(cube_fast_t c) |
| 2767 | { | 2759 | { |
| 2768 | cube_fast_t ret; | 2760 | cube_fast_t ret; |
| @@ -2782,7 +2774,7 @@ _trans_BUm(cube_fast_t c) | |||
| 2782 | return ret; | 2774 | return ret; |
| 2783 | } | 2775 | } |
| 2784 | 2776 | ||
| 2785 | static inline cube_fast_t | 2777 | _static_inline cube_fast_t |
| 2786 | _trans_BRm(cube_fast_t c) | 2778 | _trans_BRm(cube_fast_t c) |
| 2787 | { | 2779 | { |
| 2788 | cube_fast_t ret; | 2780 | cube_fast_t ret; |
| @@ -2802,7 +2794,7 @@ _trans_BRm(cube_fast_t c) | |||
| 2802 | return ret; | 2794 | return ret; |
| 2803 | } | 2795 | } |
| 2804 | 2796 | ||
| 2805 | static inline cube_fast_t | 2797 | _static_inline cube_fast_t |
| 2806 | _trans_BDm(cube_fast_t c) | 2798 | _trans_BDm(cube_fast_t c) |
| 2807 | { | 2799 | { |
| 2808 | cube_fast_t ret; | 2800 | cube_fast_t ret; |
| @@ -2822,7 +2814,7 @@ _trans_BDm(cube_fast_t c) | |||
| 2822 | return ret; | 2814 | return ret; |
| 2823 | } | 2815 | } |
| 2824 | 2816 | ||
| 2825 | static inline cube_fast_t | 2817 | _static_inline cube_fast_t |
| 2826 | _trans_BLm(cube_fast_t c) | 2818 | _trans_BLm(cube_fast_t c) |
| 2827 | { | 2819 | { |
| 2828 | cube_fast_t ret; | 2820 | cube_fast_t ret; |
| @@ -2842,7 +2834,7 @@ _trans_BLm(cube_fast_t c) | |||
| 2842 | return ret; | 2834 | return ret; |
| 2843 | } | 2835 | } |
| 2844 | 2836 | ||
| 2845 | static cube_fast_t | 2837 | _static cube_fast_t |
| 2846 | cubetofast(cube_t cube) | 2838 | cubetofast(cube_t cube) |
| 2847 | { | 2839 | { |
| 2848 | cube_fast_t fast; | 2840 | cube_fast_t fast; |
| @@ -2850,7 +2842,7 @@ cubetofast(cube_t cube) | |||
| 2850 | return fast; | 2842 | return fast; |
| 2851 | } | 2843 | } |
| 2852 | 2844 | ||
| 2853 | static cube_t | 2845 | _static cube_t |
| 2854 | fasttocube(cube_fast_t fast) | 2846 | fasttocube(cube_fast_t fast) |
| 2855 | { | 2847 | { |
| 2856 | cube_t cube; | 2848 | cube_t cube; |
| @@ -2858,7 +2850,7 @@ fasttocube(cube_fast_t fast) | |||
| 2858 | return cube; | 2850 | return cube; |
| 2859 | } | 2851 | } |
| 2860 | 2852 | ||
| 2861 | static inline bool | 2853 | _static_inline bool |
| 2862 | equal_fast(cube_fast_t c1, cube_fast_t c2) | 2854 | equal_fast(cube_fast_t c1, cube_fast_t c2) |
| 2863 | { | 2855 | { |
| 2864 | uint8_t i; | 2856 | uint8_t i; |
| @@ -2873,13 +2865,29 @@ equal_fast(cube_fast_t c1, cube_fast_t c2) | |||
| 2873 | return ret; | 2865 | return ret; |
| 2874 | } | 2866 | } |
| 2875 | 2867 | ||
| 2876 | static inline bool | 2868 | _static_inline bool |
| 2877 | issolved_fast(cube_fast_t cube) | 2869 | issolved_fast(cube_fast_t cube) |
| 2878 | { | 2870 | { |
| 2879 | return equal_fast(cube, solved_fast); | 2871 | return equal_fast(cube, solved_fast); |
| 2880 | } | 2872 | } |
| 2881 | 2873 | ||
| 2882 | static inline cube_fast_t | 2874 | _static_inline cube_fast_t |
| 2875 | invertco_fast(cube_fast_t c) | ||
| 2876 | { | ||
| 2877 | uint8_t i, piece, orien; | ||
| 2878 | cube_fast_t ret; | ||
| 2879 | |||
| 2880 | ret = c; | ||
| 2881 | for (i = 0; i < 8; i++) { | ||
| 2882 | piece = c.corner[i]; | ||
| 2883 | orien = ((piece << 1) | (piece >> 1)) & _cobits2; | ||
| 2884 | ret.corner[i] = (piece & _pbits) | orien; | ||
| 2885 | } | ||
| 2886 | |||
| 2887 | return ret; | ||
| 2888 | } | ||
| 2889 | |||
| 2890 | _static_inline cube_fast_t | ||
| 2883 | inverse_fast(cube_fast_t cube) | 2891 | inverse_fast(cube_fast_t cube) |
| 2884 | { | 2892 | { |
| 2885 | cube_fast_t ret; | 2893 | cube_fast_t ret; |
| @@ -2902,7 +2910,7 @@ inverse_fast(cube_fast_t cube) | |||
| 2902 | return ret; | 2910 | return ret; |
| 2903 | } | 2911 | } |
| 2904 | 2912 | ||
| 2905 | static inline cube_fast_t | 2913 | _static_inline cube_fast_t |
| 2906 | compose_fast(cube_fast_t c1, cube_fast_t c2) | 2914 | compose_fast(cube_fast_t c1, cube_fast_t c2) |
| 2907 | { | 2915 | { |
| 2908 | cube_fast_t ret; | 2916 | cube_fast_t ret; |
| @@ -2931,7 +2939,7 @@ compose_fast(cube_fast_t c1, cube_fast_t c2) | |||
| 2931 | return ret; | 2939 | return ret; |
| 2932 | } | 2940 | } |
| 2933 | 2941 | ||
| 2934 | static inline int64_t | 2942 | _static_inline int64_t |
| 2935 | coord_fast_eo(cube_fast_t cube) | 2943 | coord_fast_eo(cube_fast_t cube) |
| 2936 | { | 2944 | { |
| 2937 | int i, p; | 2945 | int i, p; |
| @@ -2954,32 +2962,43 @@ Some of these routines depend on the efficient functions implemented in the | |||
| 2954 | previous sections, while some other operate directly on the cube. | 2962 | previous sections, while some other operate directly on the cube. |
| 2955 | ******************************************************************************/ | 2963 | ******************************************************************************/ |
| 2956 | 2964 | ||
| 2957 | static inline uint8_t movebase(uint8_t); | 2965 | _static cube_t zero = { .corner = {0}, .edge = {0} }; |
| 2958 | static inline uint8_t moveaxis(uint8_t); | 2966 | _static cube_t solved = { |
| 2959 | static uint8_t readco(char *); | ||
| 2960 | static uint8_t readcp(char *); | ||
| 2961 | static uint8_t readeo(char *); | ||
| 2962 | static uint8_t readep(char *); | ||
| 2963 | static int permsign(uint8_t *, int); | ||
| 2964 | static cube_t readcube_H48(char *); | ||
| 2965 | static void writecube_AVX(cube_t, char *); | ||
| 2966 | static void writecube_H48(cube_t, char *); | ||
| 2967 | static int writepiece_SRC(uint8_t, char *); | ||
| 2968 | static void writecube_SRC(cube_t, char *); | ||
| 2969 | static uint8_t readmove(char); | ||
| 2970 | static uint8_t readmodifier(char); | ||
| 2971 | static uint8_t readtrans(char *); | ||
| 2972 | static int writemoves(uint8_t *, int, char *); | ||
| 2973 | static void writetrans(uint8_t, char *); | ||
| 2974 | static cube_fast_t transform(cube_fast_t, uint8_t); | ||
| 2975 | static cube_fast_t move(cube_fast_t, uint8_t); | ||
| 2976 | |||
| 2977 | static cube_t zero = { .corner = {0}, .edge = {0} }; | ||
| 2978 | static cube_t solved = { | ||
| 2979 | .corner = {0, 1, 2, 3, 4, 5, 6, 7}, | 2967 | .corner = {0, 1, 2, 3, 4, 5, 6, 7}, |
| 2980 | .edge = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} | 2968 | .edge = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} |
| 2981 | }; | 2969 | }; |
| 2982 | 2970 | ||
| 2971 | cube_t solvedcube(void); | ||
| 2972 | bool isconsistent(cube_t); | ||
| 2973 | bool issolvable(cube_t); | ||
| 2974 | bool issolved(cube_t cube); | ||
| 2975 | bool equal(cube_t, cube_t); | ||
| 2976 | bool iserror(cube_t); | ||
| 2977 | cube_t compose(cube_t, cube_t); | ||
| 2978 | cube_t inverse(cube_t); | ||
| 2979 | cube_t applymoves(cube_t, char *); | ||
| 2980 | cube_t applytrans(cube_t, char *); | ||
| 2981 | cube_t readcube(char *, char *); | ||
| 2982 | void writecube(char *, cube_t, char *); | ||
| 2983 | |||
| 2984 | _static int permsign(uint8_t *, int); | ||
| 2985 | _static uint8_t readco(char *); | ||
| 2986 | _static uint8_t readcp(char *); | ||
| 2987 | _static uint8_t readeo(char *); | ||
| 2988 | _static uint8_t readep(char *); | ||
| 2989 | _static cube_t readcube_H48(char *); | ||
| 2990 | _static int writepiece_SRC(uint8_t, char *); | ||
| 2991 | _static void writecube_AVX(cube_t, char *); | ||
| 2992 | _static void writecube_H48(cube_t, char *); | ||
| 2993 | _static void writecube_SRC(cube_t, char *); | ||
| 2994 | _static uint8_t readmove(char); | ||
| 2995 | _static uint8_t readmodifier(char); | ||
| 2996 | _static uint8_t readtrans(char *); | ||
| 2997 | _static int writemoves(uint8_t *, int, char *); | ||
| 2998 | _static void writetrans(uint8_t, char *); | ||
| 2999 | _static cube_fast_t move(cube_fast_t, uint8_t); | ||
| 3000 | _static cube_fast_t transform(cube_fast_t, uint8_t); | ||
| 3001 | |||
| 2983 | cube_t | 3002 | cube_t |
| 2984 | solvedcube(void) | 3003 | solvedcube(void) |
| 2985 | { | 3004 | { |
| @@ -2987,6 +3006,111 @@ solvedcube(void) | |||
| 2987 | } | 3006 | } |
| 2988 | 3007 | ||
| 2989 | bool | 3008 | bool |
| 3009 | isconsistent(cube_t cube) | ||
| 3010 | { | ||
| 3011 | uint8_t i, p, e, piece; | ||
| 3012 | bool found[12]; | ||
| 3013 | |||
| 3014 | for (i = 0; i < 12; i++) | ||
| 3015 | found[i] = false; | ||
| 3016 | for (i = 0; i < 12; i++) { | ||
| 3017 | piece = cube.edge[i]; | ||
| 3018 | p = piece & _pbits; | ||
| 3019 | e = piece & _eobit; | ||
| 3020 | if (p >= 12) | ||
| 3021 | goto inconsistent_ep; | ||
| 3022 | if (e != 0 && e != _eobit) | ||
| 3023 | goto inconsistent_eo; | ||
| 3024 | found[p] = true; | ||
| 3025 | } | ||
| 3026 | for (i = 0; i < 12; i++) | ||
| 3027 | if (!found[i]) | ||
| 3028 | goto inconsistent_ep; | ||
| 3029 | |||
| 3030 | for (i = 0; i < 8; i++) | ||
| 3031 | found[i] = false; | ||
| 3032 | for (i = 0; i < 8; i++) { | ||
| 3033 | piece = cube.corner[i]; | ||
| 3034 | p = piece & _pbits; | ||
| 3035 | e = piece & _cobits; | ||
| 3036 | if (p >= 8) | ||
| 3037 | goto inconsistent_cp; | ||
| 3038 | if (e != 0 && e != _ctwist_cw && e != _ctwist_ccw) | ||
| 3039 | goto inconsistent_co; | ||
| 3040 | found[p] = true; | ||
| 3041 | } | ||
| 3042 | for (i = 0; i < 8; i++) | ||
| 3043 | if (!found[i]) | ||
| 3044 | goto inconsistent_co; | ||
| 3045 | |||
| 3046 | return true; | ||
| 3047 | |||
| 3048 | inconsistent_ep: | ||
| 3049 | DBG_LOG("Inconsistent EP\n"); | ||
| 3050 | return false; | ||
| 3051 | inconsistent_cp: | ||
| 3052 | DBG_LOG("Inconsistent CP\n"); | ||
| 3053 | return false; | ||
| 3054 | inconsistent_eo: | ||
| 3055 | DBG_LOG("Inconsistent EO\n"); | ||
| 3056 | return false; | ||
| 3057 | inconsistent_co: | ||
| 3058 | DBG_LOG("Inconsistent CO\n"); | ||
| 3059 | return false; | ||
| 3060 | } | ||
| 3061 | |||
| 3062 | bool | ||
| 3063 | issolvable(cube_t cube) | ||
| 3064 | { | ||
| 3065 | uint8_t i, eo, co, piece, edges[12], corners[8]; | ||
| 3066 | |||
| 3067 | DBG_ASSERT(isconsistent(cube), false, | ||
| 3068 | "issolvable: cube is inconsistent\n"); | ||
| 3069 | |||
| 3070 | for (i = 0; i < 12; i++) | ||
| 3071 | edges[i] = cube.edge[i] & _pbits; | ||
| 3072 | for (i = 0; i < 8; i++) | ||
| 3073 | corners[i] = cube.corner[i] & _pbits; | ||
| 3074 | |||
| 3075 | if (permsign(edges, 12) != permsign(corners, 8)) | ||
| 3076 | goto issolvable_parity; | ||
| 3077 | |||
| 3078 | eo = 0; | ||
| 3079 | for (i = 0; i < 12; i++) { | ||
| 3080 | piece = cube.edge[i]; | ||
| 3081 | eo += (piece & _eobit) >> _eoshift; | ||
| 3082 | } | ||
| 3083 | if (eo % 2 != 0) | ||
| 3084 | goto issolvable_eo; | ||
| 3085 | |||
| 3086 | co = 0; | ||
| 3087 | for (i = 0; i < 8; i++) { | ||
| 3088 | piece = cube.corner[i]; | ||
| 3089 | co += (piece & _cobits) >> _coshift; | ||
| 3090 | } | ||
| 3091 | if (co % 3 != 0) | ||
| 3092 | goto issolvable_co; | ||
| 3093 | |||
| 3094 | return true; | ||
| 3095 | |||
| 3096 | issolvable_parity: | ||
| 3097 | DBG_LOG("EP and CP parities are different\n"); | ||
| 3098 | return false; | ||
| 3099 | issolvable_eo: | ||
| 3100 | DBG_LOG("Odd number of flipped edges\n"); | ||
| 3101 | return false; | ||
| 3102 | issolvable_co: | ||
| 3103 | DBG_LOG("Sum of corner orientation is not multiple of 3\n"); | ||
| 3104 | return false; | ||
| 3105 | } | ||
| 3106 | |||
| 3107 | bool | ||
| 3108 | issolved(cube_t cube) | ||
| 3109 | { | ||
| 3110 | return equal(cube, solved); | ||
| 3111 | } | ||
| 3112 | |||
| 3113 | bool | ||
| 2990 | equal(cube_t c1, cube_t c2) | 3114 | equal(cube_t c1, cube_t c2) |
| 2991 | { | 3115 | { |
| 2992 | int i; | 3116 | int i; |
| @@ -3007,19 +3131,133 @@ iserror(cube_t cube) | |||
| 3007 | return equal(cube, zero); | 3131 | return equal(cube, zero); |
| 3008 | } | 3132 | } |
| 3009 | 3133 | ||
| 3010 | static inline uint8_t | 3134 | cube_t |
| 3011 | movebase(uint8_t move) | 3135 | compose(cube_t c1, cube_t c2) |
| 3012 | { | 3136 | { |
| 3013 | return move / 3; | 3137 | DBG_ASSERT(isconsistent(c1) && isconsistent(c2), |
| 3138 | zero, "compose error: inconsistent cube\n") | ||
| 3139 | |||
| 3140 | return fasttocube(compose_fast(cubetofast(c1), cubetofast(c2))); | ||
| 3014 | } | 3141 | } |
| 3015 | 3142 | ||
| 3016 | static inline uint8_t | 3143 | cube_t |
| 3017 | moveaxis(uint8_t move) | 3144 | inverse(cube_t cube) |
| 3018 | { | 3145 | { |
| 3019 | return move / 6; | 3146 | DBG_ASSERT(isconsistent(cube), zero, |
| 3147 | "inverse error: inconsistent cube\n"); | ||
| 3148 | |||
| 3149 | return fasttocube(inverse_fast(cubetofast(cube))); | ||
| 3020 | } | 3150 | } |
| 3021 | 3151 | ||
| 3022 | static uint8_t | 3152 | cube_t |
| 3153 | applymoves(cube_t cube, char *buf) | ||
| 3154 | { | ||
| 3155 | cube_fast_t fast; | ||
| 3156 | uint8_t r, m; | ||
| 3157 | char *b; | ||
| 3158 | |||
| 3159 | DBG_ASSERT(isconsistent(cube), zero, | ||
| 3160 | "move error: inconsistent cube\n"); | ||
| 3161 | |||
| 3162 | fast = cubetofast(cube); | ||
| 3163 | |||
| 3164 | for (b = buf; *b != '\0'; b++) { | ||
| 3165 | while (*b == ' ' || *b == '\t' || *b == '\n') | ||
| 3166 | b++; | ||
| 3167 | if (*b == '\0') | ||
| 3168 | goto readmoves_finish; | ||
| 3169 | if ((r = readmove(*b)) == _error) | ||
| 3170 | goto readmoves_error; | ||
| 3171 | if ((m = readmodifier(*(b+1))) != 0) | ||
| 3172 | b++; | ||
| 3173 | fast = move(fast, r + m); | ||
| 3174 | } | ||
| 3175 | |||
| 3176 | readmoves_finish: | ||
| 3177 | return fasttocube(fast); | ||
| 3178 | |||
| 3179 | readmoves_error: | ||
| 3180 | DBG_LOG("readmoves error\n"); | ||
| 3181 | return zero; | ||
| 3182 | } | ||
| 3183 | |||
| 3184 | cube_t | ||
| 3185 | applytrans(cube_t cube, char *buf) | ||
| 3186 | { | ||
| 3187 | cube_fast_t fast; | ||
| 3188 | uint8_t t; | ||
| 3189 | |||
| 3190 | DBG_ASSERT(isconsistent(cube), zero, | ||
| 3191 | "transformation error: inconsistent cube\n"); | ||
| 3192 | |||
| 3193 | t = readtrans(buf); | ||
| 3194 | fast = cubetofast(cube); | ||
| 3195 | fast = transform(fast, t); | ||
| 3196 | |||
| 3197 | return fasttocube(fast); | ||
| 3198 | } | ||
| 3199 | |||
| 3200 | cube_t | ||
| 3201 | readcube(char *format, char *buf) | ||
| 3202 | { | ||
| 3203 | cube_t cube; | ||
| 3204 | |||
| 3205 | if (!strcmp(format, "H48")) { | ||
| 3206 | cube = readcube_H48(buf); | ||
| 3207 | } else { | ||
| 3208 | DBG_LOG("Cannot read cube in the given format\n"); | ||
| 3209 | cube = zero; | ||
| 3210 | } | ||
| 3211 | |||
| 3212 | return cube; | ||
| 3213 | } | ||
| 3214 | |||
| 3215 | void | ||
| 3216 | writecube(char *format, cube_t cube, char *buf) | ||
| 3217 | { | ||
| 3218 | char *errormsg; | ||
| 3219 | size_t len; | ||
| 3220 | |||
| 3221 | if (!isconsistent(cube)) { | ||
| 3222 | errormsg = "ERROR: cannot write inconsistent cube"; | ||
| 3223 | goto writecube_error; | ||
| 3224 | } | ||
| 3225 | |||
| 3226 | if (!strcmp(format, "H48")) { | ||
| 3227 | writecube_H48(cube, buf); | ||
| 3228 | } else if (!strcmp(format, "SRC")) { | ||
| 3229 | writecube_SRC(cube, buf); | ||
| 3230 | } else if (!strcmp(format, "AVX")) { | ||
| 3231 | writecube_AVX(cube, buf); | ||
| 3232 | } else { | ||
| 3233 | errormsg = "ERROR: cannot write cube in the given format"; | ||
| 3234 | goto writecube_error; | ||
| 3235 | } | ||
| 3236 | |||
| 3237 | return; | ||
| 3238 | |||
| 3239 | writecube_error: | ||
| 3240 | DBG_LOG("writecube error, see stdout for details\n"); | ||
| 3241 | len = strlen(errormsg); | ||
| 3242 | memcpy(buf, errormsg, len); | ||
| 3243 | buf[len] = '\n'; | ||
| 3244 | buf[len+1] = '\0'; | ||
| 3245 | } | ||
| 3246 | |||
| 3247 | _static int | ||
| 3248 | permsign(uint8_t *a, int n) | ||
| 3249 | { | ||
| 3250 | int i, j; | ||
| 3251 | uint8_t ret = 0; | ||
| 3252 | |||
| 3253 | for (i = 0; i < n; i++) | ||
| 3254 | for (j = i+1; j < n; j++) | ||
| 3255 | ret += a[i] > a[j] ? 1 : 0; | ||
| 3256 | |||
| 3257 | return ret % 2; | ||
| 3258 | } | ||
| 3259 | |||
| 3260 | _static uint8_t | ||
| 3023 | readco(char *str) | 3261 | readco(char *str) |
| 3024 | { | 3262 | { |
| 3025 | if (*str == '0') | 3263 | if (*str == '0') |
| @@ -3033,7 +3271,7 @@ readco(char *str) | |||
| 3033 | return _error; | 3271 | return _error; |
| 3034 | } | 3272 | } |
| 3035 | 3273 | ||
| 3036 | static uint8_t | 3274 | _static uint8_t |
| 3037 | readcp(char *str) | 3275 | readcp(char *str) |
| 3038 | { | 3276 | { |
| 3039 | uint8_t c; | 3277 | uint8_t c; |
| @@ -3047,7 +3285,7 @@ readcp(char *str) | |||
| 3047 | return _error; | 3285 | return _error; |
| 3048 | } | 3286 | } |
| 3049 | 3287 | ||
| 3050 | static uint8_t | 3288 | _static uint8_t |
| 3051 | readeo(char *str) | 3289 | readeo(char *str) |
| 3052 | { | 3290 | { |
| 3053 | if (*str == '0') | 3291 | if (*str == '0') |
| @@ -3059,7 +3297,7 @@ readeo(char *str) | |||
| 3059 | return _error; | 3297 | return _error; |
| 3060 | } | 3298 | } |
| 3061 | 3299 | ||
| 3062 | static uint8_t | 3300 | _static uint8_t |
| 3063 | readep(char *str) | 3301 | readep(char *str) |
| 3064 | { | 3302 | { |
| 3065 | uint8_t e; | 3303 | uint8_t e; |
| @@ -3072,7 +3310,7 @@ readep(char *str) | |||
| 3072 | return _error; | 3310 | return _error; |
| 3073 | } | 3311 | } |
| 3074 | 3312 | ||
| 3075 | static cube_t | 3313 | _static cube_t |
| 3076 | readcube_H48(char *buf) | 3314 | readcube_H48(char *buf) |
| 3077 | { | 3315 | { |
| 3078 | int i; | 3316 | int i; |
| @@ -3108,23 +3346,7 @@ readcube_H48(char *buf) | |||
| 3108 | return ret; | 3346 | return ret; |
| 3109 | } | 3347 | } |
| 3110 | 3348 | ||
| 3111 | cube_t | 3349 | _static int |
| 3112 | readcube(char *format, char *buf) | ||
| 3113 | { | ||
| 3114 | cube_t cube; | ||
| 3115 | |||
| 3116 | if (!strcmp(format, "H48")) { | ||
| 3117 | cube = readcube_H48(buf); | ||
| 3118 | } else { | ||
| 3119 | DBG_LOG("Cannot read cube in the given format\n"); | ||
| 3120 | cube = zero; | ||
| 3121 | } | ||
| 3122 | |||
| 3123 | return cube; | ||
| 3124 | } | ||
| 3125 | |||
| 3126 | |||
| 3127 | static int | ||
| 3128 | writepiece_SRC(uint8_t piece, char *buf) | 3350 | writepiece_SRC(uint8_t piece, char *buf) |
| 3129 | { | 3351 | { |
| 3130 | char digits[3]; | 3352 | char digits[3]; |
| @@ -3147,7 +3369,7 @@ writepiece_SRC(uint8_t piece, char *buf) | |||
| 3147 | return len+2; | 3369 | return len+2; |
| 3148 | } | 3370 | } |
| 3149 | 3371 | ||
| 3150 | static void | 3372 | _static void |
| 3151 | writecube_AVX(cube_t cube, char *buf) | 3373 | writecube_AVX(cube_t cube, char *buf) |
| 3152 | { | 3374 | { |
| 3153 | int i, ptr; | 3375 | int i, ptr; |
| @@ -3172,7 +3394,7 @@ writecube_AVX(cube_t cube, char *buf) | |||
| 3172 | memcpy(buf+ptr-2, "\n)\0", 3); | 3394 | memcpy(buf+ptr-2, "\n)\0", 3); |
| 3173 | } | 3395 | } |
| 3174 | 3396 | ||
| 3175 | static void | 3397 | _static void |
| 3176 | writecube_H48(cube_t cube, char *buf) | 3398 | writecube_H48(cube_t cube, char *buf) |
| 3177 | { | 3399 | { |
| 3178 | uint8_t piece, perm, orient; | 3400 | uint8_t piece, perm, orient; |
| @@ -3201,7 +3423,7 @@ writecube_H48(cube_t cube, char *buf) | |||
| 3201 | buf[48+39] = '\0'; | 3423 | buf[48+39] = '\0'; |
| 3202 | } | 3424 | } |
| 3203 | 3425 | ||
| 3204 | static void | 3426 | _static void |
| 3205 | writecube_SRC(cube_t cube, char *buf) | 3427 | writecube_SRC(cube_t cube, char *buf) |
| 3206 | { | 3428 | { |
| 3207 | int i, ptr; | 3429 | int i, ptr; |
| @@ -3226,39 +3448,7 @@ writecube_SRC(cube_t cube, char *buf) | |||
| 3226 | memcpy(buf+ptr-2, "}\n}\0", 4); | 3448 | memcpy(buf+ptr-2, "}\n}\0", 4); |
| 3227 | } | 3449 | } |
| 3228 | 3450 | ||
| 3229 | void | 3451 | _static uint8_t |
| 3230 | writecube(char *format, cube_t cube, char *buf) | ||
| 3231 | { | ||
| 3232 | char *errormsg; | ||
| 3233 | size_t len; | ||
| 3234 | |||
| 3235 | if (!isconsistent(cube)) { | ||
| 3236 | errormsg = "ERROR: cannot write inconsistent cube"; | ||
| 3237 | goto writecube_error; | ||
| 3238 | } | ||
| 3239 | |||
| 3240 | if (!strcmp(format, "H48")) { | ||
| 3241 | writecube_H48(cube, buf); | ||
| 3242 | } else if (!strcmp(format, "SRC")) { | ||
| 3243 | writecube_SRC(cube, buf); | ||
| 3244 | } else if (!strcmp(format, "AVX")) { | ||
| 3245 | writecube_AVX(cube, buf); | ||
| 3246 | } else { | ||
| 3247 | errormsg = "ERROR: cannot write cube in the given format"; | ||
| 3248 | goto writecube_error; | ||
| 3249 | } | ||
| 3250 | |||
| 3251 | return; | ||
| 3252 | |||
| 3253 | writecube_error: | ||
| 3254 | DBG_LOG("writecube error, see stdout for details\n"); | ||
| 3255 | len = strlen(errormsg); | ||
| 3256 | memcpy(buf, errormsg, len); | ||
| 3257 | buf[len] = '\n'; | ||
| 3258 | buf[len+1] = '\0'; | ||
| 3259 | } | ||
| 3260 | |||
| 3261 | static uint8_t | ||
| 3262 | readmove(char c) | 3452 | readmove(char c) |
| 3263 | { | 3453 | { |
| 3264 | switch (c) { | 3454 | switch (c) { |
| @@ -3279,7 +3469,7 @@ readmove(char c) | |||
| 3279 | } | 3469 | } |
| 3280 | } | 3470 | } |
| 3281 | 3471 | ||
| 3282 | static uint8_t | 3472 | _static uint8_t |
| 3283 | readmodifier(char c) | 3473 | readmodifier(char c) |
| 3284 | { | 3474 | { |
| 3285 | switch (c) { | 3475 | switch (c) { |
| @@ -3294,7 +3484,7 @@ readmodifier(char c) | |||
| 3294 | } | 3484 | } |
| 3295 | } | 3485 | } |
| 3296 | 3486 | ||
| 3297 | static uint8_t | 3487 | _static uint8_t |
| 3298 | readtrans(char *buf) | 3488 | readtrans(char *buf) |
| 3299 | { | 3489 | { |
| 3300 | uint8_t t; | 3490 | uint8_t t; |
| @@ -3307,7 +3497,7 @@ readtrans(char *buf) | |||
| 3307 | return _error; | 3497 | return _error; |
| 3308 | } | 3498 | } |
| 3309 | 3499 | ||
| 3310 | static int | 3500 | _static int |
| 3311 | writemoves(uint8_t *m, int n, char *buf) | 3501 | writemoves(uint8_t *m, int n, char *buf) |
| 3312 | { | 3502 | { |
| 3313 | int i; | 3503 | int i; |
| @@ -3329,7 +3519,7 @@ writemoves(uint8_t *m, int n, char *buf) | |||
| 3329 | return b - buf; | 3519 | return b - buf; |
| 3330 | } | 3520 | } |
| 3331 | 3521 | ||
| 3332 | static void | 3522 | _static void |
| 3333 | writetrans(uint8_t t, char *buf) | 3523 | writetrans(uint8_t t, char *buf) |
| 3334 | { | 3524 | { |
| 3335 | if (t >= 48) | 3525 | if (t >= 48) |
| @@ -3339,143 +3529,7 @@ writetrans(uint8_t t, char *buf) | |||
| 3339 | buf[11] = '\0'; | 3529 | buf[11] = '\0'; |
| 3340 | } | 3530 | } |
| 3341 | 3531 | ||
| 3342 | static int | 3532 | _static cube_fast_t |
| 3343 | permsign(uint8_t *a, int n) | ||
| 3344 | { | ||
| 3345 | int i, j; | ||
| 3346 | uint8_t ret = 0; | ||
| 3347 | |||
| 3348 | for (i = 0; i < n; i++) | ||
| 3349 | for (j = i+1; j < n; j++) | ||
| 3350 | ret += a[i] > a[j] ? 1 : 0; | ||
| 3351 | |||
| 3352 | return ret % 2; | ||
| 3353 | } | ||
| 3354 | |||
| 3355 | bool | ||
| 3356 | isconsistent(cube_t cube) | ||
| 3357 | { | ||
| 3358 | uint8_t i, p, e, piece; | ||
| 3359 | bool found[12]; | ||
| 3360 | |||
| 3361 | for (i = 0; i < 12; i++) | ||
| 3362 | found[i] = false; | ||
| 3363 | for (i = 0; i < 12; i++) { | ||
| 3364 | piece = cube.edge[i]; | ||
| 3365 | p = piece & _pbits; | ||
| 3366 | e = piece & _eobit; | ||
| 3367 | if (p >= 12) | ||
| 3368 | goto inconsistent_ep; | ||
| 3369 | if (e != 0 && e != _eobit) | ||
| 3370 | goto inconsistent_eo; | ||
| 3371 | found[p] = true; | ||
| 3372 | } | ||
| 3373 | for (i = 0; i < 12; i++) | ||
| 3374 | if (!found[i]) | ||
| 3375 | goto inconsistent_ep; | ||
| 3376 | |||
| 3377 | for (i = 0; i < 8; i++) | ||
| 3378 | found[i] = false; | ||
| 3379 | for (i = 0; i < 8; i++) { | ||
| 3380 | piece = cube.corner[i]; | ||
| 3381 | p = piece & _pbits; | ||
| 3382 | e = piece & _cobits; | ||
| 3383 | if (p >= 8) | ||
| 3384 | goto inconsistent_cp; | ||
| 3385 | if (e != 0 && e != _ctwist_cw && e != _ctwist_ccw) | ||
| 3386 | goto inconsistent_co; | ||
| 3387 | found[p] = true; | ||
| 3388 | } | ||
| 3389 | for (i = 0; i < 8; i++) | ||
| 3390 | if (!found[i]) | ||
| 3391 | goto inconsistent_co; | ||
| 3392 | |||
| 3393 | return true; | ||
| 3394 | |||
| 3395 | inconsistent_ep: | ||
| 3396 | DBG_LOG("Inconsistent EP\n"); | ||
| 3397 | return false; | ||
| 3398 | inconsistent_cp: | ||
| 3399 | DBG_LOG("Inconsistent CP\n"); | ||
| 3400 | return false; | ||
| 3401 | inconsistent_eo: | ||
| 3402 | DBG_LOG("Inconsistent EO\n"); | ||
| 3403 | return false; | ||
| 3404 | inconsistent_co: | ||
| 3405 | DBG_LOG("Inconsistent CO\n"); | ||
| 3406 | return false; | ||
| 3407 | } | ||
| 3408 | |||
| 3409 | bool | ||
| 3410 | issolvable(cube_t cube) | ||
| 3411 | { | ||
| 3412 | uint8_t i, eo, co, piece, edges[12], corners[8]; | ||
| 3413 | |||
| 3414 | DBG_ASSERT(isconsistent(cube), false, | ||
| 3415 | "issolvable: cube is inconsistent\n"); | ||
| 3416 | |||
| 3417 | for (i = 0; i < 12; i++) | ||
| 3418 | edges[i] = cube.edge[i] & _pbits; | ||
| 3419 | for (i = 0; i < 8; i++) | ||
| 3420 | corners[i] = cube.corner[i] & _pbits; | ||
| 3421 | |||
| 3422 | if (permsign(edges, 12) != permsign(corners, 8)) | ||
| 3423 | goto issolvable_parity; | ||
| 3424 | |||
| 3425 | eo = 0; | ||
| 3426 | for (i = 0; i < 12; i++) { | ||
| 3427 | piece = cube.edge[i]; | ||
| 3428 | eo += (piece & _eobit) >> _eoshift; | ||
| 3429 | } | ||
| 3430 | if (eo % 2 != 0) | ||
| 3431 | goto issolvable_eo; | ||
| 3432 | |||
| 3433 | co = 0; | ||
| 3434 | for (i = 0; i < 8; i++) { | ||
| 3435 | piece = cube.corner[i]; | ||
| 3436 | co += (piece & _cobits) >> _coshift; | ||
| 3437 | } | ||
| 3438 | if (co % 3 != 0) | ||
| 3439 | goto issolvable_co; | ||
| 3440 | |||
| 3441 | return true; | ||
| 3442 | |||
| 3443 | issolvable_parity: | ||
| 3444 | DBG_LOG("EP and CP parities are different\n"); | ||
| 3445 | return false; | ||
| 3446 | issolvable_eo: | ||
| 3447 | DBG_LOG("Odd number of flipped edges\n"); | ||
| 3448 | return false; | ||
| 3449 | issolvable_co: | ||
| 3450 | DBG_LOG("Sum of corner orientation is not multiple of 3\n"); | ||
| 3451 | return false; | ||
| 3452 | } | ||
| 3453 | |||
| 3454 | bool | ||
| 3455 | issolved(cube_t cube) | ||
| 3456 | { | ||
| 3457 | return equal(cube, solved); | ||
| 3458 | } | ||
| 3459 | |||
| 3460 | cube_t | ||
| 3461 | inverse(cube_t cube) | ||
| 3462 | { | ||
| 3463 | DBG_ASSERT(isconsistent(cube), zero, | ||
| 3464 | "inverse error: inconsistent cube\n"); | ||
| 3465 | |||
| 3466 | return fasttocube(inverse_fast(cubetofast(cube))); | ||
| 3467 | } | ||
| 3468 | |||
| 3469 | cube_t | ||
| 3470 | compose(cube_t c1, cube_t c2) | ||
| 3471 | { | ||
| 3472 | DBG_ASSERT(isconsistent(c1) && isconsistent(c2), | ||
| 3473 | zero, "compose error: inconsistent cube\n") | ||
| 3474 | |||
| 3475 | return fasttocube(compose_fast(cubetofast(c1), cubetofast(c2))); | ||
| 3476 | } | ||
| 3477 | |||
| 3478 | static cube_fast_t | ||
| 3479 | move(cube_fast_t c, uint8_t m) | 3533 | move(cube_fast_t c, uint8_t m) |
| 3480 | { | 3534 | { |
| 3481 | switch (m) { | 3535 | switch (m) { |
| @@ -3521,7 +3575,7 @@ move(cube_fast_t c, uint8_t m) | |||
| 3521 | } | 3575 | } |
| 3522 | } | 3576 | } |
| 3523 | 3577 | ||
| 3524 | static cube_fast_t | 3578 | _static cube_fast_t |
| 3525 | transform(cube_fast_t c, uint8_t t) | 3579 | transform(cube_fast_t c, uint8_t t) |
| 3526 | { | 3580 | { |
| 3527 | switch (t) { | 3581 | switch (t) { |
| @@ -3627,52 +3681,26 @@ transform(cube_fast_t c, uint8_t t) | |||
| 3627 | } | 3681 | } |
| 3628 | } | 3682 | } |
| 3629 | 3683 | ||
| 3630 | cube_t | 3684 | /****************************************************************************** |
| 3631 | applymoves(cube_t cube, char *buf) | 3685 | Section: moves and move sequences |
| 3632 | { | ||
| 3633 | cube_fast_t fast; | ||
| 3634 | uint8_t r, m; | ||
| 3635 | char *b; | ||
| 3636 | |||
| 3637 | DBG_ASSERT(isconsistent(cube), zero, | ||
| 3638 | "move error: inconsistent cube\n"); | ||
| 3639 | |||
| 3640 | fast = cubetofast(cube); | ||
| 3641 | 3686 | ||
| 3642 | for (b = buf; *b != '\0'; b++) { | 3687 | This section contains methods to work with moves and arrays of moves. They |
| 3643 | while (*b == ' ' || *b == '\t' || *b == '\n') | 3688 | do not rely on the cube structure. |
| 3644 | b++; | 3689 | ******************************************************************************/ |
| 3645 | if (*b == '\0') | ||
| 3646 | goto readmoves_finish; | ||
| 3647 | if ((r = readmove(*b)) == _error) | ||
| 3648 | goto readmoves_error; | ||
| 3649 | if ((m = readmodifier(*(b+1))) != 0) | ||
| 3650 | b++; | ||
| 3651 | fast = move(fast, r + m); | ||
| 3652 | } | ||
| 3653 | 3690 | ||
| 3654 | readmoves_finish: | 3691 | _static_inline uint8_t movebase(uint8_t); |
| 3655 | return fasttocube(fast); | 3692 | _static_inline uint8_t moveaxis(uint8_t); |
| 3656 | 3693 | ||
| 3657 | readmoves_error: | 3694 | _static_inline uint8_t |
| 3658 | DBG_LOG("readmoves error\n"); | 3695 | movebase(uint8_t move) |
| 3659 | return zero; | 3696 | { |
| 3697 | return move / 3; | ||
| 3660 | } | 3698 | } |
| 3661 | 3699 | ||
| 3662 | cube_t | 3700 | _static_inline uint8_t |
| 3663 | applytrans(cube_t cube, char *buf) | 3701 | moveaxis(uint8_t move) |
| 3664 | { | 3702 | { |
| 3665 | cube_fast_t fast; | 3703 | return move / 6; |
| 3666 | uint8_t t; | ||
| 3667 | |||
| 3668 | DBG_ASSERT(isconsistent(cube), zero, | ||
| 3669 | "transformation error: inconsistent cube\n"); | ||
| 3670 | |||
| 3671 | t = readtrans(buf); | ||
| 3672 | fast = cubetofast(cube); | ||
| 3673 | fast = transform(fast, t); | ||
| 3674 | |||
| 3675 | return fasttocube(fast); | ||
| 3676 | } | 3704 | } |
| 3677 | 3705 | ||
| 3678 | /****************************************************************************** | 3706 | /****************************************************************************** |
| @@ -3692,7 +3720,82 @@ typedef struct { | |||
| 3692 | uint8_t (*estimate)(cube_fast_t); | 3720 | uint8_t (*estimate)(cube_fast_t); |
| 3693 | } dfsarg_generic_t; | 3721 | } dfsarg_generic_t; |
| 3694 | 3722 | ||
| 3695 | static bool | 3723 | int64_t solve(cube_t, char *, char *, char *, int8_t, int8_t, int64_t, int8_t, |
| 3724 | void *, char *); | ||
| 3725 | void multisolve(int, cube_t *, char *, void *, char *); | ||
| 3726 | int64_t gendata(char *, void *); | ||
| 3727 | |||
| 3728 | _static bool allowednextmove(dfsarg_generic_t, uint8_t); | ||
| 3729 | _static void solve_generic_appendsolution(dfsarg_generic_t); | ||
| 3730 | _static int solve_generic_dfs(dfsarg_generic_t); | ||
| 3731 | _static int64_t solve_generic(cube_t, char *, int8_t, int8_t, int64_t, int8_t, | ||
| 3732 | char *, uint8_t (*)(cube_fast_t)); | ||
| 3733 | _static uint8_t estimate_simple(cube_fast_t); | ||
| 3734 | _static int64_t solve_simple(cube_t, int8_t, int8_t, int64_t, int8_t, char *); | ||
| 3735 | |||
| 3736 | int64_t | ||
| 3737 | solve( | ||
| 3738 | cube_t cube, | ||
| 3739 | char *solver, | ||
| 3740 | char *options, | ||
| 3741 | char *nisstype, | ||
| 3742 | int8_t minmoves, | ||
| 3743 | int8_t maxmoves, | ||
| 3744 | int64_t maxsols, | ||
| 3745 | int8_t optimal, | ||
| 3746 | void *data, | ||
| 3747 | char *solutions | ||
| 3748 | ) | ||
| 3749 | { | ||
| 3750 | DBG_WARN(!strcmp(options, ""), | ||
| 3751 | "solve: 'options' not implemented yet, ignoring\n"); | ||
| 3752 | |||
| 3753 | DBG_WARN(!strcmp(nisstype, ""), | ||
| 3754 | "solve: NISS not implemented yet, ignoring 'nisstype'\n"); | ||
| 3755 | |||
| 3756 | DBG_WARN(data == NULL, | ||
| 3757 | "solve: 'data' not implemented yet, ignoring\n"); | ||
| 3758 | |||
| 3759 | if (!strcmp(solver, "optimal") || !strcmp(solver, "simple")) { | ||
| 3760 | return solve_simple( | ||
| 3761 | cube, | ||
| 3762 | minmoves, | ||
| 3763 | maxmoves, | ||
| 3764 | maxsols, | ||
| 3765 | optimal, | ||
| 3766 | solutions | ||
| 3767 | ); | ||
| 3768 | } else { | ||
| 3769 | DBG_LOG("solve: unknown solver '%s'\n", solver); | ||
| 3770 | return -1; | ||
| 3771 | } | ||
| 3772 | |||
| 3773 | DBG_LOG("solve: error\n"); | ||
| 3774 | return -1; | ||
| 3775 | } | ||
| 3776 | |||
| 3777 | void | ||
| 3778 | multisolve(int n, cube_t *cube, char *solver, void *data, char *sols) | ||
| 3779 | { | ||
| 3780 | char *s; | ||
| 3781 | int i; | ||
| 3782 | |||
| 3783 | s = sols; | ||
| 3784 | for (i = 0; i < n; i++) { | ||
| 3785 | solve(cube[i], solver, "", "normal", 0, -1, 1, 0, NULL, s); | ||
| 3786 | while (s++); | ||
| 3787 | } | ||
| 3788 | } | ||
| 3789 | |||
| 3790 | int64_t | ||
| 3791 | gendata(char *solver, void *data) | ||
| 3792 | { | ||
| 3793 | DBG_LOG("gendata: not implemented yet\n"); | ||
| 3794 | |||
| 3795 | return -1; | ||
| 3796 | } | ||
| 3797 | |||
| 3798 | _static bool | ||
| 3696 | allowednextmove(dfsarg_generic_t arg, uint8_t m) | 3799 | allowednextmove(dfsarg_generic_t arg, uint8_t m) |
| 3697 | { | 3800 | { |
| 3698 | int n; | 3801 | int n; |
| @@ -3720,7 +3823,7 @@ allowednextmove(dfsarg_generic_t arg, uint8_t m) | |||
| 3720 | return l1axis != l2axis || mbase != l2base; | 3823 | return l1axis != l2axis || mbase != l2base; |
| 3721 | } | 3824 | } |
| 3722 | 3825 | ||
| 3723 | static void | 3826 | _static void |
| 3724 | solve_generic_appendsolution(dfsarg_generic_t arg) | 3827 | solve_generic_appendsolution(dfsarg_generic_t arg) |
| 3725 | { | 3828 | { |
| 3726 | int strl; | 3829 | int strl; |
| @@ -3733,7 +3836,7 @@ solve_generic_appendsolution(dfsarg_generic_t arg) | |||
| 3733 | (*arg.nsols)++; | 3836 | (*arg.nsols)++; |
| 3734 | } | 3837 | } |
| 3735 | 3838 | ||
| 3736 | static int | 3839 | _static int |
| 3737 | solve_generic_dfs(dfsarg_generic_t arg) | 3840 | solve_generic_dfs(dfsarg_generic_t arg) |
| 3738 | { | 3841 | { |
| 3739 | dfsarg_generic_t nextarg; | 3842 | dfsarg_generic_t nextarg; |
| @@ -3765,7 +3868,7 @@ solve_generic_dfs(dfsarg_generic_t arg) | |||
| 3765 | return ret; | 3868 | return ret; |
| 3766 | } | 3869 | } |
| 3767 | 3870 | ||
| 3768 | static int64_t | 3871 | _static int64_t |
| 3769 | solve_generic( | 3872 | solve_generic( |
| 3770 | cube_t cube, | 3873 | cube_t cube, |
| 3771 | char *nisstype, | 3874 | char *nisstype, |
| @@ -3862,13 +3965,13 @@ solve_generic( | |||
| 3862 | return ret; | 3965 | return ret; |
| 3863 | } | 3966 | } |
| 3864 | 3967 | ||
| 3865 | static uint8_t | 3968 | _static uint8_t |
| 3866 | estimate_simple(cube_fast_t cube) | 3969 | estimate_simple(cube_fast_t cube) |
| 3867 | { | 3970 | { |
| 3868 | return issolved_fast(cube) ? 0 : 1; | 3971 | return issolved_fast(cube) ? 0 : 1; |
| 3869 | } | 3972 | } |
| 3870 | 3973 | ||
| 3871 | static int64_t | 3974 | _static int64_t |
| 3872 | solve_simple( | 3975 | solve_simple( |
| 3873 | cube_t cube, | 3976 | cube_t cube, |
| 3874 | int8_t minmoves, | 3977 | int8_t minmoves, |
| @@ -3889,65 +3992,3 @@ solve_simple( | |||
| 3889 | &estimate_simple | 3992 | &estimate_simple |
| 3890 | ); | 3993 | ); |
| 3891 | } | 3994 | } |
| 3892 | |||
| 3893 | int64_t | ||
| 3894 | solve( | ||
| 3895 | cube_t cube, | ||
| 3896 | char *solver, | ||
| 3897 | char *options, | ||
| 3898 | char *nisstype, | ||
| 3899 | int8_t minmoves, | ||
| 3900 | int8_t maxmoves, | ||
| 3901 | int64_t maxsols, | ||
| 3902 | int8_t optimal, | ||
| 3903 | void *data, | ||
| 3904 | char *solutions | ||
| 3905 | ) | ||
| 3906 | { | ||
| 3907 | DBG_WARN(!strcmp(options, ""), | ||
| 3908 | "solve: 'options' not implemented yet, ignoring\n"); | ||
| 3909 | |||
| 3910 | DBG_WARN(!strcmp(nisstype, ""), | ||
| 3911 | "solve: NISS not implemented yet, ignoring 'nisstype'\n"); | ||
| 3912 | |||
| 3913 | DBG_WARN(data == NULL, | ||
| 3914 | "solve: 'data' not implemented yet, ignoring\n"); | ||
| 3915 | |||
| 3916 | if (!strcmp(solver, "optimal") || !strcmp(solver, "simple")) { | ||
| 3917 | return solve_simple( | ||
| 3918 | cube, | ||
| 3919 | minmoves, | ||
| 3920 | maxmoves, | ||
| 3921 | maxsols, | ||
| 3922 | optimal, | ||
| 3923 | solutions | ||
| 3924 | ); | ||
| 3925 | } else { | ||
| 3926 | DBG_LOG("solve: unknown solver '%s'\n", solver); | ||
| 3927 | return -1; | ||
| 3928 | } | ||
| 3929 | |||
| 3930 | DBG_LOG("solve: error\n"); | ||
| 3931 | return -1; | ||
| 3932 | } | ||
| 3933 | |||
| 3934 | void | ||
| 3935 | multisolve(int n, cube_t *cube, char *solver, void *data, char *sols) | ||
| 3936 | { | ||
| 3937 | char *s; | ||
| 3938 | int i; | ||
| 3939 | |||
| 3940 | s = sols; | ||
| 3941 | for (i = 0; i < n; i++) { | ||
| 3942 | solve(cube[i], solver, "", "normal", 0, -1, 1, 0, NULL, s); | ||
| 3943 | while (s++); | ||
| 3944 | } | ||
| 3945 | } | ||
| 3946 | |||
| 3947 | int64_t | ||
| 3948 | gendata(char *solver, void *data) | ||
| 3949 | { | ||
| 3950 | DBG_LOG("gendata: not implemented yet\n"); | ||
| 3951 | |||
| 3952 | return -1; | ||
| 3953 | } | ||
diff --git a/old/061_coord_eo/00_solved.in b/test/061_coord_eo/00_solved.in index dff224d..dff224d 100644 --- a/old/061_coord_eo/00_solved.in +++ b/test/061_coord_eo/00_solved.in | |||
diff --git a/old/061_coord_eo/00_solved.out b/test/061_coord_eo/00_solved.out index 573541a..573541a 100644 --- a/old/061_coord_eo/00_solved.out +++ b/test/061_coord_eo/00_solved.out | |||
diff --git a/old/061_coord_eo/01_U.in b/test/061_coord_eo/01_U.in index b5b36ad..b5b36ad 100644 --- a/old/061_coord_eo/01_U.in +++ b/test/061_coord_eo/01_U.in | |||
diff --git a/old/061_coord_eo/01_U.out b/test/061_coord_eo/01_U.out index 573541a..573541a 100644 --- a/old/061_coord_eo/01_U.out +++ b/test/061_coord_eo/01_U.out | |||
diff --git a/old/061_coord_eo/02_U2.in b/test/061_coord_eo/02_U2.in index 316ad57..316ad57 100644 --- a/old/061_coord_eo/02_U2.in +++ b/test/061_coord_eo/02_U2.in | |||
diff --git a/old/061_coord_eo/02_U2.out b/test/061_coord_eo/02_U2.out index 573541a..573541a 100644 --- a/old/061_coord_eo/02_U2.out +++ b/test/061_coord_eo/02_U2.out | |||
diff --git a/old/061_coord_eo/03_U3.in b/test/061_coord_eo/03_U3.in index 7721ab5..7721ab5 100644 --- a/old/061_coord_eo/03_U3.in +++ b/test/061_coord_eo/03_U3.in | |||
diff --git a/old/061_coord_eo/03_U3.out b/test/061_coord_eo/03_U3.out index 573541a..573541a 100644 --- a/old/061_coord_eo/03_U3.out +++ b/test/061_coord_eo/03_U3.out | |||
diff --git a/old/061_coord_eo/04_D.in b/test/061_coord_eo/04_D.in index cf4f816..cf4f816 100644 --- a/old/061_coord_eo/04_D.in +++ b/test/061_coord_eo/04_D.in | |||
diff --git a/old/061_coord_eo/04_D.out b/test/061_coord_eo/04_D.out index 573541a..573541a 100644 --- a/old/061_coord_eo/04_D.out +++ b/test/061_coord_eo/04_D.out | |||
diff --git a/old/061_coord_eo/07_R.in b/test/061_coord_eo/07_R.in index 8c8fcb3..8c8fcb3 100644 --- a/old/061_coord_eo/07_R.in +++ b/test/061_coord_eo/07_R.in | |||
diff --git a/old/061_coord_eo/07_R.out b/test/061_coord_eo/07_R.out index 573541a..573541a 100644 --- a/old/061_coord_eo/07_R.out +++ b/test/061_coord_eo/07_R.out | |||
diff --git a/old/061_coord_eo/08_R2.in b/test/061_coord_eo/08_R2.in index 90765e2..90765e2 100644 --- a/old/061_coord_eo/08_R2.in +++ b/test/061_coord_eo/08_R2.in | |||
diff --git a/old/061_coord_eo/08_R2.out b/test/061_coord_eo/08_R2.out index 573541a..573541a 100644 --- a/old/061_coord_eo/08_R2.out +++ b/test/061_coord_eo/08_R2.out | |||
diff --git a/old/061_coord_eo/10_L.in b/test/061_coord_eo/10_L.in index 0b0565c..0b0565c 100644 --- a/old/061_coord_eo/10_L.in +++ b/test/061_coord_eo/10_L.in | |||
diff --git a/old/061_coord_eo/10_L.out b/test/061_coord_eo/10_L.out index 573541a..573541a 100644 --- a/old/061_coord_eo/10_L.out +++ b/test/061_coord_eo/10_L.out | |||
diff --git a/old/061_coord_eo/13_F.in b/test/061_coord_eo/13_F.in index e805af8..e805af8 100644 --- a/old/061_coord_eo/13_F.in +++ b/test/061_coord_eo/13_F.in | |||
diff --git a/old/061_coord_eo/13_F.out b/test/061_coord_eo/13_F.out index 2c60641..2c60641 100644 --- a/old/061_coord_eo/13_F.out +++ b/test/061_coord_eo/13_F.out | |||
diff --git a/old/061_coord_eo/14_F2.in b/test/061_coord_eo/14_F2.in index 8aa701f..8aa701f 100644 --- a/old/061_coord_eo/14_F2.in +++ b/test/061_coord_eo/14_F2.in | |||
diff --git a/old/061_coord_eo/14_F2.out b/test/061_coord_eo/14_F2.out index 573541a..573541a 100644 --- a/old/061_coord_eo/14_F2.out +++ b/test/061_coord_eo/14_F2.out | |||
diff --git a/old/061_coord_eo/15_F3.in b/test/061_coord_eo/15_F3.in index 40f1260..40f1260 100644 --- a/old/061_coord_eo/15_F3.in +++ b/test/061_coord_eo/15_F3.in | |||
diff --git a/old/061_coord_eo/15_F3.out b/test/061_coord_eo/15_F3.out index 2c60641..2c60641 100644 --- a/old/061_coord_eo/15_F3.out +++ b/test/061_coord_eo/15_F3.out | |||
diff --git a/old/061_coord_eo/16_B.in b/test/061_coord_eo/16_B.in index f7fb13c..f7fb13c 100644 --- a/old/061_coord_eo/16_B.in +++ b/test/061_coord_eo/16_B.in | |||
diff --git a/old/061_coord_eo/16_B.out b/test/061_coord_eo/16_B.out index 1fd9918..1fd9918 100644 --- a/old/061_coord_eo/16_B.out +++ b/test/061_coord_eo/16_B.out | |||
diff --git a/old/061_coord_eo/17_B2.in b/test/061_coord_eo/17_B2.in index 9b33e35..9b33e35 100644 --- a/old/061_coord_eo/17_B2.in +++ b/test/061_coord_eo/17_B2.in | |||
diff --git a/old/061_coord_eo/17_B2.out b/test/061_coord_eo/17_B2.out index 573541a..573541a 100644 --- a/old/061_coord_eo/17_B2.out +++ b/test/061_coord_eo/17_B2.out | |||
diff --git a/old/061_coord_eo/18_B3.in b/test/061_coord_eo/18_B3.in index 1367517..1367517 100644 --- a/old/061_coord_eo/18_B3.in +++ b/test/061_coord_eo/18_B3.in | |||
diff --git a/old/061_coord_eo/18_B3.out b/test/061_coord_eo/18_B3.out index 1fd9918..1fd9918 100644 --- a/old/061_coord_eo/18_B3.out +++ b/test/061_coord_eo/18_B3.out | |||
diff --git a/old/061_coord_eo/20_scrambled.in b/test/061_coord_eo/20_scrambled.in index 274d30b..274d30b 100644 --- a/old/061_coord_eo/20_scrambled.in +++ b/test/061_coord_eo/20_scrambled.in | |||
diff --git a/old/061_coord_eo/20_scrambled.out b/test/061_coord_eo/20_scrambled.out index aa309cc..aa309cc 100644 --- a/old/061_coord_eo/20_scrambled.out +++ b/test/061_coord_eo/20_scrambled.out | |||
diff --git a/old/061_coord_eo/coord_eo_tests.c b/test/061_coord_eo/coord_eo_tests.c index 30989e8..bd3db8a 100644 --- a/old/061_coord_eo/coord_eo_tests.c +++ b/test/061_coord_eo/coord_eo_tests.c | |||
| @@ -6,19 +6,24 @@ | |||
| 6 | #include <immintrin.h> | 6 | #include <immintrin.h> |
| 7 | #endif | 7 | #endif |
| 8 | 8 | ||
| 9 | #include "../../cube.h" | 9 | #include "../test.h" |
| 10 | 10 | ||
| 11 | #define STRLENMAX 10000 | 11 | #define STRLENMAX 10000 |
| 12 | 12 | ||
| 13 | int64_t coord_fast_eo(cube_fast_t); | ||
| 14 | cube_fast_t cubetofast(cube_t); | ||
| 15 | |||
| 13 | int main() { | 16 | int main() { |
| 14 | char str[STRLENMAX]; | 17 | char str[STRLENMAX]; |
| 15 | cube_t cube; | 18 | cube_t cube; |
| 19 | cube_fast_t fast; | ||
| 16 | int16_t result; | 20 | int16_t result; |
| 17 | 21 | ||
| 18 | fgets(str, STRLENMAX, stdin); | 22 | fgets(str, STRLENMAX, stdin); |
| 19 | cube = readcube("H48", str); | 23 | cube = readcube("H48", str); |
| 24 | fast = cubetofast(cube); | ||
| 20 | 25 | ||
| 21 | result = coord_eo(cube); | 26 | result = coord_fast_eo(fast); |
| 22 | 27 | ||
| 23 | printf("%" PRId16 "\n", result); | 28 | printf("%" PRId16 "\n", result); |
| 24 | 29 | ||
diff --git a/test/060_solve_simple/01_U_U3.in b/test/070_solve_simple/01_U_U3.in index c0f7930..c0f7930 100644 --- a/test/060_solve_simple/01_U_U3.in +++ b/test/070_solve_simple/01_U_U3.in | |||
diff --git a/test/060_solve_simple/01_U_U3.out b/test/070_solve_simple/01_U_U3.out index ca934b4..ca934b4 100644 --- a/test/060_solve_simple/01_U_U3.out +++ b/test/070_solve_simple/01_U_U3.out | |||
diff --git a/test/060_solve_simple/02_MUMU_alloptimal.in b/test/070_solve_simple/02_MUMU_alloptimal.in index f97c95f..f97c95f 100644 --- a/test/060_solve_simple/02_MUMU_alloptimal.in +++ b/test/070_solve_simple/02_MUMU_alloptimal.in | |||
diff --git a/test/060_solve_simple/02_MUMU_alloptimal.out b/test/070_solve_simple/02_MUMU_alloptimal.out index 06cd521..06cd521 100644 --- a/test/060_solve_simple/02_MUMU_alloptimal.out +++ b/test/070_solve_simple/02_MUMU_alloptimal.out | |||
diff --git a/test/060_solve_simple/solve_simple_tests.c b/test/070_solve_simple/solve_simple_tests.c index 14a1674..14a1674 100644 --- a/test/060_solve_simple/solve_simple_tests.c +++ b/test/070_solve_simple/solve_simple_tests.c | |||
diff --git a/test/test.h b/test/test.h new file mode 100644 index 0000000..607a52d --- /dev/null +++ b/test/test.h | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | #include "../cube.h" | ||
| 2 | |||
| 3 | #ifdef CUBE_AVX2 | ||
| 4 | typedef __m256i cube_fast_t; | ||
| 5 | #else | ||
| 6 | typedef cube_t cube_fast_t; | ||
| 7 | #endif | ||
