Levels
This commit is contained in:
parent
1c65abd735
commit
fc4ee42646
124
thickenings.c
124
thickenings.c
@ -631,7 +631,7 @@ typedef struct {
|
||||
|
||||
*/
|
||||
|
||||
static long enumerate_tree(const enumeration_info_t *info, const bitvec_t *pos, const bitvec_t *neg, int next_neg, int already_known)
|
||||
static long enumerate_tree(const enumeration_info_t *info, const bitvec_t *pos, const bitvec_t *neg, int next_neg, int already_known, int level)
|
||||
{
|
||||
static long totcount = 0;
|
||||
bitvec_t newpos, newneg, known;
|
||||
@ -676,13 +676,76 @@ static long enumerate_tree(const enumeration_info_t *info, const bitvec_t *pos,
|
||||
}
|
||||
|
||||
do {
|
||||
count += enumerate_tree(info, &newpos, &newneg, next_next_neg, next_neg + 1);
|
||||
count += enumerate_tree(info, &newpos, &newneg, next_next_neg, next_neg + 1, level + 1);
|
||||
next_next_neg = bv_next_zero(&known, next_next_neg + 1);
|
||||
} while(next_next_neg <= info->size/2);
|
||||
|
||||
// multiprocessing stuff
|
||||
// if(level == 3)
|
||||
// fprintf(stderr, "%d\n", count);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
void generate_principal_ideals(node_t *graph, int size, bitvec_t *pos, bitvec_t *neg, int *is_slim)
|
||||
{
|
||||
queue_t queue;
|
||||
int current;
|
||||
edgelist_t *edge;
|
||||
|
||||
// generate principal ideals
|
||||
int *principal = (int*)malloc(size*sizeof(int));
|
||||
for(int i = 0; i < size; i++) {
|
||||
memset(principal, 0, size*sizeof(int));
|
||||
principal[i] = 1;
|
||||
queue_init(&queue);
|
||||
queue_put(&queue, i);
|
||||
while((current = queue_get(&queue)) != -1)
|
||||
for(edge = graph[current].bruhat_lower; edge; edge = edge->next)
|
||||
if(!principal[edge->to]) {
|
||||
principal[edge->to] = 1;
|
||||
queue_put(&queue, edge->to);
|
||||
}
|
||||
|
||||
// copy the first half into bitvectors
|
||||
bv_clear(&pos[i]);
|
||||
bv_clear(&neg[i]);
|
||||
is_slim[i] = 1;
|
||||
for(int j = 0; j < size/2; j++)
|
||||
if(principal[j])
|
||||
bv_set_bit(&pos[i], j);
|
||||
for(int j = 0; j < size/2; j++)
|
||||
if(principal[size - 1 - j]) {
|
||||
bv_set_bit(&neg[i], j);
|
||||
if(bv_get_bit(&pos[i], j))
|
||||
is_slim[i] = 0;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
if(is_slim[i]) {
|
||||
fprintf(stderr, " ids: [0");
|
||||
for(int j = 1; j < size; j++)
|
||||
if(principal[j])
|
||||
fprintf(stderr, ", %d", graph[j].id);
|
||||
fprintf(stderr, "]\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
free(principal);
|
||||
|
||||
// output principal ideals
|
||||
#ifdef _DEBUG
|
||||
for(int i = 0; i < size; i++) {
|
||||
fprintf(stderr, "%2d: ", i);
|
||||
bv_print_nice(stderr, &pos[i], &neg[i], -1, size/2);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
enumerates all balanced ideals
|
||||
|
||||
@ -696,12 +759,8 @@ static long enumerate_tree(const enumeration_info_t *info, const bitvec_t *pos,
|
||||
|
||||
long enumerate_balanced_thickenings(node_t *graph, int size, void (*callback) (const bitvec_t *, int, void*), void *callback_data)
|
||||
{
|
||||
signed char *level;
|
||||
long count = 0;
|
||||
enumeration_info_t info;
|
||||
queue_t queue;
|
||||
int current;
|
||||
edgelist_t *edge;
|
||||
|
||||
info.size = size;
|
||||
info.callback = callback;
|
||||
@ -720,63 +779,14 @@ long enumerate_balanced_thickenings(node_t *graph, int size, void (*callback) (c
|
||||
if(info.size > 128*BV_QWORD_RANK)
|
||||
return -1;
|
||||
|
||||
// generate principal ideals
|
||||
int *principal = (int*)malloc(info.size*sizeof(int));
|
||||
for(int i = 0; i < info.size; i++) {
|
||||
memset(principal, 0, info.size*sizeof(int));
|
||||
principal[i] = 1;
|
||||
queue_init(&queue);
|
||||
queue_put(&queue, i);
|
||||
while((current = queue_get(&queue)) != -1)
|
||||
for(edge = graph[current].bruhat_lower; edge; edge = edge->next)
|
||||
if(!principal[edge->to]) {
|
||||
principal[edge->to] = 1;
|
||||
queue_put(&queue, edge->to);
|
||||
}
|
||||
|
||||
// copy the first half into bitvectors
|
||||
bv_clear(&info.principal_pos[i]);
|
||||
bv_clear(&info.principal_neg[i]);
|
||||
info.principal_is_slim[i] = 1;
|
||||
for(int j = 0; j < info.size/2; j++)
|
||||
if(principal[j])
|
||||
bv_set_bit(&info.principal_pos[i], j);
|
||||
for(int j = 0; j < info.size/2; j++)
|
||||
if(principal[info.size - 1 - j]) {
|
||||
bv_set_bit(&info.principal_neg[i], j);
|
||||
if(bv_get_bit(&info.principal_pos[i], j))
|
||||
info.principal_is_slim[i] = 0;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
if(info.principal_is_slim[i]) {
|
||||
fprintf(stderr, " ids: [0");
|
||||
for(int j = 1; j < info.size; j++)
|
||||
if(principal[j])
|
||||
fprintf(stderr, ", %d", graph[j].id);
|
||||
fprintf(stderr, "]\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
free(principal);
|
||||
|
||||
// output principal ideals
|
||||
#ifdef _DEBUG
|
||||
for(int i = 0; i < info.size; i++) {
|
||||
fprintf(stderr, "%2d: ", i);
|
||||
bv_print_nice(stderr, &info.principal_pos[i], &info.principal_neg[i], -1, info.size/2);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
#endif
|
||||
generate_principal_ideals(graph, size, info.principal_pos, info.principal_neg, info.principal_is_slim);
|
||||
|
||||
// enumerate balanced ideals
|
||||
bitvec_t pos, neg;
|
||||
bv_clear(&pos);
|
||||
bv_clear(&neg);
|
||||
for(int i = 0; i <= info.size/2; i++)
|
||||
count += enumerate_tree(&info, &pos, &neg, i, 0);
|
||||
count += enumerate_tree(&info, &pos, &neg, i, 0, 0);
|
||||
|
||||
free(info.principal_is_slim);
|
||||
free(info.principal_pos);
|
||||
|
Loading…
Reference in New Issue
Block a user