6 void printBinary(unsigned long number, int T) {
11 printf("%d", (int)(number/pow(2,i))%2);
16 void supplement(long stabStateIndices[], int T)
19 int K = round(log(T)/log(2)); // T = 2^K
21 //printf("K=%d\n", K);
23 int treeDepth, levelMaskDepth, maskIndex;
25 unsigned long levelMask;
27 unsigned long long maskList[K];
29 unsigned long given = (unsigned long)stabStateIndices[0]; // the given bitstring
31 unsigned long bitstring;
33 int bitstringCounter = 1; // bitstringCounter starts at 1 since 0 is the given bitstring
37 // first added bitstring is alpha ... alpha for alpha = 01
39 for(i=1; i<T/2; i++) {
43 //printf("%lu\n", bitstring);
44 stabStateIndices[bitstringCounter] = given^(bitstring);
47 // second added bitstring is beta ... beta for beta = 10
49 for(i=1; i<T/2; i++) {
53 //printf("%lu\n", bitstring);
54 stabStateIndices[bitstringCounter] = given^bitstring;
57 maskList[0] = round(pow(2,pow(2,K)))-1;
59 for(treeDepth=1; treeDepth<=K-1; treeDepth++) {
61 levelMask = round(pow(2,pow(2,K-treeDepth))-1);
62 // repeat this unit-cell mask to the other bits on levelMask
63 for(levelMaskDepth=2; levelMaskDepth<=round(pow(2,treeDepth-1)); levelMaskDepth++) {
64 levelMask += round(pow(2,pow(2,K-treeDepth+1)))*levelMask;
67 //printf("levelMask=");
68 //printBinary(levelMask, T);
70 bitstring = stabStateIndices[1] ^ levelMask;
72 for(maskIndex=0; maskIndex < (int)(pow(2,treeDepth)); maskIndex++) {
73 stabStateIndices[bitstringCounter] = bitstring;
74 for(i=0; i<treeDepth; i++){
75 // if ith binary digit of maskIndex is 1 then XOR with ith string in maskList
76 stabStateIndices[bitstringCounter] ^= ((int)(maskIndex/(pow(2,i)))%2)*maskList[i];
78 //printf("new bitstring=");
79 //printBinary(stabStateIndices[bitstringCounter], T);
83 maskList[treeDepth] = levelMask;
90 int main(int argc, char *argv[])
93 int T = (int)pow(2,4);
94 long* stabStateIndices;
96 stabStateIndices = calloc(T+1,sizeof(long));
98 stabStateIndices[0] = (int)(pow(2,T))-1;
100 supplement(&stabStateIndices[0], T);
104 printBinary(stabStateIndices[i], T);