From 1f031db03e9d4d04a7daa10b7122ab790a5c8708 Mon Sep 17 00:00:00 2001 From: Florian Stecker Date: Tue, 6 Sep 2016 11:23:15 +0200 Subject: [PATCH] Nice process, F4, test program to find representatives of classes of equivalence by generators --- Makefile | 2 +- coxeter.c | 8 ++++++ process.c | 79 +++++++++++++++++++++++++-------------------------- test.c | 31 +++++++++++++++++--- thickenings.c | 6 ++-- 5 files changed, 78 insertions(+), 48 deletions(-) diff --git a/Makefile b/Makefile index e718ff6..462b2da 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ HEADERS=coxeter.h thickenings.h queue.h -OPTIONS=-O3 -g -std=gnu99 +OPTIONS=-O3 -std=gnu99 all: generate process test diff --git a/coxeter.c b/coxeter.c index 122f7b3..1fc78aa 100644 --- a/coxeter.c +++ b/coxeter.c @@ -70,6 +70,14 @@ static void generate_schlaefli_matrix(semisimple_type_t type, gsl_matrix *mat) gsl_matrix_set(mat, offset + i, offset + j, 2.0); else if(i > 0 && j > 0 && (i - j == 1 || i - j == -1) || i == 0 && j == 2 || i == 2 && j == 0) gsl_matrix_set(mat, offset + i, offset + j, -1.0); + } else if(type.factors[k].series == 'F') { + ERROR(type.factors[k].rank != 4, "A Coxeter group of type %c%d does not exist or is not implemented!\n", type.factors[k].series, type.factors[k].rank); + for(int i = 0; i < 4; i++) + gsl_matrix_set(mat, offset + i, offset + i, 2.0); + for(int i = 0; i < 3; i++) { + gsl_matrix_set(mat, offset + i, offset + i + 1, i == 1 ? -sqrt(2.0) : -1.0); + gsl_matrix_set(mat, offset + i + 1, offset + i, i == 1 ? -sqrt(2.0) : -1.0); + } } else if(type.factors[k].series == 'G') { ERROR(type.factors[k].rank != 2, "A Coxeter group of type %c%d does not exist or is not implemented!\n", type.factors[k].series, type.factors[k].rank); gsl_matrix_set(mat, offset + 0, offset + 0, 2.0); diff --git a/process.c b/process.c index f548f44..c62cad2 100644 --- a/process.c +++ b/process.c @@ -51,7 +51,8 @@ int main(int argc, const char *argv[]) signed char *level; node_t *graph; int *left, *right; - int *left_invariant, *right_invariant; + int left_invariant, right_invariant; + int left_invariant_wanted = 0, right_invariant_wanted = 0; edgelist_t *edgelists; int *words; @@ -59,7 +60,7 @@ int main(int argc, const char *argv[]) int current; int *seen; int *generators; - int ngens, nleft, nright; + int ngens; char string_buffer1[1000]; const char *alphabet = "abcdefghijklmnopqrstuvwxyz"; @@ -68,8 +69,21 @@ int main(int argc, const char *argv[]) if(argc < 2) infile = stdin; - else - infile = fopen(argv[1], "rb"); + else { + if(strcmp(argv[1], "-") == 0) + infile = stdin; + else + infile = fopen(argv[1], "rb"); + + if(argc >= 4) { + if(strcmp(argv[2], "-") != 0) + for(int i = 0; i < strlen(argv[2]); i++) + left_invariant_wanted |= (1 << (argv[2][i] - 'a')); + if(strcmp(argv[3], "-") != 0) + for(int i = 0; i < strlen(argv[3]); i++) + right_invariant_wanted |= (1 << (argv[3][i] - 'a')); + } + } fread(&type.n, sizeof(int), 1, infile); // we completely trust the input data type.factors = malloc(type.n * sizeof(simple_type_t)); @@ -83,8 +97,6 @@ int main(int argc, const char *argv[]) graph = (node_t*)malloc(order*sizeof(node_t)); left = (int*)malloc(order*rank*sizeof(int)); right = (int*)malloc(order*rank*sizeof(int)); - left_invariant = (int*)malloc(rank*sizeof(int)); - right_invariant = (int*)malloc(rank*sizeof(int)); seen = (int*)malloc(order*sizeof(int)); generators = (int*)malloc(order*sizeof(int)); level = (signed char*)malloc(order*sizeof(int)); @@ -106,57 +118,46 @@ int main(int argc, const char *argv[]) continue; */ - for(int j = 0; j < rank; j++) { - left_invariant[j] = 1; - right_invariant[j] = 1; - } + left_invariant = right_invariant = -1; // all 1s for(int j = 0; j < order; j++) { for(int k = 0; k < rank; k++) { if(level[j] > 0 && level[graph[j].left[k]] < 0 || level[j] < 0 && level[graph[j].left[k]] > 0) { - left_invariant[k] = 0; + left_invariant &= ~(1 << k); } if(level[j] > 0 && level[graph[j].right[k]] < 0 || level[j] < 0 && level[graph[j].right[k]] > 0) { - right_invariant[k] = 0; + right_invariant &= ~(1 << k); } } } - nleft = nright = 0; - for(int j = 0; j < rank; j ++) { - if(left_invariant[j]) - nleft++; - if(right_invariant[j]) - nright++; - } - - ngens = 0; - memset(generators, 0, order*sizeof(int)); - for(int j = 0; j < order; j++) { - if(level[j] == HEAD_MARKER && generators[j] == 0) { // ignore the generator, if it is equivalent to one already seen - ngens++; - queue_init(&queue); - queue_put(&queue, j); - while((current = queue_get(&queue)) != -1) { - if(generators[current] == 0) { // visit everyone only once - generators[current] = ngens; - for(int k = 0; k < rank; k++) { - if(left_invariant[k]) + if((~left_invariant & left_invariant_wanted) == 0 && (~right_invariant & right_invariant_wanted) == 0) { + ngens = 0; + memset(generators, 0, order*sizeof(int)); + for(int j = 0; j < order; j++) { + if(level[j] == HEAD_MARKER && generators[j] == 0) { // ignore the generator, if it is equivalent to one already seen + ngens++; + queue_init(&queue); + queue_put(&queue, j); + while((current = queue_get(&queue)) != -1) { + if(generators[current] == 0) { // visit everyone only once + generators[current] = ngens; + for(int k = 0; k < rank; k++) { + if(left_invariant & (1 << k)) queue_put(&queue, graph[current].left[k]); - if(right_invariant[k]) - queue_put(&queue, graph[current].right[k]); + if(right_invariant & (1 << k)) + queue_put(&queue, graph[current].right[k]); + } } } } } - } - if(nleft >= 2 && nright >= 2) { printf("left: "); for(int j = 0; j < rank; j++) - printf("%c", left_invariant[j] ? alphabet[j] : ' '); + printf("%c", left_invariant & (1 << j) ? alphabet[j] : ' '); printf(" right: "); for(int j = 0; j < rank; j++) - printf("%c", right_invariant[j] ? alphabet[j] : ' '); + printf("%c", right_invariant & (1 << j) ? alphabet[j] : ' '); printf(" generators: "); memset(seen, 0, order*sizeof(int)); @@ -190,8 +191,6 @@ int main(int argc, const char *argv[]) free(graph); free(left); free(right); - free(right_invariant); - free(left_invariant); free(seen); free(generators); free(type.factors); diff --git a/test.c b/test.c index 742410c..385ae14 100644 --- a/test.c +++ b/test.c @@ -3,6 +3,28 @@ #include "thickenings.h" #include "queue.h" +#define SWAP(t, a, b) do {t tmp = a; a = b; b = tmp;} while(0) + +char *stringify_Sp2n_permutation(int *word, int wordlength, int rank, int len, char *str) +{ + for(int i = 0; i < rank*2; i++) + str[i] = '1' + i; + str[2*rank] = 0; + + for(int i = 0; i < wordlength; i++) { + if(word[i] == 0) + SWAP(char, str[rank-1], str[2*rank-1]); + else { + SWAP(char, str[rank-word[i]], str[rank-word[i]-1]); + SWAP(char, str[2*rank-word[i]], str[2*rank-word[i]-1]); + } + } + + str[len] = 0; + + return str; +} + int main(int argc, const char *argv[]) { semisimple_type_t type; @@ -17,13 +39,13 @@ int main(int argc, const char *argv[]) char alphabet[] = "abcdefghijklmnopqrstuvwxyz"; char buffer[1024]; - int left = ~0x01; // 1111 1110 - int right = ~0x01; // 1111 1101 + int left = ~(1 << (atoi(argv[1]) - atoi(argv[3]))); + int right = ~(1 << (atoi(argv[1]) - atoi(argv[2]))); type.n = 1; type.factors = (simple_type_t*)malloc(type.n*sizeof(simple_type_t)); type.factors[0].series = 'B'; - type.factors[0].rank = 4; + type.factors[0].rank = atoi(argv[1]); rank = coxeter_rank(type); order = coxeter_order(type); @@ -77,9 +99,10 @@ int main(int argc, const char *argv[]) for(int i = 0; i < order; i++) if(reduced[i] == i) { if(i == 0) - printf("1 "); + printf("1 "); else printf("%s ", alphabetize(graph[i].word, graph[i].wordlength, alphabet, buffer)); + // printf("%s ", stringify_Sp2n_permutation(graph[i].word, graph[i].wordlength, rank, atoi(argv[2]), buffer)); } printf("\n"); diff --git a/thickenings.c b/thickenings.c index 71fee42..9d72f56 100644 --- a/thickenings.c +++ b/thickenings.c @@ -375,9 +375,9 @@ void enumerate_balanced_thickenings(semisimple_type_t type, node_t *graph, const if(is_fat) { // ERROR(count >= MAX_THICKENINGS, "Too many balanced thickenings! Increase MAX_THICKENINGS\n"); - if(count % 10000000 == 0) - print_thickening(rank, order, level, 0, 0, 0, alphabet, stderr); - // fwrite(level, sizeof(signed char), order, outfile); + //if(count % 10000000 == 0) + //print_thickening(rank, order, level, 0, 0, 0, alphabet, stderr); + fwrite(level, sizeof(signed char), order, outfile); count++; } }