Nice process, F4, test program to find representatives of classes of equivalence by generators

This commit is contained in:
Florian Stecker 2016-09-06 11:23:15 +02:00
parent bb91e24b8a
commit 1f031db03e
5 changed files with 78 additions and 48 deletions

View File

@ -1,5 +1,5 @@
HEADERS=coxeter.h thickenings.h queue.h HEADERS=coxeter.h thickenings.h queue.h
OPTIONS=-O3 -g -std=gnu99 OPTIONS=-O3 -std=gnu99
all: generate process test all: generate process test

View File

@ -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); 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) 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); 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') { } 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); 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); gsl_matrix_set(mat, offset + 0, offset + 0, 2.0);

View File

@ -51,7 +51,8 @@ int main(int argc, const char *argv[])
signed char *level; signed char *level;
node_t *graph; node_t *graph;
int *left, *right; 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; edgelist_t *edgelists;
int *words; int *words;
@ -59,7 +60,7 @@ int main(int argc, const char *argv[])
int current; int current;
int *seen; int *seen;
int *generators; int *generators;
int ngens, nleft, nright; int ngens;
char string_buffer1[1000]; char string_buffer1[1000];
const char *alphabet = "abcdefghijklmnopqrstuvwxyz"; const char *alphabet = "abcdefghijklmnopqrstuvwxyz";
@ -68,8 +69,21 @@ int main(int argc, const char *argv[])
if(argc < 2) if(argc < 2)
infile = stdin; infile = stdin;
else else {
infile = fopen(argv[1], "rb"); 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 fread(&type.n, sizeof(int), 1, infile); // we completely trust the input data
type.factors = malloc(type.n * sizeof(simple_type_t)); 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)); graph = (node_t*)malloc(order*sizeof(node_t));
left = (int*)malloc(order*rank*sizeof(int)); left = (int*)malloc(order*rank*sizeof(int));
right = (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)); seen = (int*)malloc(order*sizeof(int));
generators = (int*)malloc(order*sizeof(int)); generators = (int*)malloc(order*sizeof(int));
level = (signed char*)malloc(order*sizeof(int)); level = (signed char*)malloc(order*sizeof(int));
@ -106,57 +118,46 @@ int main(int argc, const char *argv[])
continue; continue;
*/ */
for(int j = 0; j < rank; j++) { left_invariant = right_invariant = -1; // all 1s
left_invariant[j] = 1;
right_invariant[j] = 1;
}
for(int j = 0; j < order; j++) { for(int j = 0; j < order; j++) {
for(int k = 0; k < rank; k++) { 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) { 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) { 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; if((~left_invariant & left_invariant_wanted) == 0 && (~right_invariant & right_invariant_wanted) == 0) {
for(int j = 0; j < rank; j ++) { ngens = 0;
if(left_invariant[j]) memset(generators, 0, order*sizeof(int));
nleft++; for(int j = 0; j < order; j++) {
if(right_invariant[j]) if(level[j] == HEAD_MARKER && generators[j] == 0) { // ignore the generator, if it is equivalent to one already seen
nright++; ngens++;
} queue_init(&queue);
queue_put(&queue, j);
ngens = 0; while((current = queue_get(&queue)) != -1) {
memset(generators, 0, order*sizeof(int)); if(generators[current] == 0) { // visit everyone only once
for(int j = 0; j < order; j++) { generators[current] = ngens;
if(level[j] == HEAD_MARKER && generators[j] == 0) { // ignore the generator, if it is equivalent to one already seen for(int k = 0; k < rank; k++) {
ngens++; if(left_invariant & (1 << k))
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])
queue_put(&queue, graph[current].left[k]); queue_put(&queue, graph[current].left[k]);
if(right_invariant[k]) if(right_invariant & (1 << k))
queue_put(&queue, graph[current].right[k]); queue_put(&queue, graph[current].right[k]);
}
} }
} }
} }
} }
}
if(nleft >= 2 && nright >= 2) {
printf("left: "); printf("left: ");
for(int j = 0; j < rank; j++) for(int j = 0; j < rank; j++)
printf("%c", left_invariant[j] ? alphabet[j] : ' '); printf("%c", left_invariant & (1 << j) ? alphabet[j] : ' ');
printf(" right: "); printf(" right: ");
for(int j = 0; j < rank; j++) for(int j = 0; j < rank; j++)
printf("%c", right_invariant[j] ? alphabet[j] : ' '); printf("%c", right_invariant & (1 << j) ? alphabet[j] : ' ');
printf(" generators: "); printf(" generators: ");
memset(seen, 0, order*sizeof(int)); memset(seen, 0, order*sizeof(int));
@ -190,8 +191,6 @@ int main(int argc, const char *argv[])
free(graph); free(graph);
free(left); free(left);
free(right); free(right);
free(right_invariant);
free(left_invariant);
free(seen); free(seen);
free(generators); free(generators);
free(type.factors); free(type.factors);

31
test.c
View File

@ -3,6 +3,28 @@
#include "thickenings.h" #include "thickenings.h"
#include "queue.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[]) int main(int argc, const char *argv[])
{ {
semisimple_type_t type; semisimple_type_t type;
@ -17,13 +39,13 @@ int main(int argc, const char *argv[])
char alphabet[] = "abcdefghijklmnopqrstuvwxyz"; char alphabet[] = "abcdefghijklmnopqrstuvwxyz";
char buffer[1024]; char buffer[1024];
int left = ~0x01; // 1111 1110 int left = ~(1 << (atoi(argv[1]) - atoi(argv[3])));
int right = ~0x01; // 1111 1101 int right = ~(1 << (atoi(argv[1]) - atoi(argv[2])));
type.n = 1; type.n = 1;
type.factors = (simple_type_t*)malloc(type.n*sizeof(simple_type_t)); type.factors = (simple_type_t*)malloc(type.n*sizeof(simple_type_t));
type.factors[0].series = 'B'; type.factors[0].series = 'B';
type.factors[0].rank = 4; type.factors[0].rank = atoi(argv[1]);
rank = coxeter_rank(type); rank = coxeter_rank(type);
order = coxeter_order(type); order = coxeter_order(type);
@ -77,9 +99,10 @@ int main(int argc, const char *argv[])
for(int i = 0; i < order; i++) for(int i = 0; i < order; i++)
if(reduced[i] == i) { if(reduced[i] == i) {
if(i == 0) if(i == 0)
printf("1 "); printf("1 ");
else else
printf("%s ", alphabetize(graph[i].word, graph[i].wordlength, alphabet, buffer)); 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"); printf("\n");

View File

@ -375,9 +375,9 @@ void enumerate_balanced_thickenings(semisimple_type_t type, node_t *graph, const
if(is_fat) { if(is_fat) {
// ERROR(count >= MAX_THICKENINGS, "Too many balanced thickenings! Increase MAX_THICKENINGS\n"); // ERROR(count >= MAX_THICKENINGS, "Too many balanced thickenings! Increase MAX_THICKENINGS\n");
if(count % 10000000 == 0) //if(count % 10000000 == 0)
print_thickening(rank, order, level, 0, 0, 0, alphabet, stderr); //print_thickening(rank, order, level, 0, 0, 0, alphabet, stderr);
// fwrite(level, sizeof(signed char), order, outfile); fwrite(level, sizeof(signed char), order, outfile);
count++; count++;
} }
} }