Fixes
This commit is contained in:
		
							
								
								
									
										30
									
								
								bitvec.h
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								bitvec.h
									
									
									
									
									
								
							@@ -23,7 +23,9 @@
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
// 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 BIT(n) (((uint64_t)1 << (n)))
 | 
			
		||||
#define ALLBITS ((uint64_t)-1)
 | 
			
		||||
@@ -31,7 +33,7 @@
 | 
			
		||||
#define INDEX(n) ((n)%64)
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  uint64_t v[BV_QWORD_RANK];
 | 
			
		||||
  uint64_t v[BV_RANK];
 | 
			
		||||
} bitvec_t;
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
{
 | 
			
		||||
  int i;
 | 
			
		||||
  for (i=0;i<BV_QWORD_RANK;i++)
 | 
			
		||||
  for (i=0;i<BV_RANK;i++)
 | 
			
		||||
    x->v[i] = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline int bv_is_zero(const bitvec_t *x)
 | 
			
		||||
{
 | 
			
		||||
  int i;
 | 
			
		||||
  for (i=0;i<BV_QWORD_RANK;i++)
 | 
			
		||||
  for (i=0;i<BV_RANK;i++)
 | 
			
		||||
    if (x->v[i])
 | 
			
		||||
      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)
 | 
			
		||||
{
 | 
			
		||||
  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];
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -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)
 | 
			
		||||
{
 | 
			
		||||
  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];
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -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)
 | 
			
		||||
{
 | 
			
		||||
  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];
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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])
 | 
			
		||||
      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))));
 | 
			
		||||
 | 
			
		||||
  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]);
 | 
			
		||||
    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)
 | 
			
		||||
{
 | 
			
		||||
  for(int i = 0; i < BV_QWORD_RANK; i++)
 | 
			
		||||
  for(int i = 0; i < BV_RANK; i++)
 | 
			
		||||
    to->v[i] = from->v[i];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -338,11 +338,13 @@ int main(int argc, const char *argv[])
 | 
			
		||||
    info.buffer = buffer;
 | 
			
		||||
    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;
 | 
			
		||||
    if(output_level >= 2) {
 | 
			
		||||
      fprintf(stdout, "Balanced ideals:\n", count);
 | 
			
		||||
      fprintf(stdout, "Balanced ideals:\n");
 | 
			
		||||
      count = enumerate_balanced_thickenings(dq, balanced_thickening_callback, &info);
 | 
			
		||||
      fprintf(stdout, "\n", count);
 | 
			
		||||
      fprintf(stdout, "\n");
 | 
			
		||||
    } else {
 | 
			
		||||
      long outputcount = 0;
 | 
			
		||||
      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)
 | 
			
		||||
      return 0;
 | 
			
		||||
 | 
			
		||||
  // we can only handle bitvectors up to 64*BV_QWORD_RANK bits, but we only store half of the weyl group
 | 
			
		||||
  if(info.size > 128*BV_QWORD_RANK)
 | 
			
		||||
    return -1;
 | 
			
		||||
  // we can only handle bitvectors up to BV_BLOCKSIZE*BV_RANK bits, but we only store half of the weyl group
 | 
			
		||||
  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);
 | 
			
		||||
 | 
			
		||||
  generate_principal_ideals(dq, info.principal_pos, info.principal_neg, info.principal_is_slim);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
#ifndef THICKENINGS_H
 | 
			
		||||
#define THICKENINGS_H
 | 
			
		||||
 | 
			
		||||
#define BV_QWORD_RANK 10
 | 
			
		||||
#include "bitvec.h"
 | 
			
		||||
#include "weyl.h"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user