enumerate-balanced-ideals/idealbounds.c

75 lines
1.7 KiB
C
Raw Normal View History

2017-11-28 15:58:29 +00:00
#include "weyl.h"
#include "queue.h"
#include <limits.h>
#include <string.h>
#include <stdio.h>
static char* alphabetize(weylgroup_element_t *e, char *str)
{
if(e->wordlength == 0)
sprintf(str, "1");
else {
for(int j = 0; j < e->wordlength; j++)
str[j] = e->word[j] + 'a';
str[e->wordlength] = 0;
}
return str;
}
2017-11-28 15:58:29 +00:00
int main(int argc, char *argv[])
{
semisimple_type_t type;
simple_type_t simple;
char buf[100];
2017-11-28 15:58:29 +00:00
simple.series = 'A';
simple.rank = atoi(argv[1]);
type.n = 1;
type.factors = &simple;
int order = weyl_order(type);
doublequotient_t *dq = weyl_generate_bruhat(type, 0, 0);
queue_t q;
int cur;
int *viewed = (int*)malloc(order*sizeof(int));
int found;
int minimum = INT_MAX;
for(int i = 0; i < order; i++) {
found = 0;
memset(viewed, 0, order*sizeof(int));
queue_init(&q);
queue_put(&q, dq->cosets[i].opposite->index);
while((cur = queue_get(&q)) != -1) {
if(cur == i) { // found what we were looking for
// printf("foo: %d %d\n", i, dq->cosets[i].min->wordlength);
found = 1;
break;
}
for(doublecoset_list_t *current = dq->cosets[cur].bruhat_lower; current; current = current->next) {
if(!viewed[current->to->index]) {
viewed[current->to->index] = 1;
queue_put(&q, current->to->index);
}
}
}
if(!found) {
printf("%s %d not found\n", alphabetize(dq->cosets[i].min, buf), dq->cosets[i].min->wordlength);
2017-11-28 15:58:29 +00:00
if(dq->cosets[i].min->wordlength < minimum)
minimum = dq->cosets[i].min->wordlength;
// break;
2017-11-28 15:58:29 +00:00
} else {
printf("%s %d found\n", alphabetize(dq->cosets[i].min, buf), dq->cosets[i].min->wordlength);
2017-11-28 15:58:29 +00:00
}
}
printf("Minimum l(w) such that w0w can be in a balanced ideal: %d\n", minimum);
free(viewed);
return 0;
}