Fixes
This commit is contained in:
parent
161d850294
commit
b823aa7b0b
30
bitvec.h
30
bitvec.h
@ -23,7 +23,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
// FIRSTBITS(n) only yields useful result when 0 <= n < 64
|
// FIRSTBITS(n) only yields useful result when 0 <= n < 64
|
||||||
#define BLOCKSIZE 64
|
#define BV_RANK 10
|
||||||
|
#define BV_BLOCKSIZE 64
|
||||||
|
|
||||||
#define FIRSTBITS(n) (((uint64_t)1 << (n)) - 1l)
|
#define FIRSTBITS(n) (((uint64_t)1 << (n)) - 1l)
|
||||||
#define BIT(n) (((uint64_t)1 << (n)))
|
#define BIT(n) (((uint64_t)1 << (n)))
|
||||||
#define ALLBITS ((uint64_t)-1)
|
#define ALLBITS ((uint64_t)-1)
|
||||||
@ -31,7 +33,7 @@
|
|||||||
#define INDEX(n) ((n)%64)
|
#define INDEX(n) ((n)%64)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t v[BV_QWORD_RANK];
|
uint64_t v[BV_RANK];
|
||||||
} bitvec_t;
|
} bitvec_t;
|
||||||
|
|
||||||
static inline void bv_clear_bit(bitvec_t *x, int k)
|
static inline void bv_clear_bit(bitvec_t *x, int k)
|
||||||
@ -52,14 +54,14 @@ static inline int bv_get_bit(const bitvec_t *x, int k)
|
|||||||
static inline void bv_clear(bitvec_t *x)
|
static inline void bv_clear(bitvec_t *x)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<BV_QWORD_RANK;i++)
|
for (i=0;i<BV_RANK;i++)
|
||||||
x->v[i] = 0;
|
x->v[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int bv_is_zero(const bitvec_t *x)
|
static inline int bv_is_zero(const bitvec_t *x)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<BV_QWORD_RANK;i++)
|
for (i=0;i<BV_RANK;i++)
|
||||||
if (x->v[i])
|
if (x->v[i])
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -94,7 +96,7 @@ static inline void bv_print_nice(FILE *f, const bitvec_t *pos, const bitvec_t *n
|
|||||||
static inline void bv_union(const bitvec_t *x, const bitvec_t *y, bitvec_t *result)
|
static inline void bv_union(const bitvec_t *x, const bitvec_t *y, bitvec_t *result)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i < BV_QWORD_RANK; i++) {
|
for (i=0; i < BV_RANK; i++) {
|
||||||
result->v[i] = x->v[i] | y->v[i];
|
result->v[i] = x->v[i] | y->v[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,7 +104,7 @@ static inline void bv_union(const bitvec_t *x, const bitvec_t *y, bitvec_t *resu
|
|||||||
static inline void bv_intersection(const bitvec_t *x, const bitvec_t *y, bitvec_t *result)
|
static inline void bv_intersection(const bitvec_t *x, const bitvec_t *y, bitvec_t *result)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i < BV_QWORD_RANK; i++) {
|
for (i=0; i < BV_RANK; i++) {
|
||||||
result->v[i] = x->v[i] & y->v[i];
|
result->v[i] = x->v[i] & y->v[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,14 +112,14 @@ static inline void bv_intersection(const bitvec_t *x, const bitvec_t *y, bitvec_
|
|||||||
static inline void bv_difference(const bitvec_t *x, const bitvec_t *y, bitvec_t *result)
|
static inline void bv_difference(const bitvec_t *x, const bitvec_t *y, bitvec_t *result)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i < BV_QWORD_RANK; i++) {
|
for (i=0; i < BV_RANK; i++) {
|
||||||
result->v[i] = x->v[i] & ~y->v[i];
|
result->v[i] = x->v[i] & ~y->v[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int bv_disjoint(const bitvec_t *x, const bitvec_t *y)
|
static inline int bv_disjoint(const bitvec_t *x, const bitvec_t *y)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < BV_QWORD_RANK; i++)
|
for(int i = 0; i < BV_RANK; i++)
|
||||||
if(x->v[i] & y->v[i])
|
if(x->v[i] & y->v[i])
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -168,26 +170,26 @@ static inline int bv_next_zero(const bitvec_t *x, int start)
|
|||||||
position = ffsll(~(x->v[BLOCK(start)] | FIRSTBITS(INDEX(start))));
|
position = ffsll(~(x->v[BLOCK(start)] | FIRSTBITS(INDEX(start))));
|
||||||
|
|
||||||
if(position)
|
if(position)
|
||||||
return BLOCK(start)*BLOCKSIZE + position - 1; // found zero in same chunk
|
return BLOCK(start)*BV_BLOCKSIZE + position - 1; // found zero in same chunk
|
||||||
|
|
||||||
for(int i = BLOCK(start) + 1; i < BV_QWORD_RANK; i++) {
|
for(int i = BLOCK(start) + 1; i < BV_RANK; i++) {
|
||||||
position = ffsll(~x->v[i]);
|
position = ffsll(~x->v[i]);
|
||||||
if(position) // found a 0
|
if(position) // found a 0
|
||||||
return i*BLOCKSIZE + position - 1;
|
return i*BV_BLOCKSIZE + position - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return BV_QWORD_RANK*BLOCKSIZE; // found nothing
|
return BV_RANK*BV_BLOCKSIZE; // found nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bv_copy(const bitvec_t *from, bitvec_t *to)
|
static inline void bv_copy(const bitvec_t *from, bitvec_t *to)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < BV_QWORD_RANK; i++)
|
for(int i = 0; i < BV_RANK; i++)
|
||||||
to->v[i] = from->v[i];
|
to->v[i] = from->v[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bv_negate(const bitvec_t *from, bitvec_t *to)
|
static inline void bv_negate(const bitvec_t *from, bitvec_t *to)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < BV_QWORD_RANK; i++)
|
for(int i = 0; i < BV_RANK; i++)
|
||||||
to->v[i] = ~from->v[i];
|
to->v[i] = ~from->v[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,11 +338,13 @@ int main(int argc, const char *argv[])
|
|||||||
info.buffer = buffer;
|
info.buffer = buffer;
|
||||||
info.level = output_level;
|
info.level = output_level;
|
||||||
|
|
||||||
|
ERROR(dq->count > 2*BV_BLOCKSIZE*BV_RANK, "We can handle at most %d cosets. Increase BV_RANK if more is needed.\n", 2*BV_BLOCKSIZE*BV_RANK);
|
||||||
|
|
||||||
long count;
|
long count;
|
||||||
if(output_level >= 2) {
|
if(output_level >= 2) {
|
||||||
fprintf(stdout, "Balanced ideals:\n", count);
|
fprintf(stdout, "Balanced ideals:\n");
|
||||||
count = enumerate_balanced_thickenings(dq, balanced_thickening_callback, &info);
|
count = enumerate_balanced_thickenings(dq, balanced_thickening_callback, &info);
|
||||||
fprintf(stdout, "\n", count);
|
fprintf(stdout, "\n");
|
||||||
} else {
|
} else {
|
||||||
long outputcount = 0;
|
long outputcount = 0;
|
||||||
count = enumerate_balanced_thickenings(dq, balanced_thickening_simple_callback, &outputcount);
|
count = enumerate_balanced_thickenings(dq, balanced_thickening_simple_callback, &outputcount);
|
||||||
|
@ -163,9 +163,8 @@ long enumerate_balanced_thickenings(doublequotient_t *dq, enumeration_callback c
|
|||||||
if(dq->cosets[i].opposite->min->id == dq->cosets[i].min->id)
|
if(dq->cosets[i].opposite->min->id == dq->cosets[i].min->id)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// we can only handle bitvectors up to 64*BV_QWORD_RANK bits, but we only store half of the weyl group
|
// we can only handle bitvectors up to BV_BLOCKSIZE*BV_RANK bits, but we only store half of the weyl group
|
||||||
if(info.size > 128*BV_QWORD_RANK)
|
ERROR(info.size > 2*BV_BLOCKSIZE*BV_RANK, "We can handle at most %d cosets. Increase BV_RANK if more is needed.\n", 2*BV_BLOCKSIZE*BV_RANK);
|
||||||
return -1;
|
|
||||||
|
|
||||||
generate_principal_ideals(dq, info.principal_pos, info.principal_neg, info.principal_is_slim);
|
generate_principal_ideals(dq, info.principal_pos, info.principal_neg, info.principal_is_slim);
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef THICKENINGS_H
|
#ifndef THICKENINGS_H
|
||||||
#define THICKENINGS_H
|
#define THICKENINGS_H
|
||||||
|
|
||||||
#define BV_QWORD_RANK 10
|
|
||||||
#include "bitvec.h"
|
#include "bitvec.h"
|
||||||
#include "weyl.h"
|
#include "weyl.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user