List thickenings when found

This commit is contained in:
Florian Stecker 2016-06-20 10:37:21 +02:00
parent 53811ef32a
commit 3f9df34e01

View File

@ -11,6 +11,8 @@
#define DEBUG(msg, ...) do{fprintf(stderr, msg, ##__VA_ARGS__); }while(0) #define DEBUG(msg, ...) do{fprintf(stderr, msg, ##__VA_ARGS__); }while(0)
#define MAX_THICKENINGS 10000
typedef struct _edgelist { typedef struct _edgelist {
int to; int to;
struct _edgelist *next; struct _edgelist *next;
@ -37,6 +39,32 @@ static char *alphabetize(int *word, int len, const char *alphabet, char *buffer)
return buffer; return buffer;
} }
static void print_balanced_thickening(int rank, int order, const int *thickening, const int *left_invariant, const int *right_invariant, const char *alphabet)
{
for(int i = 0; i < order; i++) {
if(thickening[i])
printf("x");
else
printf("0");
}
printf(" left: ");
for(int j = 0; j < rank; j++)
if(left_invariant[j])
printf("%c", alphabet[j]);
else
printf(" ");
printf(" right: ");
for(int j = 0; j < rank; j++)
if(right_invariant[j])
printf("%c", alphabet[j]);
else
printf(" ");
printf("\n");
}
static int compare_wordlength(const void *a, const void *b, void *gr) static int compare_wordlength(const void *a, const void *b, void *gr)
{ {
int i = *((int*)a); int i = *((int*)a);
@ -67,6 +95,8 @@ int main(int argc, const char *argv[])
int is_fat, is_slim; int is_fat, is_slim;
int thickenings_count, fat_count, slim_count, balanced_count; int thickenings_count, fat_count, slim_count, balanced_count;
int *balanced_thickenings;
char *string_buffer1, *string_buffer2; char *string_buffer1, *string_buffer2;
const char *alphabet = "abcdefghijklmnopqrstuvwxyz"; const char *alphabet = "abcdefghijklmnopqrstuvwxyz";
@ -86,7 +116,7 @@ int main(int argc, const char *argv[])
ERROR(strlen(alphabet) < rank, "The alphabet has too few letters\n"); ERROR(strlen(alphabet) < rank, "The alphabet has too few letters\n");
DEBUG("The group has rank %d and order %d\n", rank, order); // DEBUG("The group has rank %d and order %d\n", rank, order);
graph = (node_t*)malloc(order*sizeof(node_t)); graph = (node_t*)malloc(order*sizeof(node_t));
graph_unsorted = (node_t*)malloc(order*sizeof(node_t)); graph_unsorted = (node_t*)malloc(order*sizeof(node_t));
@ -99,8 +129,9 @@ int main(int argc, const char *argv[])
right = (int*)malloc(order*rank*sizeof(int)); right = (int*)malloc(order*rank*sizeof(int));
left_invariant = (int*)malloc(rank*sizeof(int)); left_invariant = (int*)malloc(rank*sizeof(int));
right_invariant = (int*)malloc(rank*sizeof(int)); right_invariant = (int*)malloc(rank*sizeof(int));
balanced_thickenings = (int*)malloc(MAX_THICKENINGS*order*sizeof(int));
DEBUG("Generate Cayley graph\n"); // DEBUG("Generate Cayley graph\n");
generate_coxeter_graph(type, graph_data); generate_coxeter_graph(type, graph_data);
@ -116,7 +147,7 @@ int main(int argc, const char *argv[])
graph_unsorted[i].is_hyperplane_reflection = 0; graph_unsorted[i].is_hyperplane_reflection = 0;
} }
DEBUG("Find wordlengths\n"); // DEBUG("Find wordlengths\n");
graph_unsorted[0].wordlength = 0; graph_unsorted[0].wordlength = 0;
queue_init(&queue); queue_init(&queue);
@ -139,7 +170,7 @@ int main(int argc, const char *argv[])
string_buffer1 = (char*)malloc((max_wordlength+1)*sizeof(char)); string_buffer1 = (char*)malloc((max_wordlength+1)*sizeof(char));
string_buffer2 = (char*)malloc((max_wordlength+1)*sizeof(char)); string_buffer2 = (char*)malloc((max_wordlength+1)*sizeof(char));
DEBUG("Sort by wordlength\n"); // DEBUG("Sort by wordlength\n");
for(int i = 0; i < order; i++) for(int i = 0; i < order; i++)
wordlength_order[i] = i; wordlength_order[i] = i;
@ -152,7 +183,7 @@ int main(int argc, const char *argv[])
graph[i].left[j] = reverse_wordlength_order[graph[i].left[j]]; // rewrite references graph[i].left[j] = reverse_wordlength_order[graph[i].left[j]]; // rewrite references
} }
DEBUG("Find words\n"); // DEBUG("Find words\n");
words = (int*)malloc(order*max_wordlength*sizeof(int)); words = (int*)malloc(order*max_wordlength*sizeof(int));
memset(words, 0, order*max_wordlength*sizeof(int)); memset(words, 0, order*max_wordlength*sizeof(int));
@ -171,7 +202,7 @@ int main(int argc, const char *argv[])
} }
} }
DEBUG("Generate right edges\n"); // DEBUG("Generate right edges\n");
for(int i = 0; i < order; i++) { for(int i = 0; i < order; i++) {
for(int j = 0; j < rank; j++) { for(int j = 0; j < rank; j++) {
@ -183,7 +214,7 @@ int main(int argc, const char *argv[])
} }
} }
DEBUG("Find opposites\n"); // DEBUG("Find opposites\n");
node_t *longest = &graph[order-1]; node_t *longest = &graph[order-1];
for(int i = 0; i < order; i++) { for(int i = 0; i < order; i++) {
@ -193,7 +224,7 @@ int main(int argc, const char *argv[])
graph[i].opposite = current; graph[i].opposite = current;
} }
DEBUG("Enumerate hyperplanes\n"); // every right edge is a reflection along a hyperplane; calculate what this reflection does to the identity // DEBUG("Enumerate hyperplanes\n"); // every right edge is a reflection along a hyperplane; calculate what this reflection does to the identity
hyperplane_count = 0; hyperplane_count = 0;
for(int i = 0; i < order; i++) { for(int i = 0; i < order; i++) {
@ -214,8 +245,8 @@ int main(int argc, const char *argv[])
} }
} }
DEBUG("We have %d hyperplanes\n", hyperplane_count); // DEBUG("The Weyl chambers are bounded by %d hyperplanes\n", hyperplane_count);
DEBUG("Generate folding order\n"); // DEBUG("Generate folding order\n");
edgelists = (edgelist_t*)malloc(order*hyperplane_count*sizeof(edgelist_t)); edgelists = (edgelist_t*)malloc(order*hyperplane_count*sizeof(edgelist_t));
for(int i = 0; i < order; i++) { for(int i = 0; i < order; i++) {
@ -239,7 +270,7 @@ int main(int argc, const char *argv[])
} }
} }
DEBUG("Remove redundant edges\n"); // DEBUG("Remove redundant edges\n");
for(int i = 0; i < order; i++) { for(int i = 0; i < order; i++) {
memset(seen, 0, order*sizeof(int)); memset(seen, 0, order*sizeof(int));
@ -277,7 +308,7 @@ int main(int argc, const char *argv[])
} }
} }
DEBUG("Reverse folding order\n"); // DEBUG("Reverse folding order\n");
for(int i = 0; i < order; i++) { for(int i = 0; i < order; i++) {
edge = graph[i].bruhat_lower; edge = graph[i].bruhat_lower;
@ -290,17 +321,21 @@ int main(int argc, const char *argv[])
} }
} }
printf("The group is: \n"); printf("Rank: %d\t\tOrder: %d\t\tHyperplanes: %d\n", rank, order, hyperplane_count);
for(int i =0; i < order; i++) { printf("\n");
if(graph[i].wordlength == 0) printf("Group elements: \n");
for(int i = 0, wl = 0; i < order; i++) {
if(i == 0) {
printf("1"); printf("1");
else } else if(graph[i].wordlength > wl) {
printf("\n%s ", alphabetize(graph[i].word, graph[i].wordlength, alphabet, string_buffer1));
wl = graph[i].wordlength;
} else
printf("%s ", alphabetize(graph[i].word, graph[i].wordlength, alphabet, string_buffer1)); printf("%s ", alphabetize(graph[i].word, graph[i].wordlength, alphabet, string_buffer1));
} }
printf("\n"); printf("\n\n");
DEBUG("Enumerate thickenings\n"); // DEBUG("Enumerate thickenings\n");
DEBUG("\n");
thickenings_count = fat_count = slim_count = balanced_count = 0; thickenings_count = fat_count = slim_count = balanced_count = 0;
memset(level, 0, order*sizeof(int)); memset(level, 0, order*sizeof(int));
@ -339,17 +374,18 @@ int main(int argc, const char *argv[])
fat_count++; fat_count++;
if(is_slim) if(is_slim)
slim_count++; slim_count++;
if(is_slim && is_fat) if(is_slim && is_fat) {
ERROR(balanced_count >= MAX_THICKENINGS, "Too many balanced thickenings! Increase MAX_THICKENINGS\n");
memcpy(&balanced_thickenings[balanced_count*order], level, order*sizeof(int));
balanced_count++; balanced_count++;
}
// print out levels
if(is_fat && is_slim) { if(is_fat && is_slim) {
// check for invariances // check for invariances
for(int j = 0; j < rank; j++) { for(int j = 0; j < rank; j++) {
left_invariant[j] = 1; left_invariant[j] = 1;
right_invariant[j] = 1; right_invariant[j] = 1;
} }
for(int i = 0; i < order; i++) { for(int i = 0; i < order; i++) {
for(int j = 0; j < rank; j++) { for(int j = 0; j < rank; j++) {
if(level[i] == 0 && level[graph[i].left[j]] != 0 || level[i] != 0 && level[graph[i].left[j]] == 0) if(level[i] == 0 && level[graph[i].left[j]] != 0 || level[i] != 0 && level[graph[i].left[j]] == 0)
@ -358,26 +394,7 @@ int main(int argc, const char *argv[])
right_invariant[j] = 0; right_invariant[j] = 0;
} }
} }
print_balanced_thickening(rank, order, level, left_invariant, right_invariant, alphabet);
for(int i = 0; i < order; i++) {
if(level[i] != 0)
printf("x");
else
printf("%d", level[i]);
}
printf(" left: ");
for(int j = 0; j < rank; j++)
if(left_invariant[j])
printf("%c", alphabet[j]);
else
printf(" ");
printf(" right: ");
for(int j = 0; j < rank; j++)
if(right_invariant[j])
printf("%c", alphabet[j]);
else
printf(" ");
printf("\n");
} }
// try to find empty spot to the left of "head" // try to find empty spot to the left of "head"
@ -414,38 +431,41 @@ int main(int argc, const char *argv[])
for(int i = 0; i < head; i++) for(int i = 0; i < head; i++)
if(level[i] >= current_level) if(level[i] >= current_level)
level[i] = 0; level[i] = 0;
// print out levels
/* for(int i = 0; i < order; i++) { */
/* if(level[i] == -1) */
/* printf("x"); */
/* else */
/* printf("%d", level[i]); */
/* } */
/* printf(" %d\n", current_level); */
} }
printf("\n"); printf("\n");
printf("Found %d thickenings, %d fat, %d slim, %d balanced\n", thickenings_count, fat_count, slim_count, balanced_count); printf("Found %d thickenings, %d fat, %d slim, %d balanced\n\n", thickenings_count, fat_count, slim_count, balanced_count);
/* /*
printf("\n"); for(int i = 0; i < balanced_count; i++) {
// figure out invariances
for(int i = 0; i < order; i++) { for(int j = 0; j < rank; j++) {
printf("%-6s ", alphabetize(graph[i].word, graph[i].wordlength, alphabet, string_buffer1)); left_invariant[j] = 1;
right_invariant[j] = 1;
edge = graph[i].bruhat_higher;
while(edge) {
printf("-> %-6s ", alphabetize(graph[edge->to].word, graph[edge->to].wordlength, alphabet, string_buffer1));
edge = edge->next;
} }
//printf("Bruhat: %6s -> %-6s\n", alphabetize(graph[current].word, graph[current].wordlength, alphabet, string_buffer1), alphabetize(graph[j].word, graph[j].wordlength, alphabet, string_buffer2));
int *current_thickening = balanced_thickenings + i*order;
for(int k = 0; k < order; k++) {
for(int j = 0; j < rank; j++) {
if(current_thickening[k] == 0 && current_thickening[graph[k].left[j]] != 0 || current_thickening[k] != 0 && current_thickening[graph[k].left[j]] == 0)
left_invariant[j] = 0;
if(current_thickening[k] == 0 && current_thickening[graph[k].right[j]] != 0 || current_thickening[k] != 0 && current_thickening[graph[k].right[j]] == 0)
right_invariant[j] = 0;
}
}
printf("left: ");
for(int k = 0; k < rank; k++)
printf("%c", left_invariant[k] ? alphabet[k] : ' ');
printf(" right: ");
for(int k = 0; k < rank; k++)
printf("%c", right_invariant[k] ? alphabet[k] : ' ');
printf("\n"); printf("\n");
} }
printf("\n");
*/ */
free(edgelists); free(edgelists);
free(words); free(words);
free(string_buffer1); free(string_buffer1);
@ -462,6 +482,7 @@ int main(int argc, const char *argv[])
free(left_invariant); free(left_invariant);
free(right_invariant); free(right_invariant);
free(type.factors); free(type.factors);
free(balanced_thickenings);
return 0; return 0;
} }