PPL  1.2
Parma_Polyhedra_Library::Bit_Row Class Reference

A row in a matrix of bits. More...

#include <Bit_Row_defs.hh>

Public Member Functions

 Bit_Row ()
 Default constructor. More...
 
 Bit_Row (const Bit_Row &y)
 Copy constructor. More...
 
 Bit_Row (const Bit_Row &y, const Bit_Row &z)
 Set-union constructor. More...
 
 ~Bit_Row ()
 Destructor. More...
 
Bit_Rowoperator= (const Bit_Row &y)
 Assignment operator. More...
 
void m_swap (Bit_Row &y)
 Swaps *this with y. More...
 
bool operator[] (unsigned long k) const
 Returns the truth value corresponding to the bit in position k. More...
 
void set (unsigned long k)
 Sets the bit in position k. More...
 
void set_until (unsigned long k)
 Sets bits up to position k (excluded). More...
 
void clear (unsigned long k)
 Clears the bit in position k. More...
 
void clear_from (unsigned long k)
 Clears bits from position k (included) onward. More...
 
void clear ()
 Clears all the bits of the row. More...
 
void union_assign (const Bit_Row &x, const Bit_Row &y)
 Assigns to *this the set-theoretic union of x and y. More...
 
void intersection_assign (const Bit_Row &x, const Bit_Row &y)
 Assigns to *this the set-theoretic intersection of x and y. More...
 
void difference_assign (const Bit_Row &x, const Bit_Row &y)
 Assigns to *this the set-theoretic difference of x and y. More...
 
unsigned long first () const
 Returns the index of the first set bit or ULONG_MAX if no bit is set. More...
 
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. More...
 
unsigned long last () const
 Returns the index of the last set bit or ULONG_MAX if no bit is set. More...
 
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. More...
 
unsigned long count_ones () const
 Returns the number of set bits in the row. More...
 
bool empty () const
 Returns true if no bit is set in the row. More...
 
memory_size_type total_memory_in_bytes () const
 Returns the total size in bytes of the memory occupied by *this. More...
 
memory_size_type external_memory_in_bytes () const
 Returns the size in bytes of the memory managed by *this. More...
 
bool OK () const
 Checks if all the invariants are satisfied. More...
 

Private Member Functions

void union_helper (const Bit_Row &y, const Bit_Row &z)
 Assigns to *this the union of y and z. More...
 

Private Attributes

mpz_t vec
 Bit-vector representing the row. More...
 

Friends

int compare (const Bit_Row &x, const Bit_Row &y)
 
bool operator== (const Bit_Row &x, const Bit_Row &y)
 
bool operator!= (const Bit_Row &x, const Bit_Row &y)
 
bool subset_or_equal (const Bit_Row &x, const Bit_Row &y)
 
bool subset_or_equal (const Bit_Row &x, const Bit_Row &y, bool &strict_subset)
 
bool strict_subset (const Bit_Row &x, const Bit_Row &y)
 

Related Functions

(Note that these are not member functions.)

int compare (const Bit_Row &x, const Bit_Row &y)
 
bool subset_or_equal (const Bit_Row &x, const Bit_Row &y)
 
bool subset_or_equal (const Bit_Row &x, const Bit_Row &y, bool &strict_subset)
 
bool strict_subset (const Bit_Row &x, const Bit_Row &y)
 
bool operator== (const Bit_Row &x, const Bit_Row &y)
 
bool operator!= (const Bit_Row &x, const Bit_Row &y)
 
void swap (Bit_Row &x, Bit_Row &y)
 Swaps x with y. More...
 
void iter_swap (std::vector< Bit_Row >::iterator x, std::vector< Bit_Row >::iterator y)
 Swaps objects referred by x and y. More...
 
bool operator== (const Bit_Row &x, const Bit_Row &y)
 Returns true if and only if x and y are equal. More...
 
bool operator!= (const Bit_Row &x, const Bit_Row &y)
 Returns true if and only if x and y are not equal. More...
 
int compare (const Bit_Row &x, const Bit_Row &y)
 The basic comparison function. More...
 
bool subset_or_equal (const Bit_Row &x, const Bit_Row &y)
 Set-theoretic inclusion test. More...
 
bool subset_or_equal (const Bit_Row &x, const Bit_Row &y, bool &strict_subset)
 Set-theoretic inclusion test: sets strict_subset to a Boolean indicating whether the inclusion is strict or not. More...
 
bool strict_subset (const Bit_Row &x, const Bit_Row &y)
 Set-theoretic strict inclusion test. More...
 
void swap (Bit_Row &x, Bit_Row &y)
 
void iter_swap (std::vector< Bit_Row >::iterator x, std::vector< Bit_Row >::iterator y)
 

Detailed Description

A row in a matrix of bits.

Definition at line 108 of file Bit_Row_defs.hh.

Constructor & Destructor Documentation

Parma_Polyhedra_Library::Bit_Row::Bit_Row ( )
inline

Default constructor.

Definition at line 43 of file Bit_Row_inlines.hh.

References vec.

43  {
44  mpz_init(vec);
45 }
mpz_t vec
Bit-vector representing the row.
Parma_Polyhedra_Library::Bit_Row::Bit_Row ( const Bit_Row y)
inline

Copy constructor.

Definition at line 48 of file Bit_Row_inlines.hh.

References vec.

48  {
49  mpz_init_set(vec, y.vec);
50 }
mpz_t vec
Bit-vector representing the row.
Parma_Polyhedra_Library::Bit_Row::Bit_Row ( const Bit_Row y,
const Bit_Row z 
)
inline

Set-union constructor.

Constructs an object containing the set-union of y and z.

Definition at line 53 of file Bit_Row_inlines.hh.

References PPL_BITS_PER_GMP_LIMB, union_helper(), and vec.

53  {
54  const mp_size_t y_size = y.vec->_mp_size;
55  PPL_ASSERT(y_size >= 0);
56  const mp_size_t z_size = z.vec->_mp_size;
57  PPL_ASSERT(z_size >= 0);
58  if (y_size < z_size) {
59  PPL_ASSERT(static_cast<unsigned long>(z_size)
61  mpz_init2(vec, static_cast<unsigned long>(z_size) * PPL_BITS_PER_GMP_LIMB);
62  union_helper(y, z);
63  }
64  else {
65  PPL_ASSERT(static_cast<unsigned long>(y_size)
67  mpz_init2(vec, static_cast<unsigned long>(y_size) * PPL_BITS_PER_GMP_LIMB);
68  union_helper(z, y);
69  }
70 }
mpz_t vec
Bit-vector representing the row.
#define PPL_BITS_PER_GMP_LIMB
void union_helper(const Bit_Row &y, const Bit_Row &z)
Assigns to *this the union of y and z.
Definition: Bit_Row.cc:340
Parma_Polyhedra_Library::Bit_Row::~Bit_Row ( )
inline

Destructor.

Definition at line 73 of file Bit_Row_inlines.hh.

References vec.

73  {
74  mpz_clear(vec);
75 }
mpz_t vec
Bit-vector representing the row.

Member Function Documentation

void Parma_Polyhedra_Library::Bit_Row::clear ( unsigned long  k)
inline
void Parma_Polyhedra_Library::Bit_Row::clear ( )
inline

Clears all the bits of the row.

Definition at line 116 of file Bit_Row_inlines.hh.

References vec.

116  {
117  mpz_set_ui(vec, 0UL);
118 }
mpz_t vec
Bit-vector representing the row.
void Parma_Polyhedra_Library::Bit_Row::clear_from ( unsigned long  k)
inline

Clears bits from position k (included) onward.

Definition at line 94 of file Bit_Row_inlines.hh.

References vec.

94  {
95  mpz_tdiv_r_2exp(vec, vec, k);
96 }
mpz_t vec
Bit-vector representing the row.
unsigned long Parma_Polyhedra_Library::Bit_Row::count_ones ( ) const
inline

Returns the number of set bits in the row.

Definition at line 99 of file Bit_Row_inlines.hh.

References vec.

Referenced by Parma_Polyhedra_Library::Polyhedron::conversion().

99  {
100  const mp_size_t x_size = vec->_mp_size;
101  PPL_ASSERT(x_size >= 0);
102  return (x_size == 0) ? 0 : mpn_popcount(vec->_mp_d, x_size);
103 }
mpz_t vec
Bit-vector representing the row.
void Parma_Polyhedra_Library::Bit_Row::difference_assign ( const Bit_Row x,
const Bit_Row y 
)
inline

Assigns to *this the set-theoretic difference of x and y.

Definition at line 156 of file Bit_Row_inlines.hh.

References PPL_DIRTY_TEMP, and vec.

Referenced by Parma_Polyhedra_Library::Polyhedron::BHZ09_NNC_poly_hull_assign_if_exact().

156  {
157  PPL_DIRTY_TEMP(mpz_class, complement_y);
158  mpz_com(complement_y.get_mpz_t(), y.vec);
159  mpz_and(vec, x.vec, complement_y.get_mpz_t());
160 }
mpz_t vec
Bit-vector representing the row.
#define PPL_DIRTY_TEMP(T, id)
bool Parma_Polyhedra_Library::Bit_Row::empty ( ) const
inline

Returns true if no bit is set in the row.

Definition at line 106 of file Bit_Row_inlines.hh.

References vec.

Referenced by Parma_Polyhedra_Library::Polyhedron::BHZ09_NNC_poly_hull_assign_if_exact(), and Parma_Polyhedra_Library::Polyhedron::simplify_using_context_assign().

106  {
107  return mpz_sgn(vec) == 0;
108 }
mpz_t vec
Bit-vector representing the row.
memory_size_type Parma_Polyhedra_Library::Bit_Row::external_memory_in_bytes ( ) const
inline

Returns the size in bytes of the memory managed by *this.

Definition at line 121 of file Bit_Row_inlines.hh.

References vec.

Referenced by total_memory_in_bytes().

121  {
122  return static_cast<memory_size_type>(vec[0]._mp_alloc) * PPL_SIZEOF_MP_LIMB_T;
123 }
mpz_t vec
Bit-vector representing the row.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
unsigned long Parma_Polyhedra_Library::Bit_Row::first ( ) const

Returns the index of the first set bit or ULONG_MAX if no bit is set.

Definition at line 32 of file Bit_Row.cc.

References Parma_Polyhedra_Library::Implementation::first_one(), PPL_BITS_PER_GMP_LIMB, and vec.

Referenced by Parma_Polyhedra_Library::Polyhedron::BHZ09_NNC_poly_hull_assign_if_exact().

32  {
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;
38  if (limb != 0) {
39  return static_cast<unsigned long>(li) * PPL_BITS_PER_GMP_LIMB
41  }
42  }
44 }
mpz_t vec
Bit-vector representing the row.
#define PPL_BITS_PER_GMP_LIMB
unsigned int first_one(unsigned int u)
Assuming u is nonzero, returns the index of the first set bit in u.
void Parma_Polyhedra_Library::Bit_Row::intersection_assign ( const Bit_Row x,
const Bit_Row y 
)
inline

Assigns to *this the set-theoretic intersection of x and y.

Definition at line 151 of file Bit_Row_inlines.hh.

References vec.

Referenced by Parma_Polyhedra_Library::Polyhedron::BHZ09_NNC_poly_hull_assign_if_exact().

151  {
152  mpz_and(vec, x.vec, y.vec);
153 }
mpz_t vec
Bit-vector representing the row.
unsigned long Parma_Polyhedra_Library::Bit_Row::last ( ) const

Returns the index of the last set bit or ULONG_MAX if no bit is set.

Definition at line 92 of file Bit_Row.cc.

References Parma_Polyhedra_Library::Implementation::last_one(), and PPL_BITS_PER_GMP_LIMB.

Referenced by Parma_Polyhedra_Library::Bit_Matrix::OK().

92  {
93  mp_size_t li = vec->_mp_size;
94  PPL_ASSERT(li >= 0);
95  if (li == 0) {
97  }
98  --li;
99  const mp_srcptr p = vec->_mp_d + li;
100  const mp_limb_t limb = *p;
101  PPL_ASSERT(limb != 0);
102  return static_cast<unsigned long>(li) * PPL_BITS_PER_GMP_LIMB
103  + Implementation::last_one(limb);
104 }
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.
#define PPL_BITS_PER_GMP_LIMB
void Parma_Polyhedra_Library::Bit_Row::m_swap ( Bit_Row y)
inline

Swaps *this with y.

Definition at line 111 of file Bit_Row_inlines.hh.

References vec.

Referenced by swap().

111  {
112  mpz_swap(vec, y.vec);
113 }
mpz_t vec
Bit-vector representing the row.
unsigned long Parma_Polyhedra_Library::Bit_Row::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.

Definition at line 47 of file Bit_Row.cc.

References Parma_Polyhedra_Library::Implementation::first_one(), and PPL_BITS_PER_GMP_LIMB.

Referenced by Parma_Polyhedra_Library::Polyhedron::BHZ09_NNC_poly_hull_assign_if_exact().

47  {
48  ++position;
49 
50  /*
51  The alternative implementation using the mpz_scan1() function
52  of GMP was measured to be slower that ours. Here it is, in
53  case mpz_scan1() is improved:
54 
55  <CODE>
56  unsigned long r = mpz_scan1(vec, position);
57  return (r == C_Integer<unsigned long>::max) ? -1 : r;
58  </CODE>
59  */
60 
61  const unsigned long uli = position / PPL_BITS_PER_GMP_LIMB;
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);
65  if (li >= vec_size) {
67  }
68 
69  // Get the first limb.
70  mp_srcptr p = vec->_mp_d + li;
71 
72  // Mask off any bits before `position' in the first limb.
73  mp_limb_t limb
74  = *p & ((~static_cast<mp_limb_t>(0)) << (position % PPL_BITS_PER_GMP_LIMB));
75 
76  while (true) {
77  if (limb != 0) {
78  return static_cast<unsigned long>(li) * PPL_BITS_PER_GMP_LIMB
80  }
81  ++li;
82  if (li == vec_size) {
83  break;
84  }
85  ++p;
86  limb = *p;
87  }
89 }
mpz_t vec
Bit-vector representing the row.
#define PPL_BITS_PER_GMP_LIMB
unsigned int first_one(unsigned int u)
Assuming u is nonzero, returns the index of the first set bit in u.
bool Parma_Polyhedra_Library::Bit_Row::OK ( ) const

Checks if all the invariants are satisfied.

Definition at line 331 of file Bit_Row.cc.

Referenced by Parma_Polyhedra_Library::Bit_Matrix::OK().

331  {
332  const mp_size_t vec_size = vec->_mp_size;
333  const mp_size_t vec_alloc = vec->_mp_alloc;
334  return vec_size >= 0
335  && vec_alloc >= vec_size
336  && (vec_size == 0 || mpz_getlimbn(vec, vec_size-1) != 0);
337 }
mpz_t vec
Bit-vector representing the row.
Bit_Row & Parma_Polyhedra_Library::Bit_Row::operator= ( const Bit_Row y)
inline

Assignment operator.

Definition at line 78 of file Bit_Row_inlines.hh.

References vec.

78  {
79  mpz_set(vec, y.vec);
80  return *this;
81 }
mpz_t vec
Bit-vector representing the row.
bool Parma_Polyhedra_Library::Bit_Row::operator[] ( unsigned long  k) const

Returns the truth value corresponding to the bit in position k.

Definition at line 152 of file Bit_Row.cc.

152  {
153  const mp_size_t vec_size = vec->_mp_size;
154  PPL_ASSERT(vec_size >= 0);
155 
156  const unsigned long i = k / static_cast<unsigned long>(GMP_NUMB_BITS);
157  if (i >= static_cast<unsigned long>(vec_size)) {
158  return false;
159  }
160 
161  const mp_limb_t limb = *(vec->_mp_d + i);
162  return ((limb >> (k % static_cast<unsigned long>(GMP_NUMB_BITS))) & 1U) != 0;
163 }
mpz_t vec
Bit-vector representing the row.
unsigned long Parma_Polyhedra_Library::Bit_Row::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.

Definition at line 107 of file Bit_Row.cc.

References Parma_Polyhedra_Library::Implementation::last_one(), and PPL_BITS_PER_GMP_LIMB.

107  {
108  if (position == 0) {
110  }
111 
112  --position;
113 
114  const mp_size_t vec_size = vec->_mp_size;
115  PPL_ASSERT(vec_size > 0);
116  const unsigned long uli = position / PPL_BITS_PER_GMP_LIMB;
117  mp_size_t li = static_cast<mp_size_t>(uli);
118 
119  mp_limb_t limb;
120  mp_srcptr p = vec->_mp_d;
121 
122  // Get the first limb.
123  if (li >= vec_size) {
124  li = vec_size - 1;
125  p += li;
126  limb = *p;
127  }
128  else {
129  const mp_limb_t mask
130  = (~static_cast<mp_limb_t>(0))
131  >> (PPL_BITS_PER_GMP_LIMB - 1U - position % PPL_BITS_PER_GMP_LIMB);
132  p += li;
133  limb = *p & mask;
134  }
135 
136  while (true) {
137  if (limb != 0) {
138  return static_cast<unsigned long>(li) * PPL_BITS_PER_GMP_LIMB
139  + Implementation::last_one(limb);
140  }
141  if (li == 0) {
142  break;
143  }
144  --li;
145  --p;
146  limb = *p;
147  }
149 }
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.
#define PPL_BITS_PER_GMP_LIMB
void Parma_Polyhedra_Library::Bit_Row::set_until ( unsigned long  k)

Sets bits up to position k (excluded).

Definition at line 166 of file Bit_Row.cc.

Referenced by Parma_Polyhedra_Library::Polyhedron::BHZ09_C_poly_hull_assign_if_exact(), and Parma_Polyhedra_Library::Polyhedron::BHZ09_NNC_poly_hull_assign_if_exact().

166  {
167  // FIXME, TODO: this is an inefficient implementation.
168  while (k-- > 0) {
169  mpz_setbit(vec, k);
170  }
171 }
mpz_t vec
Bit-vector representing the row.
memory_size_type Parma_Polyhedra_Library::Bit_Row::total_memory_in_bytes ( ) const
inline

Returns the total size in bytes of the memory occupied by *this.

Definition at line 126 of file Bit_Row_inlines.hh.

References external_memory_in_bytes().

126  {
127  return sizeof(*this) + external_memory_in_bytes();
128 }
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
void Parma_Polyhedra_Library::Bit_Row::union_assign ( const Bit_Row x,
const Bit_Row y 
)
inline

Assigns to *this the set-theoretic union of x and y.

Definition at line 131 of file Bit_Row_inlines.hh.

References PPL_BITS_PER_GMP_LIMB, union_helper(), and vec.

Referenced by Parma_Polyhedra_Library::Polyhedron::BHZ09_C_poly_hull_assign_if_exact(), Parma_Polyhedra_Library::Polyhedron::BHZ09_NNC_poly_hull_assign_if_exact(), and Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints().

131  {
132  const mp_size_t x_size = x.vec->_mp_size;
133  PPL_ASSERT(x_size >= 0);
134  const mp_size_t y_size = y.vec->_mp_size;
135  PPL_ASSERT(y_size >= 0);
136  if (x_size < y_size) {
137  PPL_ASSERT(static_cast<unsigned long>(y_size)
139  mpz_realloc2(vec, static_cast<unsigned long>(y_size) * PPL_BITS_PER_GMP_LIMB);
140  union_helper(x, y);
141  }
142  else {
143  PPL_ASSERT(static_cast<unsigned long>(x_size)
145  mpz_realloc2(vec, static_cast<unsigned long>(x_size) * PPL_BITS_PER_GMP_LIMB);
146  union_helper(y, x);
147  }
148 }
mpz_t vec
Bit-vector representing the row.
#define PPL_BITS_PER_GMP_LIMB
void union_helper(const Bit_Row &y, const Bit_Row &z)
Assigns to *this the union of y and z.
Definition: Bit_Row.cc:340
void Parma_Polyhedra_Library::Bit_Row::union_helper ( const Bit_Row y,
const Bit_Row z 
)
private

Assigns to *this the union of y and z.

The size of y must be be less than or equal to the size of z. Upon entry, vec must have allocated enough space to contain the result.

Definition at line 340 of file Bit_Row.cc.

References vec.

Referenced by Bit_Row(), and union_assign().

340  {
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;
349  z_size -= y_size;
350  while (y_size > 0) {
351  *p = *yp | * zp;
352  ++yp;
353  ++zp;
354  ++p;
355  --y_size;
356  }
357  while (z_size > 0) {
358  *p = *zp;
359  ++zp;
360  ++p;
361  --z_size;
362  }
363 }
mpz_t vec
Bit-vector representing the row.

Friends And Related Function Documentation

int compare ( const Bit_Row x,
const Bit_Row y 
)
related

The basic comparison function.

Compares x with y starting from the least significant bits. The ordering is total and has the following property: if x and y are two rows seen as sets of naturals, if x is a strict subset of y, then x comes before y.

Returns

  • -1 if x comes before y in the ordering;
  • 0 if x and y are equal;
  • 1 if x comes after y in the ordering.
int compare ( const Bit_Row x,
const Bit_Row y 
)
friend
int compare ( const Bit_Row x,
const Bit_Row y 
)
related

Definition at line 175 of file Bit_Row.cc.

References vec.

175  {
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;
183  while (size > 0) {
184  const mp_limb_t xl = *xp;
185  const mp_limb_t yl = *yp;
186  if (xl != yl) {
187  // Get the ones where they are different.
188  const mp_limb_t diff = xl ^ yl;
189  // First bit that is different.
190  const mp_limb_t mask = diff & ~(diff-1);
191  return ((xl & mask) != 0) ? 1 : -1;
192  }
193  ++xp;
194  ++yp;
195  --size;
196  }
197  return (x_size == y_size) ? 0 : ((x_size > y_size) ? 1 : -1);
198 }
void iter_swap ( std::vector< Bit_Row >::iterator  x,
std::vector< Bit_Row >::iterator  y 
)
related

Swaps objects referred by x and y.

void iter_swap ( std::vector< Bit_Row >::iterator  x,
std::vector< Bit_Row >::iterator  y 
)
related

Definition at line 229 of file Bit_Row_inlines.hh.

References Parma_Polyhedra_Library::swap().

230  {
231  swap(*x, *y);
232 }
void swap(Bit_Row &x, Bit_Row &y)
Swaps x with y.
bool operator!= ( const Bit_Row x,
const Bit_Row y 
)
related

Returns true if and only if x and y are not equal.

bool operator!= ( const Bit_Row x,
const Bit_Row y 
)
friend
bool operator!= ( const Bit_Row x,
const Bit_Row y 
)
related

Definition at line 317 of file Bit_Row.cc.

References vec.

317  {
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);
322 
323  if (x_vec_size != y_vec_size) {
324  return true;
325  }
326 
327  return mpn_cmp(x.vec->_mp_d, y.vec->_mp_d, x_vec_size) != 0;
328 }
bool operator== ( const Bit_Row x,
const Bit_Row y 
)
related

Returns true if and only if x and y are equal.

bool operator== ( const Bit_Row x,
const Bit_Row y 
)
friend
bool operator== ( const Bit_Row x,
const Bit_Row y 
)
related

Definition at line 302 of file Bit_Row.cc.

References vec.

302  {
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);
307 
308  if (x_vec_size != y_vec_size) {
309  return false;
310  }
311 
312  return mpn_cmp(x.vec->_mp_d, y.vec->_mp_d, x_vec_size) == 0;
313 }
bool strict_subset ( const Bit_Row x,
const Bit_Row y 
)
related

Set-theoretic strict inclusion test.

bool strict_subset ( const Bit_Row x,
const Bit_Row y 
)
friend
bool strict_subset ( const Bit_Row x,
const Bit_Row y 
)
related

Definition at line 273 of file Bit_Row.cc.

References vec.

273  {
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) {
279  return false;
280  }
281  bool different = (x_size < y_size);
282  mp_srcptr xp = x.vec->_mp_d;
283  mp_srcptr yp = y.vec->_mp_d;
284  while (x_size > 0) {
285  const mp_limb_t xl = *xp;
286  const mp_limb_t yl = *yp;
287  if ((xl & ~yl) != 0) {
288  return false;
289  }
290  if (!different && xl != yl) {
291  different = true;
292  }
293  ++xp;
294  ++yp;
295  --x_size;
296  }
297  return different;
298 }
bool subset_or_equal ( const Bit_Row x,
const Bit_Row y 
)
related

Set-theoretic inclusion test.

bool subset_or_equal ( const Bit_Row x,
const Bit_Row y,
bool &  strict_subset 
)
related

Set-theoretic inclusion test: sets strict_subset to a Boolean indicating whether the inclusion is strict or not.

bool subset_or_equal ( const Bit_Row x,
const Bit_Row y 
)
friend
bool subset_or_equal ( const Bit_Row x,
const Bit_Row y,
bool &  strict_subset 
)
friend
bool subset_or_equal ( const Bit_Row x,
const Bit_Row y 
)
related

Definition at line 202 of file Bit_Row.cc.

References vec.

202  {
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) {
208  return false;
209  }
210  mp_srcptr xp = x.vec->_mp_d;
211  mp_srcptr yp = y.vec->_mp_d;
212  while (x_size > 0) {
213  if ((*xp & ~*yp) != 0) {
214  return false;
215  }
216  ++xp;
217  ++yp;
218  --x_size;
219  }
220  return true;
221 }
bool subset_or_equal ( const Bit_Row x,
const Bit_Row y,
bool &  strict_subset 
)
related

Definition at line 225 of file Bit_Row.cc.

References vec.

226  {
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) {
232  return false;
233  }
234  mp_srcptr xp = x.vec->_mp_d;
235  mp_srcptr yp = y.vec->_mp_d;
236  strict_subset = (x_size < y_size);
237  mp_limb_t xl;
238  mp_limb_t yl;
239  if (strict_subset) {
240  while (x_size > 0) {
241  xl = *xp;
242  yl = *yp;
243  if ((xl & ~yl) != 0) {
244  return false;
245  }
246  strict_subset_next:
247  ++xp;
248  ++yp;
249  --x_size;
250  }
251  }
252  else {
253  while (x_size > 0) {
254  xl = *xp;
255  yl = *yp;
256  if (xl != yl) {
257  if ((xl & ~yl) != 0) {
258  return false;
259  }
260  strict_subset = true;
261  goto strict_subset_next;
262  }
263  ++xp;
264  ++yp;
265  --x_size;
266  }
267  }
268  return true;
269 }
friend bool strict_subset(const Bit_Row &x, const Bit_Row &y)
void swap ( Bit_Row x,
Bit_Row y 
)
related

Swaps x with y.

void swap ( Bit_Row x,
Bit_Row y 
)
related

Definition at line 223 of file Bit_Row_inlines.hh.

References m_swap().

223  {
224  x.m_swap(y);
225 }

Member Data Documentation


The documentation for this class was generated from the following files: