enumerate-balanced-ideals/generate.c

120 lines
3.6 KiB
C
Raw Normal View History

2016-11-19 10:16:45 +00:00
#include "thickenings.h"
2016-11-20 22:19:08 +00:00
#include "weyl.h"
2016-07-26 08:09:34 +00:00
#include "queue.h"
2016-11-19 10:16:45 +00:00
#include <strings.h>
#include <stdio.h>
void balanced_thickening_callback(const bitvec_t *pos, int size, void *data)
{
static long totcount = 0;
if((++totcount) % 100000000 == 0) {
fprintf(stderr, "Found balanced ideal: ");
bv_print(stderr, pos, size/2);
fprintf(stderr, "\n");
}
}
2016-07-26 08:09:34 +00:00
int main(int argc, const char *argv[])
{
semisimple_type_t type;
2016-11-11 16:07:45 +00:00
unsigned long right_invariance, left_invariance;
int rank, order, hyperplanes, cosets;
2016-11-14 10:54:52 +00:00
int fixpoints;
2016-07-26 08:09:34 +00:00
node_t *graph;
char string_buffer1[1000];
const char *alphabet = "abcdefghijklmnopqrstuvwxyz";
2016-11-11 16:07:45 +00:00
// read arguments
2016-07-26 08:09:34 +00:00
ERROR(argc < 2, "Too few arguments!\n");
2016-11-11 16:07:45 +00:00
type.n = 0;
2016-07-26 08:09:34 +00:00
for(int i = 0; i < argc - 1; i++) {
2016-11-11 16:07:45 +00:00
if(argv[i+1][0] < 'A' || argv[i+1][0] > 'I')
break;
type.n++;
}
type.factors = (simple_type_t*)malloc(type.n*sizeof(simple_type_t));
for(int i = 0; i < type.n; i++) {
2016-07-26 08:09:34 +00:00
type.factors[i].series = argv[i+1][0];
type.factors[i].rank = argv[i+1][1] - '0';
ERROR(argv[i+1][0] < 'A' || argv[i+1][0] > 'I' || argv[i+1][1] < '1' || argv[i+1][1] > '9', "Arguments must be Xn with X out of A-I and n out of 0-9\n");
}
2016-11-11 16:07:45 +00:00
left_invariance = right_invariance = 0;
2016-07-26 08:09:34 +00:00
2016-11-11 16:07:45 +00:00
if(argc - type.n >= 3) {
if(strcmp(argv[type.n + 1], "-") != 0)
for(int i = 0; i < strlen(argv[type.n + 1]); i++)
left_invariance |= (1 << (argv[type.n + 1][i] - 'a'));
if(strcmp(argv[type.n + 2], "-") != 0)
for(int i = 0; i < strlen(argv[type.n + 2]); i++)
right_invariance |= (1 << (argv[type.n + 2][i] - 'a'));
2016-07-26 08:09:34 +00:00
}
2016-11-11 16:07:45 +00:00
ERROR(strlen(alphabet) < rank, "The alphabet has too few letters\n");
2016-07-26 08:09:34 +00:00
// generate graph
2016-11-11 16:07:45 +00:00
graph = graph_alloc(type);
cosets = prepare_simplified_graph(type, left_invariance, right_invariance, graph);
2016-11-20 22:19:08 +00:00
ERROR(cosets < 0, "The left invariance is not preserved by the opposition involution!\n");
2016-07-26 08:09:34 +00:00
// print stuff
2016-11-20 22:19:08 +00:00
rank = weyl_rank(type); // number of simple roots
order = weyl_order(type); // number of Weyl group elements
hyperplanes = weyl_hyperplanes(type); // number of positive roots
2016-07-26 08:09:34 +00:00
2016-11-11 16:07:45 +00:00
fprintf(stderr, "Rank: %d\tOrder: %d\tPositive Roots: %d\tCosets: %d\n", rank, order, hyperplanes, cosets);
2016-07-26 08:09:34 +00:00
fprintf(stderr, "\n");
2016-11-19 10:16:45 +00:00
/*
2016-11-11 16:07:45 +00:00
fprintf(stderr, "Shortest coset representatives: \n");
for(int i = 0, wl = 0; i < cosets; i++) {
2016-07-26 08:09:34 +00:00
if(i == 0) {
fprintf(stderr, "1");
} else if(graph[i].wordlength > wl) {
fprintf(stderr, "\n%s ", alphabetize(graph[i].word, graph[i].wordlength, alphabet, string_buffer1));
wl = graph[i].wordlength;
} else
fprintf(stderr, "%s ", alphabetize(graph[i].word, graph[i].wordlength, alphabet, string_buffer1));
}
fprintf(stderr, "\n\n");
2016-11-19 10:16:45 +00:00
*/
2016-07-26 08:09:34 +00:00
2016-11-14 10:54:52 +00:00
fixpoints = 0;
for(int i = 0; i < cosets; i++)
if(graph[i].opposite == i) {
if(fixpoints == 0)
fprintf(stderr, "No thickenings since the longest element fixes the following cosets: %s", alphabetize(graph[i].word, graph[i].wordlength, alphabet, string_buffer1));
else
fprintf(stderr, " %s", alphabetize(graph[i].word, graph[i].wordlength, alphabet, string_buffer1));
fixpoints++;
}
if(fixpoints > 0) {
fprintf(stderr, "\n\n");
} else {
fwrite(&type.n, sizeof(int), 1, stdout);
fwrite(type.factors, sizeof(simple_type_t), type.n, stdout);
fwrite(&left_invariance, sizeof(unsigned long), type.n, stdout);
fwrite(&right_invariance, sizeof(unsigned long), type.n, stdout);
2016-11-19 10:16:45 +00:00
long count = enumerate_balanced_thickenings(graph, cosets, balanced_thickening_callback, (void*)0);
2016-11-14 10:54:52 +00:00
fprintf(stderr, "Found %ld balanced thickenings\n\n", count);
}
2016-07-26 08:09:34 +00:00
2016-11-11 16:07:45 +00:00
graph_free(type, graph);
2016-07-26 08:09:34 +00:00
free(type.factors);
return 0;
}