36 size_t r = ((n & (n-1)) == 0 ? 0 : 1);
49 assert(i >= -(1l<<(w-1)));
50 assert(i < (1l<<(w-1)));
51 return (i >= 0) ? i : i + (1l<<w);
57 return (i < (1ul<<(w-1))) ? i : i - (1ul<<w);
63 for (
size_t k = 0; k <
l; ++k)
65 r = (
r << 1) | (n & 1);
74 for (
size_t i = 0; i <
l.size(); ++i)
76 for (
size_t j = 0;
j < wordsize; ++
j)
78 res[i*wordsize +
j] = (*(
l.begin()+i) & (1ul<<(wordsize-1-
j)));
86 return (x + (y-1)) / y;
92 unsigned char *c = (
unsigned char*)(&
a);
96std::string
FORMAT(
const std::string &prefix,
const char*
format, ...)
98 const static size_t MAX_FMT = 256;
105 return prefix + std::string(
buf);
110 out << v.size() <<
"\n";
111 for (
size_t i = 0; i < v.size(); ++i)
122 for (
size_t i = 0; i < size; ++i)
void deserialize_bit_vector(std::istream &in, bit_vector &v)
size_t bitreverse(size_t n, const size_t l)
size_t get_power_of_two(size_t n)
std::vector< bool > bit_vector
size_t log2(size_t n)
returns ceil(log2(n)), so 1ul<<log2(n) is the smallest power of 2, that is not less than n
std::string FORMAT(const std::string &prefix, const char *format,...)
bit_vector int_list_to_bits(const std::initializer_list< unsigned long > &l, const size_t wordsize)
size_t to_twos_complement(int i, size_t w)
int from_twos_complement(size_t i, size_t w)
void serialize_bit_vector(std::ostream &out, const bit_vector &v)
long long div_ceil(long long x, long long y)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
unsigned __int64 uint64_t