24 #include "ppl-config.h"
26 #include "assertions.hh"
33 const mp_size_t vec_size =
vec->_mp_size;
34 PPL_ASSERT(vec_size >= 0);
35 mp_srcptr p =
vec->_mp_d;
36 for (mp_size_t li = 0; li < vec_size; ++li, ++p) {
37 const mp_limb_t limb = *p;
62 mp_size_t li =
static_cast<mp_size_t
>(uli);
63 const mp_size_t vec_size = vec->_mp_size;
64 PPL_ASSERT(vec_size >= 0);
70 mp_srcptr p = vec->_mp_d + li;
93 mp_size_t li = vec->_mp_size;
99 const mp_srcptr p = vec->_mp_d + li;
100 const mp_limb_t limb = *p;
101 PPL_ASSERT(limb != 0);
114 const mp_size_t vec_size = vec->_mp_size;
115 PPL_ASSERT(vec_size > 0);
117 mp_size_t li =
static_cast<mp_size_t
>(uli);
120 mp_srcptr p = vec->_mp_d;
123 if (li >= vec_size) {
130 = (~static_cast<mp_limb_t>(0))
153 const mp_size_t vec_size = vec->_mp_size;
154 PPL_ASSERT(vec_size >= 0);
156 const unsigned long i = k /
static_cast<unsigned long>(GMP_NUMB_BITS);
157 if (i >= static_cast<unsigned long>(vec_size)) {
161 const mp_limb_t limb = *(vec->_mp_d + i);
162 return ((limb >> (k % static_cast<unsigned long>(GMP_NUMB_BITS))) & 1U) != 0;
176 const mp_size_t x_size = x.
vec->_mp_size;
177 PPL_ASSERT(x_size >= 0);
178 const mp_size_t y_size = y.
vec->_mp_size;
179 PPL_ASSERT(y_size >= 0);
180 mp_size_t size = ((x_size > y_size) ? y_size : x_size);
181 mp_srcptr xp = x.
vec->_mp_d;
182 mp_srcptr yp = y.
vec->_mp_d;
184 const mp_limb_t xl = *xp;
185 const mp_limb_t yl = *yp;
188 const mp_limb_t diff = xl ^ yl;
190 const mp_limb_t mask = diff & ~(diff-1);
191 return ((xl & mask) != 0) ? 1 : -1;
197 return (x_size == y_size) ? 0 : ((x_size > y_size) ? 1 : -1);
203 mp_size_t x_size = x.
vec->_mp_size;
204 PPL_ASSERT(x_size >= 0);
205 const mp_size_t y_size = y.
vec->_mp_size;
206 PPL_ASSERT(y_size >= 0);
207 if (x_size > y_size) {
210 mp_srcptr xp = x.
vec->_mp_d;
211 mp_srcptr yp = y.
vec->_mp_d;
213 if ((*xp & ~*yp) != 0) {
226 bool& strict_subset) {
227 mp_size_t x_size = x.
vec->_mp_size;
228 PPL_ASSERT(x_size >= 0);
229 const mp_size_t y_size = y.
vec->_mp_size;
230 PPL_ASSERT(y_size >= 0);
231 if (x_size > y_size) {
234 mp_srcptr xp = x.
vec->_mp_d;
235 mp_srcptr yp = y.
vec->_mp_d;
236 strict_subset = (x_size < y_size);
243 if ((xl & ~yl) != 0) {
257 if ((xl & ~yl) != 0) {
260 strict_subset =
true;
261 goto strict_subset_next;
274 mp_size_t x_size = x.
vec->_mp_size;
275 PPL_ASSERT(x_size >= 0);
276 const mp_size_t y_size = y.
vec->_mp_size;
277 PPL_ASSERT(y_size >= 0);
278 if (x_size > y_size) {
281 bool different = (x_size < y_size);
282 mp_srcptr xp = x.
vec->_mp_d;
283 mp_srcptr yp = y.
vec->_mp_d;
285 const mp_limb_t xl = *xp;
286 const mp_limb_t yl = *yp;
287 if ((xl & ~yl) != 0) {
290 if (!different && xl != yl) {
303 const mp_size_t x_vec_size = x.
vec->_mp_size;
304 PPL_ASSERT(x_vec_size >= 0);
305 const mp_size_t y_vec_size = y.
vec->_mp_size;
306 PPL_ASSERT(y_vec_size >= 0);
308 if (x_vec_size != y_vec_size) {
312 return mpn_cmp(x.
vec->_mp_d, y.
vec->_mp_d, x_vec_size) == 0;
318 const mp_size_t x_vec_size = x.
vec->_mp_size;
319 PPL_ASSERT(x_vec_size >= 0);
320 const mp_size_t y_vec_size = y.
vec->_mp_size;
321 PPL_ASSERT(y_vec_size >= 0);
323 if (x_vec_size != y_vec_size) {
327 return mpn_cmp(x.
vec->_mp_d, y.
vec->_mp_d, x_vec_size) != 0;
332 const mp_size_t vec_size = vec->_mp_size;
333 const mp_size_t vec_alloc = vec->_mp_alloc;
335 && vec_alloc >= vec_size
336 && (vec_size == 0 || mpz_getlimbn(vec, vec_size-1) != 0);
341 mp_size_t y_size = y.
vec->_mp_size;
342 mp_size_t z_size = z.
vec->_mp_size;
343 PPL_ASSERT(y_size <= z_size);
344 PPL_ASSERT(vec->_mp_alloc >= z_size);
345 vec->_mp_size = z.
vec->_mp_size;
346 mp_srcptr yp = y.
vec->_mp_d;
347 mp_srcptr zp = z.
vec->_mp_d;
348 mp_ptr p = vec->_mp_d;
void set_until(unsigned long k)
Sets bits up to position k (excluded).
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
bool OK() const
Checks if all the invariants are satisfied.
unsigned long last() const
Returns the index of the last set bit or ULONG_MAX if no bit is set.
unsigned long prev(unsigned long position) const
Returns the index of the first set bit before position or ULONG_MAX if no bits before position is set...
A row in a matrix of bits.
mpz_t vec
Bit-vector representing the row.
unsigned int last_one(unsigned int u)
Assuming u is nonzero, returns the index of the last set bit in u.
unsigned long first() const
Returns the index of the first set bit or ULONG_MAX if no bit is set.
int compare(const Linear_Expression &x, const Linear_Expression &y)
bool operator[](unsigned long k) const
Returns the truth value corresponding to the bit in position k.
The entire library is confined to this namespace.
#define PPL_BITS_PER_GMP_LIMB
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
unsigned long next(unsigned long position) const
Returns the index of the first set bit after position or ULONG_MAX if no bit after position is set...
unsigned int first_one(unsigned int u)
Assuming u is nonzero, returns the index of the first set bit in u.
void union_helper(const Bit_Row &y, const Bit_Row &z)
Assigns to *this the union of y and z.