#include "rep.h" //every groupelem is an array of 5 inetegers. //first 4 elements stand for each axis positions, //last element stands for axis rotations int is_valid_groupelem(int candidate[5]) { for (int i=0; i<4; i++) { if(candidate[i]>18 || candidate[i]<0) { return 0; } } if(candidate[4] >24 || candidate[4]<0) { return 0; } return 1; } void print_groupelem(int el[5]) { for(int i=0; i<5; i++) { printf("(%d)", el[i]); } printf("\n"); } // the following fn maps n\in{0.. fact(n)-1} to a permutation of {0..n-1} void itoperm(int p, int arr[4]) { int pt = p; int filled[4] = {0,0,0,0}; arr[0] = pt%4; filled[arr[0]] = 1; pt = floor(pt/4); for(int i=1; i<4; i++) { int pp1 = pt%(4-i); pt = floor(pt/(4-i)); int j = 0, k = 0; while(k8 && el2[i]>8)) { resor = 0; } else { resor = 1; } //orientation of res[i] is now determined. int val1 = el1[i]%9; int val2 = el2[i]%9; int resval = (val1+val2)%9; result[i] = (9*resor)+resval; } result[4] = perm_prod(el1[4], el2[4]); if(!is_valid_groupelem(result)) { printf("CRITICAL ERROR at %S:%d\n", __FILE__, __LINE__); exit(-1); } } int PERMINV_TABLE[24]; //store inverses of permutation group elems in a table void init_PERMINV_TABLE() { for(int i=0; i<24; i++) { for(int j=0; j<24; j++) { if(perm_prod(i, j)==0) { PERMINV_TABLE[i] = j; // PERMINV_TABLE[j] = i; } } } } //inverse of an element in the torus group void inverse(int el[5], int res[5]) { for(int i=0; i<4; i++) { int elor = 0; if(el[i]>8) { elor = 1; } res[i] = (9*elor) + (9-(el[i])%9)%9; } res[4] = PERMINV_TABLE[el[4]]; } int fact(int n) { if(n==1) return 1; else return n*fact(n-1); } void init_rep() { init_PERMARRAY(); init_PERMINV_TABLE(); }