aboutsummaryrefslogtreecommitdiff
path: root/src/symcoord.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/symcoord.c')
-rw-r--r--src/symcoord.c344
1 files changed, 258 insertions, 86 deletions
diff --git a/src/symcoord.c b/src/symcoord.c
index 38e13c6..83fba0a 100644
--- a/src/symcoord.c
+++ b/src/symcoord.c
@@ -4,27 +4,43 @@
4#define CLASSES_CP_16 2768 4#define CLASSES_CP_16 2768
5#define CLASSES_EOFBEPOS_16 64430 5#define CLASSES_EOFBEPOS_16 64430
6 6
7static Cube antindex_cp_sym16(uint64_t ind);
8static Cube antindex_eofbepos_sym16(uint64_t ind);
9static Cube antindex_drud_sym16(uint64_t ind);
10static Cube antindex_drudfin_noE_sym16(uint64_t ind);
11static Cube antindex_nxopt31(uint64_t ind);
12
13static uint64_t index_cp_sym16(Cube cube); 7static uint64_t index_cp_sym16(Cube cube);
14static uint64_t index_eofbepos_sym16(Cube cube); 8static uint64_t index_eofbepos_sym16(Cube cube);
15static uint64_t index_drud_sym16(Cube cube); 9static uint64_t index_drud_sym16(Cube cube);
16static uint64_t index_drudfin_noE_sym16(Cube cube); 10static uint64_t index_drudfin_noE_sym16(Cube cube);
17static uint64_t index_nxopt31(Cube cube); 11static uint64_t index_nxopt31(Cube cube);
18 12
19static int transfinder_drud_sym16(uint64_t ind, Trans *ret); 13static uint64_t move_cp_sym16(Move m, uint64_t ind);
20static int transfinder_drudfin_noE_sym16(uint64_t ind, Trans *ret); 14static uint64_t move_eofbepos_sym16(Move m, uint64_t ind);
21static int transfinder_nxopt31(uint64_t ind, Trans *ret); 15static uint64_t move_drud_sym16(Move m, uint64_t ind);
16static uint64_t move_drudfin_noE_sym16(Move m, uint64_t ind);
17static uint64_t move_nxopt31(Move m, uint64_t ind);
18
19static uint64_t transform_cp(Trans t, uint64_t ind);
20static uint64_t transform_eofbepos(Trans t, uint64_t ind);
21static uint64_t transform_drud_sym16(Trans t, uint64_t ind);
22static uint64_t transform_drudfin_noE_sym16(Trans t, uint64_t ind);
23static uint64_t transform_nxopt31(Trans t, uint64_t ind);
22 24
23static void gensym(SymData *sd); 25static void gensym(SymData *sd);
26static void init_symc_moves();
27static void init_symc_trans();
24static bool read_symdata_file(SymData *sd); 28static bool read_symdata_file(SymData *sd);
25static int selfsims(SymData *sd, uint64_t ind, Trans *ret);
26static bool write_symdata_file(SymData *sd); 29static bool write_symdata_file(SymData *sd);
27 30
31/* Some tables ***************************************************************/
32
33static uint64_t move_cp_16[NMOVES][CLASSES_CP_16];
34static uint64_t move_eofbepos_16[NMOVES][CLASSES_EOFBEPOS_16];
35
36static int trans_eofbepos[NTRANS][POW2TO11*BINOM12ON4];
37static int trans_epud[NTRANS][FACTORIAL8];
38static int trans_cpud_separate[NTRANS][BINOM8ON4];
39
40static Trans ttrep_move_cp_16[NMOVES][CLASSES_CP_16];
41static Trans ttrep_move_eofbepos_16[NMOVES][CLASSES_EOFBEPOS_16];
42
43
28/* Transformation groups and symmetry data ***********************************/ 44/* Transformation groups and symmetry data ***********************************/
29 45
30static Trans 46static Trans
@@ -37,20 +53,22 @@ trans_group_udfix[16] = {
37 53
38static SymData 54static SymData
39sd_cp_16 = { 55sd_cp_16 = {
40 .filename = "sd_cp_16", 56 .filename = "sd_cp_16_new",
41 .coord = &coord_cp, 57 .coord = &coord_cp,
42 .sym_coord = &coord_cp_sym16, 58 .sym_coord = &coord_cp_sym16,
43 .ntrans = 16, 59 .ntrans = 16,
44 .trans = trans_group_udfix 60 .trans = trans_group_udfix,
61 .transform = transform_cp,
45}; 62};
46 63
47static SymData 64static SymData
48sd_eofbepos_16 = { 65sd_eofbepos_16 = {
49 .filename = "sd_eofbepos_16", 66 .filename = "sd_eofbepos_16_new",
50 .coord = &coord_eofbepos, 67 .coord = &coord_eofbepos,
51 .sym_coord = &coord_eofbepos_sym16, 68 .sym_coord = &coord_eofbepos_sym16,
52 .ntrans = 16, 69 .ntrans = 16,
53 .trans = trans_group_udfix 70 .trans = trans_group_udfix,
71 .transform = transform_eofbepos,
54}; 72};
55 73
56SymData * all_sd[] = { 74SymData * all_sd[] = {
@@ -65,90 +83,44 @@ SymData * all_sd[] = {
65Coordinate 83Coordinate
66coord_eofbepos_sym16 = { 84coord_eofbepos_sym16 = {
67 .index = index_eofbepos_sym16, 85 .index = index_eofbepos_sym16,
68 .cube = antindex_eofbepos_sym16, 86 .move = move_eofbepos_sym16,
69}; 87};
70 88
71Coordinate 89Coordinate
72coord_cp_sym16 = { 90coord_cp_sym16 = {
73 .index = index_cp_sym16, 91 .index = index_cp_sym16,
74 .cube = antindex_cp_sym16, 92 .move = move_cp_sym16,
75}; 93};
76 94
77Coordinate 95Coordinate
78coord_drud_sym16 = { 96coord_drud_sym16 = {
79 .index = index_drud_sym16, 97 .index = index_drud_sym16,
80 .cube = antindex_drud_sym16, 98 .move = move_drud_sym16,
81 .max = POW3TO7 * CLASSES_EOFBEPOS_16, 99 .max = POW3TO7 * CLASSES_EOFBEPOS_16,
82 .transfind = transfinder_drud_sym16, 100 .transform = transform_drud_sym16,
101 .sd = &sd_cp_16,
83}; 102};
84 103
85Coordinate 104Coordinate
86coord_drudfin_noE_sym16 = { 105coord_drudfin_noE_sym16 = {
87 .index = index_drudfin_noE_sym16, 106 .index = index_drudfin_noE_sym16,
88 .cube = antindex_drudfin_noE_sym16, 107 .move = move_drudfin_noE_sym16,
89 .max = FACTORIAL8 * CLASSES_CP_16, 108 .max = FACTORIAL8 * CLASSES_CP_16,
90 .transfind = transfinder_drudfin_noE_sym16, 109 .transform = transform_drudfin_noE_sym16,
110 .sd = &sd_eofbepos_16,
91}; 111};
92 112
93Coordinate 113Coordinate
94coord_nxopt31 = { 114coord_nxopt31 = {
95 .index = index_nxopt31, 115 .index = index_nxopt31,
96 .cube = antindex_nxopt31, 116 .move = move_nxopt31,
97 .max = POW3TO7 * BINOM8ON4 * CLASSES_EOFBEPOS_16, 117 .max = POW3TO7 * BINOM8ON4 * CLASSES_EOFBEPOS_16,
98 .transfind = transfinder_nxopt31, 118 .transform = transform_nxopt31,
119 .sd = &sd_eofbepos_16,
99}; 120};
100 121
101/* Functions *****************************************************************/ 122/* Functions *****************************************************************/
102 123
103static Cube
104antindex_cp_sym16(uint64_t ind)
105{
106 return sd_cp_16.rep[ind];
107}
108
109static Cube
110antindex_eofbepos_sym16(uint64_t ind)
111{
112 return sd_eofbepos_16.rep[ind];
113}
114
115static Cube
116antindex_drud_sym16(uint64_t ind)
117{
118 Cube c;
119
120 c = antindex_eofbepos_sym16(ind/POW3TO7);
121 c.coud = ind % POW3TO7;
122 c.cofb = c.coud;
123 c.corl = c.coud;
124
125 return c;
126}
127
128static Cube
129antindex_drudfin_noE_sym16(uint64_t ind)
130{
131 Cube c1, c2;
132
133 c1 = coord_epud.cube(ind % FACTORIAL8);
134 c2 = antindex_cp_sym16(ind/FACTORIAL8);
135 c1.cp = c2.cp;
136
137 return c1;
138}
139
140static Cube
141antindex_nxopt31(uint64_t ind)
142{
143 Cube c;
144
145 c = antindex_eofbepos_sym16(ind/(BINOM8ON4*POW3TO7));
146 c.cp = coord_cpud_separate.cube(ind % BINOM8ON4).cp;
147 c.coud = (ind / BINOM8ON4) % POW3TO7;
148
149 return c;
150}
151
152static uint64_t 124static uint64_t
153index_cp_sym16(Cube cube) 125index_cp_sym16(Cube cube)
154{ 126{
@@ -198,6 +170,116 @@ index_nxopt31(Cube cube)
198 return a * BINOM8ON4 + coord_cpud_separate.index((Cube){.cp = cp}); 170 return a * BINOM8ON4 + coord_cpud_separate.index((Cube){.cp = cp});
199} 171}
200 172
173static uint64_t
174move_cp_sym16(Move m, uint64_t ind)
175{
176 return move_cp_16[m][ind];
177}
178
179static uint64_t
180move_eofbepos_sym16(Move m, uint64_t ind)
181{
182 return move_eofbepos_16[m][ind];
183}
184
185static uint64_t
186move_drud_sym16(Move m, uint64_t ind)
187{
188 uint64_t coud, eofbepos;
189 Trans ttr;
190
191 eofbepos = move_eofbepos_16[m][ind / POW3TO7];
192 ttr = ttrep_move_eofbepos_16[m][ind / POW3TO7];
193 coud = coud_mtable[m][ind % POW3TO7];
194 coud = co_ttable[ttr][coud]; /* Source is always coud */
195
196 return eofbepos * POW3TO7 + coud;
197}
198
199static uint64_t
200move_drudfin_noE_sym16(Move m, uint64_t ind)
201{
202 uint64_t cp, epud;
203 Trans ttr;
204
205 cp = move_cp_16[m][ind / FACTORIAL8];
206 ttr = ttrep_move_cp_16[m][ind / FACTORIAL8];
207 epud = coord_epud.move(m, ind % FACTORIAL8);
208 epud = trans_epud[ttr][epud];
209
210 return cp * FACTORIAL8 + epud;
211}
212
213static uint64_t
214move_nxopt31(Move m, uint64_t ind)
215{
216 uint64_t eofbepos, cpsep, coud;
217 Trans ttr;
218
219 eofbepos = ind / (POW3TO7 * BINOM8ON4);
220 coud = (ind / BINOM8ON4) % POW3TO7;
221 cpsep = ind % BINOM8ON4;
222
223 eofbepos = move_eofbepos_16[m][eofbepos];
224 ttr = ttrep_move_eofbepos_16[m][eofbepos];
225 coud = coud_mtable[m][coud];
226 coud = co_ttable[ttr][coud]; /* Source is always coud */
227 cpsep = coord_cpud_separate.move(m, cpsep);
228 cpsep = trans_cpud_separate[ttr][cpsep];
229
230 return (eofbepos * POW3TO7 + coud) * BINOM8ON4 + cpsep;
231}
232
233static uint64_t
234transform_cp(Trans t, uint64_t ind)
235{
236 return cp_ttable[t][ind];
237}
238
239static uint64_t
240transform_eofbepos(Trans t, uint64_t ind)
241{
242 return trans_eofbepos[t][ind];
243}
244
245static uint64_t
246transform_drud_sym16(Trans t, uint64_t ind)
247{
248 uint64_t coud, eofbepos;
249
250 eofbepos = ind / POW3TO7; /* Assum trans fixes eofbepos */
251 coud = co_ttable[t][ind % POW3TO7]; /* Source is always coud */
252
253 return eofbepos * POW3TO7 + coud;
254}
255
256static uint64_t
257transform_drudfin_noE_sym16(Trans t, uint64_t ind)
258{
259 uint64_t cp, epud;
260
261 cp = ind / FACTORIAL8; /* Assume trans fixes eofbepos */
262 epud = trans_epud[t][ind % FACTORIAL8];
263
264 return cp * FACTORIAL8 + epud;
265}
266
267static uint64_t
268transform_nxopt31(Trans t, uint64_t ind)
269{
270 uint64_t eofbepos, cpsep, coud;
271
272 eofbepos = ind / (POW3TO7 * BINOM8ON4);
273 coud = (ind / BINOM8ON4) % POW3TO7;
274 cpsep = ind % BINOM8ON4;
275
276 coud = co_ttable[t][coud]; /* Source is always coud */
277 cpsep = trans_cpud_separate[t][cpsep];
278
279 return (eofbepos * POW3TO7 + coud) * BINOM8ON4 + cpsep;
280}
281
282/*
201static int 283static int
202transfinder_drud_sym16(uint64_t ind, Trans *ret) 284transfinder_drud_sym16(uint64_t ind, Trans *ret)
203{ 285{
@@ -264,6 +346,8 @@ transfinder_nxopt31(uint64_t ind, Trans *ret)
264 return naux[trueind]; 346 return naux[trueind];
265} 347}
266 348
349*/
350
267/* Other functions ***********************************************************/ 351/* Other functions ***********************************************************/
268 352
269void 353void
@@ -271,7 +355,7 @@ free_sd(SymData *sd)
271{ 355{
272 if (sd->generated) { 356 if (sd->generated) {
273 free(sd->class); 357 free(sd->class);
274 free(sd->rep); 358 free(sd->unsym);
275 free(sd->transtorep); 359 free(sd->transtorep);
276 } 360 }
277 361
@@ -282,15 +366,16 @@ static void
282gensym(SymData *sd) 366gensym(SymData *sd)
283{ 367{
284 uint64_t i, in, nreps = 0; 368 uint64_t i, in, nreps = 0;
369 Trans t;
285 int j; 370 int j;
286 Cube c, d;
287 371
288 if (sd->generated) 372 if (sd->generated)
289 return; 373 return;
290 374
291 sd->class = malloc(sd->coord->max * sizeof(uint64_t)); 375 sd->class = malloc(sd->coord->max * sizeof(uint64_t));
292 sd->rep = malloc(sd->coord->max * sizeof(Cube)); 376 sd->unsym = malloc(sd->coord->max * sizeof(uint64_t));
293 sd->transtorep = malloc(sd->coord->max * sizeof(Trans)); 377 sd->transtorep = malloc(sd->coord->max * sizeof(Trans));
378 sd->selfsim = malloc(sd->coord->max * sizeof(uint64_t));
294 379
295 if (read_symdata_file(sd)) { 380 if (read_symdata_file(sd)) {
296 sd->generated = true; 381 sd->generated = true;
@@ -304,16 +389,17 @@ gensym(SymData *sd)
304 389
305 for (i = 0; i < sd->coord->max; i++) { 390 for (i = 0; i < sd->coord->max; i++) {
306 if (sd->class[i] == sd->coord->max + 1) { 391 if (sd->class[i] == sd->coord->max + 1) {
307 c = sd->coord->cube(i); 392 sd->unsym[nreps] = i;
308 sd->rep[nreps] = c; 393 sd->selfsim[nreps] = 0;
309 for (j = 0; j < sd->ntrans; j++) { 394 for (j = 0; j < sd->ntrans; j++) {
310 d = apply_trans(sd->trans[j], c); 395 t = sd->trans[j];
311 in = sd->coord->index(d); 396 in = sd->transform(t, i);
312 397 sd->class[in] = nreps;
313 if (sd->class[in] == sd->coord->max + 1) { 398 if (in == i) {
314 sd->class[in] = nreps; 399 sd->selfsim[nreps] |= (1 << t);
315 sd->transtorep[in] = 400 sd->transtorep[in] = uf;
316 inverse_trans(sd->trans[j]); 401 } else {
402 sd->transtorep[in] = inverse_trans(t);
317 } 403 }
318 } 404 }
319 nreps++; 405 nreps++;
@@ -321,7 +407,8 @@ gensym(SymData *sd)
321 } 407 }
322 408
323 sd->sym_coord->max = nreps; 409 sd->sym_coord->max = nreps;
324 sd->rep = realloc(sd->rep, nreps * sizeof(Cube)); 410 sd->unsym = realloc(sd->unsym, nreps * sizeof(uint64_t));
411 sd->selfsim = realloc(sd->selfsim, nreps * sizeof(uint64_t));
325 sd->generated = true; 412 sd->generated = true;
326 413
327 fprintf(stderr, "Found %" PRIu64 " classes\n", nreps); 414 fprintf(stderr, "Found %" PRIu64 " classes\n", nreps);
@@ -350,7 +437,8 @@ read_symdata_file(SymData *sd)
350 return false; 437 return false;
351 438
352 r = r && fread(&sd->sym_coord->max, sizeof(uint64_t), 1, f) == 1; 439 r = r && fread(&sd->sym_coord->max, sizeof(uint64_t), 1, f) == 1;
353 r = r && fread(sd->rep, sizeof(Cube), *sn, f) == *sn; 440 r = r && fread(sd->unsym, sizeof(uint64_t), *sn, f) == *sn;
441 r = r && fread(sd->selfsim, sizeof(uint64_t), *sn, f) == *sn;
354 r = r && fread(sd->class, sizeof(uint64_t), n, f) == n; 442 r = r && fread(sd->class, sizeof(uint64_t), n, f) == n;
355 r = r && fread(sd->transtorep, sizeof(Trans), n, f) == n; 443 r = r && fread(sd->transtorep, sizeof(Trans), n, f) == n;
356 444
@@ -358,6 +446,7 @@ read_symdata_file(SymData *sd)
358 return r; 446 return r;
359} 447}
360 448
449/*
361static int 450static int
362selfsims(SymData *sd, uint64_t ind, Trans *ret) 451selfsims(SymData *sd, uint64_t ind, Trans *ret)
363{ 452{
@@ -376,6 +465,7 @@ selfsims(SymData *sd, uint64_t ind, Trans *ret)
376 465
377 return n; 466 return n;
378} 467}
468*/
379 469
380static bool 470static bool
381write_symdata_file(SymData *sd) 471write_symdata_file(SymData *sd)
@@ -395,7 +485,8 @@ write_symdata_file(SymData *sd)
395 return false; 485 return false;
396 486
397 r = r && fwrite(&sd->sym_coord->max, sizeof(uint64_t), 1, f) == 1; 487 r = r && fwrite(&sd->sym_coord->max, sizeof(uint64_t), 1, f) == 1;
398 r = r && fwrite(sd->rep, sizeof(Cube), *sn, f) == *sn; 488 r = r && fwrite(sd->unsym, sizeof(uint64_t), *sn, f) == *sn;
489 r = r && fwrite(sd->selfsim, sizeof(uint64_t), *sn, f) == *sn;
399 r = r && fwrite(sd->class, sizeof(uint64_t), n, f) == n; 490 r = r && fwrite(sd->class, sizeof(uint64_t), n, f) == n;
400 r = r && fwrite(sd->transtorep, sizeof(Trans), n, f) == n; 491 r = r && fwrite(sd->transtorep, sizeof(Trans), n, f) == n;
401 492
@@ -403,6 +494,83 @@ write_symdata_file(SymData *sd)
403 return r; 494 return r;
404} 495}
405 496
497static void
498init_symc_moves()
499{
500 uint64_t i, ii;
501 Move j;
502
503 for (i = 0; i < CLASSES_CP_16; i++) {
504 ii = sd_cp_16.unsym[i];
505 for (j = 0; j < NMOVES; j++) {
506 move_cp_16[j][i] = sd_cp_16.coord->move(j, ii);
507 ttrep_move_cp_16[j][i] = sd_cp_16.transtorep[ii];
508 }
509 }
510
511 for (i = 0; i < CLASSES_EOFBEPOS_16; i++) {
512 ii = sd_eofbepos_16.unsym[i];
513 for (j = 0; j < NMOVES; j++) {
514 move_eofbepos_16[j][i] =
515 sd_eofbepos_16.coord->move(j, ii);
516 ttrep_move_eofbepos_16[j][i] =
517 sd_eofbepos_16.transtorep[ii];
518 }
519 }
520}
521
522void
523init_symc_trans()
524{
525 uint64_t i;
526 int j, cp;
527 int epe[4] = {FR, FL, BL, BR};
528 int a[12] = { [8] = 8, [9] = 9, [10] = 10, [11] = 11 };
529 Cube c;
530 CubeArray *arr, *aux;
531 Trans t;
532
533 for (i = 0; i < POW2TO11*BINOM12ON4; i++) {
534 for (j = 0; j < 16; j++) {
535 t = trans_group_udfix[j];
536
537 arr = new_cubearray((Cube){0}, pf_edges);
538 int_to_sum_zero_array(i/BINOM12ON4, 2, 12, arr->eofb);
539 epos_to_compatible_ep((i%BINOM12ON4)*24, arr->ep, epe);
540 fix_eorleoud(arr);
541 c = arrays_to_cube(arr, pf_edges);
542 free_cubearray(arr, pf_edges);
543
544 c = apply_trans(t, c);
545 trans_eofbepos[t][i] =
546 c.eofb * BINOM12ON4 + (c.epose / 24);
547 }
548 }
549
550 aux = malloc(sizeof(CubeArray));
551 aux->ep = a;
552 for (i = 0; i < FACTORIAL8; i++) {
553 index_to_perm(i, 8, a);
554 c = arrays_to_cube(aux, pf_ep);
555 for (j = 0; j < 16; j++) {
556 t = trans_group_udfix[j];
557 arr = new_cubearray(apply_trans(t, c), pf_ep);
558 trans_epud[t][i] = perm_to_index(arr->ep, 8);
559 free_cubearray(arr, pf_ep);
560 }
561 }
562 free(aux);
563
564 for (i = 0; i < BINOM8ON4; i++) {
565 cp = cpud_separate_ant[i];
566 for (j = 0; j < 16; j++) {
567 t = trans_group_udfix[j];
568 trans_cpud_separate[j][i] =
569 cpud_separate_ind[cp_ttable[t][cp]];
570 }
571 }
572}
573
406void 574void
407init_symcoord() 575init_symcoord()
408{ 576{
@@ -415,7 +583,11 @@ init_symcoord()
415 583
416 init_coord(); 584 init_coord();
417 585
586 init_symc_trans();
587
418 for (i = 0; all_sd[i] != NULL; i++) 588 for (i = 0; all_sd[i] != NULL; i++)
419 gensym(all_sd[i]); 589 gensym(all_sd[i]);
590
591 init_symc_moves();
420} 592}
421 593

Generated with cgit - Back to sebastiano.tronto.net