PPL  1.2
Parma_Polyhedra_Library::Implementation Namespace Reference

Implementation related data and functions. More...

Namespaces

 BD_Shapes
 
 Boxes
 
 Octagonal_Shapes
 
 Pointset_Powersets
 
 Termination
 
 Watchdog
 

Classes

class  Doubly_Linked_Object
 A (base) class for doubly linked objects. More...
 
class  EList
 A simple kind of embedded list (i.e., a doubly linked objects where the links are embedded in the objects themselves). More...
 
class  EList_Iterator
 A class providing iterators for embedded lists. More...
 
struct  Indirect_Sort_Compare
 
struct  Indirect_Swapper
 
struct  Indirect_Swapper2
 
struct  Indirect_Unique_Compare
 
class  Ptr_Iterator
 A class to define STL const and non-const iterators from pointer types. More...
 
struct  Wrap_Dim_Translations
 

Typedefs

typedef std::vector< Wrap_Dim_TranslationsWrap_Translations
 

Functions

unsigned int first_one (unsigned int u)
 Assuming u is nonzero, returns the index of the first set bit in u. More...
 
unsigned int first_one (unsigned long ul)
 Assuming ul is nonzero, returns the index of the first set bit in ul. More...
 
unsigned int first_one (unsigned long long ull)
 Assuming ull is nonzero, returns the index of the first set bit in ull. More...
 
unsigned int last_one (unsigned int u)
 Assuming u is nonzero, returns the index of the last set bit in u. More...
 
unsigned int last_one (unsigned long ul)
 Assuming ul is nonzero, returns the index of the last set bit in ul. More...
 
unsigned int last_one (unsigned long long ull)
 Assuming ull is nonzero, returns the index of the last set bit in ull. More...
 
dimension_type num_constraints (const Constraint_System &cs)
 Helper returning number of constraints in system. More...
 
template<typename T >
bool operator== (const EList_Iterator< T > &x, const EList_Iterator< T > &y)
 Returns true if and only if x and y are equal. More...
 
template<typename T >
bool operator!= (const EList_Iterator< T > &x, const EList_Iterator< T > &y)
 Returns true if and only if x and y are different. More...
 
void initialize_aux ()
 
void finalize_aux ()
 
template<typename P , typename Q >
bool operator== (const Ptr_Iterator< P > &x, const Ptr_Iterator< Q > &y)
 
template<typename P , typename Q >
bool operator!= (const Ptr_Iterator< P > &x, const Ptr_Iterator< Q > &y)
 
template<typename P , typename Q >
bool operator< (const Ptr_Iterator< P > &x, const Ptr_Iterator< Q > &y)
 
template<typename P , typename Q >
bool operator<= (const Ptr_Iterator< P > &x, const Ptr_Iterator< Q > &y)
 
template<typename P , typename Q >
bool operator> (const Ptr_Iterator< P > &x, const Ptr_Iterator< Q > &y)
 
template<typename P , typename Q >
bool operator>= (const Ptr_Iterator< P > &x, const Ptr_Iterator< Q > &y)
 
template<typename P , typename Q >
Ptr_Iterator< P >::difference_type operator- (const Ptr_Iterator< P > &x, const Ptr_Iterator< Q > &y)
 
template<typename P >
Ptr_Iterator< P > operator+ (typename Ptr_Iterator< P >::difference_type m, const Ptr_Iterator< P > &y)
 
template<typename Sort_Comparer , typename Unique_Comparer , typename Swapper >
Sort_Comparer::size_type indirect_sort_and_unique (typename Sort_Comparer::size_type num_elems, Sort_Comparer sort_cmp, Unique_Comparer unique_cmp, Swapper indirect_swap)
 
template<typename Iter >
Iter swapping_unique (Iter first, Iter last)
 
template<typename PSET >
void wrap_assign_ind (PSET &pointset, Variables_Set &vars, Wrap_Translations::const_iterator first, Wrap_Translations::const_iterator end, Bounded_Integer_Type_Width w, Coefficient_traits::const_reference min_value, Coefficient_traits::const_reference max_value, const Constraint_System &cs, Coefficient &tmp1, Coefficient &tmp2)
 
template<typename PSET >
void wrap_assign_col (PSET &dest, const PSET &src, const Variables_Set &vars, Wrap_Translations::const_iterator first, Wrap_Translations::const_iterator end, Bounded_Integer_Type_Width w, Coefficient_traits::const_reference min_value, Coefficient_traits::const_reference max_value, const Constraint_System *cs_p, Coefficient &tmp)
 
template<typename PSET >
void wrap_assign (PSET &pointset, const Variables_Set &vars, const Bounded_Integer_Type_Width w, const Bounded_Integer_Type_Representation r, const Bounded_Integer_Type_Overflow o, const Constraint_System *cs_p, const unsigned complexity_threshold, const bool wrap_individually, const char *class_name)
 

Detailed Description

Implementation related data and functions.

Typedef Documentation

Function Documentation

void Parma_Polyhedra_Library::Implementation::finalize_aux ( )

Definition at line 236 of file Init.cc.

Referenced by Parma_Polyhedra_Library::finalize().

236  {
237  PPL_ASSERT(Parma_Polyhedra_Library_initializer_p != 0);
238  delete Parma_Polyhedra_Library_initializer_p;
239  Parma_Polyhedra_Library_initializer_p = 0;
240 }
unsigned int Parma_Polyhedra_Library::Implementation::first_one ( unsigned int  u)
inline

Assuming u is nonzero, returns the index of the first set bit in u.

Definition at line 168 of file Bit_Row_inlines.hh.

References Parma_Polyhedra_Library::ctz().

Referenced by Parma_Polyhedra_Library::Bit_Row::first(), and Parma_Polyhedra_Library::Bit_Row::next().

168  {
169  return ctz(u);
170 }
unsigned int ctz(unsigned int u)
Definition: compiler.hh:186
unsigned int Parma_Polyhedra_Library::Implementation::first_one ( unsigned long  ul)
inline

Assuming ul is nonzero, returns the index of the first set bit in ul.

Definition at line 177 of file Bit_Row_inlines.hh.

References Parma_Polyhedra_Library::ctz().

177  {
178  return ctz(ul);
179 }
unsigned int ctz(unsigned int u)
Definition: compiler.hh:186
unsigned int Parma_Polyhedra_Library::Implementation::first_one ( unsigned long long  ull)
inline

Assuming ull is nonzero, returns the index of the first set bit in ull.

Definition at line 186 of file Bit_Row_inlines.hh.

References Parma_Polyhedra_Library::ctz().

186  {
187  return ctz(ull);
188 }
unsigned int ctz(unsigned int u)
Definition: compiler.hh:186
template<typename Sort_Comparer , typename Unique_Comparer , typename Swapper >
Sort_Comparer::size_type Parma_Polyhedra_Library::Implementation::indirect_sort_and_unique ( typename Sort_Comparer::size_type  num_elems,
Sort_Comparer  sort_cmp,
Unique_Comparer  unique_cmp,
Swapper  indirect_swap 
)

Definition at line 106 of file swapping_sort_templates.hh.

Referenced by Parma_Polyhedra_Library::Linear_System< Row >::sort_and_remove_with_sat(), Parma_Polyhedra_Library::Bit_Matrix::sort_rows(), and Parma_Polyhedra_Library::Linear_System< Row >::sort_rows().

109  {
110  typedef typename Sort_Comparer::size_type index_type;
111  // `iv' is a vector of indices for the portion of rows to be sorted.
112  PPL_ASSERT(num_elems >= 2);
113  std::vector<index_type> iv;
114  iv.reserve(num_elems);
115  for (index_type i = 0, i_end = num_elems; i != i_end; ++i) {
116  iv.push_back(i);
117  }
118 
119  typedef typename std::vector<index_type>::iterator Iter;
120  const Iter iv_begin = iv.begin();
121  Iter iv_end = iv.end();
122 
123  // Sort `iv' by comparing the rows indexed by its elements.
124  std::sort(iv_begin, iv_end, sort_cmp);
125 
126  // Swap the indexed rows according to `iv':
127  // for each index `i', the element that should be placed in
128  // position dst = i is the one placed in position src = iv[i].
129  for (index_type i = num_elems; i-- > 0; ) {
130  if (i != iv[i]) {
131  index_type dst = i;
132  index_type src = iv[i];
133  do {
134  indirect_swap(src, dst);
135  iv[dst] = dst;
136  dst = src;
137  src = iv[dst];
138  } while (i != src);
139  iv[dst] = dst;
140  }
141  }
142 
143  // Restore `iv' indices to 0 .. num_elems-1 for the call to unique.
144  for (index_type i = num_elems; i-- > 0; ) {
145  iv[i] = i;
146  }
147 
148  // Unique `iv' by comparing the rows indexed by its elements.
149  iv_end = std::unique(iv_begin, iv_end, unique_cmp);
150 
151  const index_type num_sorted = static_cast<index_type>(iv_end - iv_begin);
152  const index_type num_duplicates = num_elems - num_sorted;
153  if (num_duplicates == 0) {
154  return 0;
155  }
156 
157  // There were duplicates: swap the rows according to `iv'.
158  index_type dst = 0;
159  while (dst < num_sorted && dst == iv[dst]) {
160  ++dst;
161  }
162  if (dst == num_sorted) {
163  return num_duplicates;
164  }
165  do {
166  const index_type src = iv[dst];
167  indirect_swap(src, dst);
168  ++dst;
169  }
170  while (dst < num_sorted);
171  return num_duplicates;
172 }
void Parma_Polyhedra_Library::Implementation::initialize_aux ( )

Definition at line 229 of file Init.cc.

Referenced by Parma_Polyhedra_Library::initialize().

229  {
230  if (Parma_Polyhedra_Library_initializer_p == 0) {
231  Parma_Polyhedra_Library_initializer_p = new Init();
232  }
233 }
unsigned int Parma_Polyhedra_Library::Implementation::last_one ( unsigned int  u)
inline

Assuming u is nonzero, returns the index of the last set bit in u.

Definition at line 194 of file Bit_Row_inlines.hh.

References Parma_Polyhedra_Library::clz(), and sizeof_to_bits.

Referenced by Parma_Polyhedra_Library::Bit_Row::last(), and Parma_Polyhedra_Library::Bit_Row::prev().

194  {
195  return static_cast<unsigned int>(sizeof_to_bits(sizeof(u)))
196  - 1U - clz(u);
197 }
#define sizeof_to_bits(size)
Definition: compiler.hh:80
unsigned int clz(unsigned int u)
Definition: compiler.hh:143
unsigned int Parma_Polyhedra_Library::Implementation::last_one ( unsigned long  ul)
inline

Assuming ul is nonzero, returns the index of the last set bit in ul.

Definition at line 204 of file Bit_Row_inlines.hh.

References Parma_Polyhedra_Library::clz(), and sizeof_to_bits.

204  {
205  return static_cast<unsigned int>(sizeof_to_bits(sizeof(ul)))
206  - 1U - clz(ul);
207 }
#define sizeof_to_bits(size)
Definition: compiler.hh:80
unsigned int clz(unsigned int u)
Definition: compiler.hh:143
unsigned int Parma_Polyhedra_Library::Implementation::last_one ( unsigned long long  ull)
inline

Assuming ull is nonzero, returns the index of the last set bit in ull.

Definition at line 214 of file Bit_Row_inlines.hh.

References Parma_Polyhedra_Library::clz(), and sizeof_to_bits.

214  {
215  return static_cast<unsigned int>(sizeof_to_bits(sizeof(ull)))
216  - 1U - clz(ull);
217 }
#define sizeof_to_bits(size)
Definition: compiler.hh:80
unsigned int clz(unsigned int u)
Definition: compiler.hh:143
template<typename P , typename Q >
bool Parma_Polyhedra_Library::Implementation::operator!= ( const Ptr_Iterator< P > &  x,
const Ptr_Iterator< Q > &  y 
)
inline

Definition at line 141 of file Ptr_Iterator_inlines.hh.

References Parma_Polyhedra_Library::Implementation::Ptr_Iterator< P >::base().

141  {
142  return x.base() != y.base();
143 }
template<typename T >
bool Parma_Polyhedra_Library::Implementation::operator!= ( const EList_Iterator< T > &  x,
const EList_Iterator< T > &  y 
)
inline

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

Definition at line 101 of file EList_Iterator_inlines.hh.

References Parma_Polyhedra_Library::Implementation::EList_Iterator< T >::ptr.

101  {
102  return x.ptr != y.ptr;
103 }
template<typename P >
Ptr_Iterator< P > Parma_Polyhedra_Library::Implementation::operator+ ( typename Ptr_Iterator< P >::difference_type  m,
const Ptr_Iterator< P > &  y 
)
inline

Definition at line 177 of file Ptr_Iterator_inlines.hh.

References Parma_Polyhedra_Library::Implementation::Ptr_Iterator< P >::base().

178  {
179  return Ptr_Iterator<P>(m + y.base());
180 }
template<typename P , typename Q >
Ptr_Iterator< P >::difference_type Parma_Polyhedra_Library::Implementation::operator- ( const Ptr_Iterator< P > &  x,
const Ptr_Iterator< Q > &  y 
)
inline

Definition at line 171 of file Ptr_Iterator_inlines.hh.

References Parma_Polyhedra_Library::Implementation::Ptr_Iterator< P >::base().

171  {
172  return x.base() - y.base();
173 }
template<typename P , typename Q >
bool Parma_Polyhedra_Library::Implementation::operator< ( const Ptr_Iterator< P > &  x,
const Ptr_Iterator< Q > &  y 
)
inline

Definition at line 147 of file Ptr_Iterator_inlines.hh.

References Parma_Polyhedra_Library::Implementation::Ptr_Iterator< P >::base().

147  {
148  return x.base() < y.base();
149 }
template<typename P , typename Q >
bool Parma_Polyhedra_Library::Implementation::operator<= ( const Ptr_Iterator< P > &  x,
const Ptr_Iterator< Q > &  y 
)
inline

Definition at line 153 of file Ptr_Iterator_inlines.hh.

References Parma_Polyhedra_Library::Implementation::Ptr_Iterator< P >::base().

153  {
154  return x.base() <= y.base();
155 }
template<typename P , typename Q >
bool Parma_Polyhedra_Library::Implementation::operator== ( const Ptr_Iterator< P > &  x,
const Ptr_Iterator< Q > &  y 
)
inline

Definition at line 135 of file Ptr_Iterator_inlines.hh.

References Parma_Polyhedra_Library::Implementation::Ptr_Iterator< P >::base().

135  {
136  return x.base() == y.base();
137 }
template<typename T >
bool Parma_Polyhedra_Library::Implementation::operator== ( const EList_Iterator< T > &  x,
const EList_Iterator< T > &  y 
)
inline

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

Definition at line 95 of file EList_Iterator_inlines.hh.

References Parma_Polyhedra_Library::Implementation::EList_Iterator< T >::ptr.

95  {
96  return x.ptr == y.ptr;
97 }
template<typename P , typename Q >
bool Parma_Polyhedra_Library::Implementation::operator> ( const Ptr_Iterator< P > &  x,
const Ptr_Iterator< Q > &  y 
)
inline

Definition at line 159 of file Ptr_Iterator_inlines.hh.

References Parma_Polyhedra_Library::Implementation::Ptr_Iterator< P >::base().

159  {
160  return x.base() > y.base();
161 }
template<typename P , typename Q >
bool Parma_Polyhedra_Library::Implementation::operator>= ( const Ptr_Iterator< P > &  x,
const Ptr_Iterator< Q > &  y 
)
inline

Definition at line 165 of file Ptr_Iterator_inlines.hh.

References Parma_Polyhedra_Library::Implementation::Ptr_Iterator< P >::base().

165  {
166  return x.base() >= y.base();
167 }
template<typename Iter >
Iter Parma_Polyhedra_Library::Implementation::swapping_unique ( Iter  first,
Iter  last 
)

Definition at line 176 of file swapping_sort_templates.hh.

176  {
177  return swapping_unique(first, last, std::iter_swap<Iter, Iter>);
178 }
template<typename PSET >
void Parma_Polyhedra_Library::Implementation::wrap_assign ( PSET &  pointset,
const Variables_Set vars,
const Bounded_Integer_Type_Width  w,
const Bounded_Integer_Type_Representation  r,
const Bounded_Integer_Type_Overflow  o,
const Constraint_System cs_p,
const unsigned  complexity_threshold,
const bool  wrap_individually,
const char *  class_name 
)

Definition at line 152 of file wrap_assign.hh.

References Parma_Polyhedra_Library::assign_r(), Parma_Polyhedra_Library::Constraint_System::begin(), c, Parma_Polyhedra_Library::Constraint::coefficient(), Parma_Polyhedra_Library::Coefficient_one(), Parma_Polyhedra_Library::EMPTY, Parma_Polyhedra_Library::Constraint_System::end(), Parma_Polyhedra_Library::Variables_Set::insert(), Parma_Polyhedra_Library::Constraint_System::insert(), Parma_Polyhedra_Library::mul_2exp_assign(), Parma_Polyhedra_Library::neg_assign(), Parma_Polyhedra_Library::OVERFLOW_IMPOSSIBLE, Parma_Polyhedra_Library::OVERFLOW_UNDEFINED, PPL_DIRTY_TEMP_COEFFICIENT, PPL_UNINITIALIZED, Parma_Polyhedra_Library::result_overflow(), Parma_Polyhedra_Library::ROUND_DOWN, Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::SIGNED_2_COMPLEMENT, Parma_Polyhedra_Library::Variables_Set::space_dimension(), Parma_Polyhedra_Library::Constraint_System::space_dimension(), Parma_Polyhedra_Library::UNSIGNED, wrap_assign_col(), and wrap_assign_ind().

Referenced by Parma_Polyhedra_Library::Box< ITV >::wrap_assign(), Parma_Polyhedra_Library::Octagonal_Shape< T >::wrap_assign(), Parma_Polyhedra_Library::BD_Shape< T >::wrap_assign(), and Parma_Polyhedra_Library::Polyhedron::wrap_assign().

160  {
161  // We must have cs_p->space_dimension() <= vars.space_dimension()
162  // and vars.space_dimension() <= pointset.space_dimension().
163 
164  // Dimension-compatibility check of `*cs_p', if any.
165  if (cs_p != 0) {
166  const dimension_type vars_space_dim = vars.space_dimension();
167  if (cs_p->space_dimension() > vars_space_dim) {
168  std::ostringstream s;
169  s << "PPL::" << class_name << "::wrap_assign(..., cs_p, ...):"
170  << std::endl
171  << "vars.space_dimension() == " << vars_space_dim
172  << ", cs_p->space_dimension() == " << cs_p->space_dimension() << ".";
173  throw std::invalid_argument(s.str());
174  }
175 
176 #ifndef NDEBUG
177  // Check that all variables upon which `*cs_p' depends are in `vars'.
178  // An assertion is violated otherwise.
179  const Constraint_System cs = *cs_p;
180  const dimension_type cs_space_dim = cs.space_dimension();
181  Variables_Set::const_iterator vars_end = vars.end();
182  for (Constraint_System::const_iterator i = cs.begin(),
183  cs_end = cs.end(); i != cs_end; ++i) {
184  const Constraint& c = *i;
185  for (dimension_type d = cs_space_dim; d-- > 0; ) {
186  PPL_ASSERT(c.coefficient(Variable(d)) == 0
187  || vars.find(d) != vars_end);
188  }
189  }
190 #endif
191  }
192 
193  // Wrapping no variable only requires refining with *cs_p, if any.
194  if (vars.empty()) {
195  if (cs_p != 0) {
196  pointset.refine_with_constraints(*cs_p);
197  }
198  return;
199  }
200 
201  // Dimension-compatibility check of `vars'.
202  const dimension_type space_dim = pointset.space_dimension();
203  if (vars.space_dimension() > space_dim) {
204  std::ostringstream s;
205  s << "PPL::" << class_name << "::wrap_assign(vs, ...):" << std::endl
206  << "this->space_dimension() == " << space_dim
207  << ", required space dimension == " << vars.space_dimension() << ".";
208  throw std::invalid_argument(s.str());
209  }
210 
211  // Wrapping an empty polyhedron is a no-op.
212  if (pointset.is_empty()) {
213  return;
214  }
215  // Set `min_value' and `max_value' to the minimum and maximum values
216  // a variable of width `w' and signedness `s' can take.
217  PPL_DIRTY_TEMP_COEFFICIENT(min_value);
218  PPL_DIRTY_TEMP_COEFFICIENT(max_value);
219  if (r == UNSIGNED) {
220  min_value = 0;
221  mul_2exp_assign(max_value, Coefficient_one(), w);
222  --max_value;
223  }
224  else {
225  PPL_ASSERT(r == SIGNED_2_COMPLEMENT);
226  mul_2exp_assign(max_value, Coefficient_one(), w-1);
227  neg_assign(min_value, max_value);
228  --max_value;
229  }
230 
231  // If we are wrapping variables collectively, the ranges for the
232  // required translations are saved in `translations' instead of being
233  // immediately applied.
234  Wrap_Translations translations;
235 
236  // Dimensions subject to translation are added to this set if we are
237  // wrapping collectively or if `cs_p' is non null.
238  Variables_Set dimensions_to_be_translated;
239 
240  // This will contain a lower bound to the number of abstractions
241  // to be joined in order to obtain the collective wrapping result.
242  // As soon as this exceeds `complexity_threshold', counting will be
243  // interrupted and the full range will be the result of wrapping
244  // any dimension that is not fully contained in quadrant 0.
245  unsigned collective_wrap_complexity = 1;
246 
247  // This flag signals that the maximum complexity for collective
248  // wrapping as been exceeded.
249  bool collective_wrap_too_complex = false;
250 
251  if (!wrap_individually) {
252  translations.reserve(space_dim);
253  }
254 
255  // We use `full_range_bounds' to delay conversions whenever
256  // this delay does not negatively affect precision.
257  Constraint_System full_range_bounds;
258 
263 
264  for (Variables_Set::const_iterator i = vars.begin(),
265  vars_end = vars.end(); i != vars_end; ++i) {
266 
267  const Variable x(*i);
268 
269  bool extremum;
270 
271  if (!pointset.minimize(x, l_n, l_d, extremum)) {
272  set_full_range:
273  pointset.unconstrain(x);
274  full_range_bounds.insert(min_value <= x);
275  full_range_bounds.insert(x <= max_value);
276  continue;
277  }
278 
279  if (!pointset.maximize(x, u_n, u_d, extremum)) {
280  goto set_full_range;
281  }
282 
283  div_assign_r(l_n, l_n, l_d, ROUND_DOWN);
284  div_assign_r(u_n, u_n, u_d, ROUND_DOWN);
285  l_n -= min_value;
286  u_n -= min_value;
287  div_2exp_assign_r(l_n, l_n, w, ROUND_DOWN);
288  div_2exp_assign_r(u_n, u_n, w, ROUND_DOWN);
289  Coefficient& first_quadrant = l_n;
290  const Coefficient& last_quadrant = u_n;
291 
292  // Special case: this variable does not need wrapping.
293  if (first_quadrant == 0 && last_quadrant == 0) {
294  continue;
295  }
296 
297  // If overflow is impossible, try not to add useless constraints.
298  if (o == OVERFLOW_IMPOSSIBLE) {
299  if (first_quadrant < 0) {
300  full_range_bounds.insert(min_value <= x);
301  }
302  if (last_quadrant > 0) {
303  full_range_bounds.insert(x <= max_value);
304  }
305  continue;
306  }
307 
308  if (o == OVERFLOW_UNDEFINED || collective_wrap_too_complex) {
309  goto set_full_range;
310  }
311 
312  Coefficient& quadrants = u_d;
313  quadrants = last_quadrant - first_quadrant + 1;
314 
315  PPL_UNINITIALIZED(unsigned, extension);
316  Result res = assign_r(extension, quadrants, ROUND_IGNORE);
317  if (result_overflow(res) != 0 || extension > complexity_threshold) {
318  goto set_full_range;
319  }
320 
321  if (!wrap_individually && !collective_wrap_too_complex) {
322  res = mul_assign_r(collective_wrap_complexity,
323  collective_wrap_complexity, extension, ROUND_IGNORE);
324  if (result_overflow(res) != 0
325  || collective_wrap_complexity > complexity_threshold) {
326  collective_wrap_too_complex = true;
327  }
328  if (collective_wrap_too_complex) {
329  // Set all the dimensions in `translations' to full range.
330  for (Wrap_Translations::const_iterator j = translations.begin(),
331  translations_end = translations.end();
332  j != translations_end;
333  ++j) {
334  const Variable y(j->var);
335  pointset.unconstrain(y);
336  full_range_bounds.insert(min_value <= y);
337  full_range_bounds.insert(y <= max_value);
338  }
339  }
340  }
341 
342  if (wrap_individually && cs_p == 0) {
343  Coefficient& quadrant = first_quadrant;
344  // Temporary variable holding the shifts to be applied in order
345  // to implement the translations.
346  Coefficient& shift = l_d;
347  PSET hull(space_dim, EMPTY);
348  for ( ; quadrant <= last_quadrant; ++quadrant) {
349  PSET p(pointset);
350  if (quadrant != 0) {
351  mul_2exp_assign(shift, quadrant, w);
352  p.affine_image(x, x - shift, 1);
353  }
354  p.refine_with_constraint(min_value <= x);
355  p.refine_with_constraint(x <= max_value);
356  hull.upper_bound_assign(p);
357  }
358  pointset.m_swap(hull);
359  }
360  else if (wrap_individually || !collective_wrap_too_complex) {
361  PPL_ASSERT(!wrap_individually || cs_p != 0);
362  dimensions_to_be_translated.insert(x);
363  translations
364  .push_back(Wrap_Dim_Translations(x, first_quadrant, last_quadrant));
365  }
366  }
367 
368  if (!translations.empty()) {
369  if (wrap_individually) {
370  PPL_ASSERT(cs_p != 0);
371  wrap_assign_ind(pointset, dimensions_to_be_translated,
372  translations.begin(), translations.end(),
373  w, min_value, max_value, *cs_p, l_n, l_d);
374  }
375  else {
376  PSET hull(space_dim, EMPTY);
377  wrap_assign_col(hull, pointset, dimensions_to_be_translated,
378  translations.begin(), translations.end(),
379  w, min_value, max_value, cs_p, l_n);
380  pointset.m_swap(hull);
381  }
382  }
383 
384  if (cs_p != 0) {
385  pointset.refine_with_constraints(*cs_p);
386  }
387  pointset.refine_with_constraints(full_range_bounds);
388 }
int result_overflow(Result r)
The empty element, i.e., the empty set.
void wrap_assign_ind(PSET &pointset, Variables_Set &vars, Wrap_Translations::const_iterator first, Wrap_Translations::const_iterator end, Bounded_Integer_Type_Width w, Coefficient_traits::const_reference min_value, Coefficient_traits::const_reference max_value, const Constraint_System &cs, Coefficient &tmp1, Coefficient &tmp2)
Definition: wrap_assign.hh:52
size_t dimension_type
An unsigned integral type for representing space dimensions.
#define PPL_DIRTY_TEMP_COEFFICIENT(id)
Declare a local variable named id, of type Coefficient, and containing an unknown initial value...
Result
Possible outcomes of a checked arithmetic computation.
Definition: Result_defs.hh:76
Enable_If< Is_Native_Or_Checked< To >::value &&Is_Special< From >::value, Result >::type assign_r(To &to, const From &x, Rounding_Dir dir)
void mul_2exp_assign(Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, unsigned int exp)
Assigns to x the value .
On overflow, the result is undefined.
void wrap_assign_col(PSET &dest, const PSET &src, const Variables_Set &vars, Wrap_Translations::const_iterator first, Wrap_Translations::const_iterator end, Bounded_Integer_Type_Width w, Coefficient_traits::const_reference min_value, Coefficient_traits::const_reference max_value, const Constraint_System *cs_p, Coefficient &tmp)
Definition: wrap_assign.hh:104
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
void neg_assign(Checked_Number< T, Policy > &x)
Assigns to x its negation.
Signed binary where negative values are represented by the two's complement of the absolute value...
Coefficient c
Definition: PIP_Tree.cc:64
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
#define PPL_UNINITIALIZED(type, name)
Definition: compiler.hh:72
std::vector< Wrap_Dim_Translations > Wrap_Translations
Definition: wrap_assign.hh:48
template<typename PSET >
void Parma_Polyhedra_Library::Implementation::wrap_assign_col ( PSET &  dest,
const PSET &  src,
const Variables_Set vars,
Wrap_Translations::const_iterator  first,
Wrap_Translations::const_iterator  end,
Bounded_Integer_Type_Width  w,
Coefficient_traits::const_reference  min_value,
Coefficient_traits::const_reference  max_value,
const Constraint_System cs_p,
Coefficient tmp 
)

Definition at line 104 of file wrap_assign.hh.

References Parma_Polyhedra_Library::Implementation::Wrap_Dim_Translations::first_quadrant, Parma_Polyhedra_Library::Implementation::Wrap_Dim_Translations::last_quadrant, Parma_Polyhedra_Library::mul_2exp_assign(), PPL_DIRTY_TEMP_COEFFICIENT, and Parma_Polyhedra_Library::Implementation::Wrap_Dim_Translations::var.

Referenced by wrap_assign().

113  {
114  if (first == end) {
115  PSET p(src);
116  if (cs_p != 0) {
117  p.refine_with_constraints(*cs_p);
118  }
119  for (Variables_Set::const_iterator i = vars.begin(),
120  vars_end = vars.end(); i != vars_end; ++i) {
121  const Variable x(*i);
122  p.refine_with_constraint(min_value <= x);
123  p.refine_with_constraint(x <= max_value);
124  }
125  dest.upper_bound_assign(p);
126  }
127  else {
128  const Wrap_Dim_Translations& wrap_dim_translations = *first;
129  const Variable x(wrap_dim_translations.var);
130  const Coefficient& first_quadrant = wrap_dim_translations.first_quadrant;
131  const Coefficient& last_quadrant = wrap_dim_translations.last_quadrant;
132  Coefficient& shift = tmp;
133  PPL_DIRTY_TEMP_COEFFICIENT(quadrant);
134  for (quadrant = first_quadrant; quadrant <= last_quadrant; ++quadrant) {
135  if (quadrant != 0) {
136  mul_2exp_assign(shift, quadrant, w);
137  PSET p(src);
138  p.affine_image(x, x - shift, 1);
139  wrap_assign_col(dest, p, vars, first+1, end, w, min_value, max_value,
140  cs_p, tmp);
141  }
142  else {
143  wrap_assign_col(dest, src, vars, first+1, end, w, min_value, max_value,
144  cs_p, tmp);
145  }
146  }
147  }
148 }
#define PPL_DIRTY_TEMP_COEFFICIENT(id)
Declare a local variable named id, of type Coefficient, and containing an unknown initial value...
void mul_2exp_assign(Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, unsigned int exp)
Assigns to x the value .
void wrap_assign_col(PSET &dest, const PSET &src, const Variables_Set &vars, Wrap_Translations::const_iterator first, Wrap_Translations::const_iterator end, Bounded_Integer_Type_Width w, Coefficient_traits::const_reference min_value, Coefficient_traits::const_reference max_value, const Constraint_System *cs_p, Coefficient &tmp)
Definition: wrap_assign.hh:104
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
template<typename PSET >
void Parma_Polyhedra_Library::Implementation::wrap_assign_ind ( PSET &  pointset,
Variables_Set vars,
Wrap_Translations::const_iterator  first,
Wrap_Translations::const_iterator  end,
Bounded_Integer_Type_Width  w,
Coefficient_traits::const_reference  min_value,
Coefficient_traits::const_reference  max_value,
const Constraint_System cs,
Coefficient tmp1,
Coefficient tmp2 
)

Definition at line 52 of file wrap_assign.hh.

References Parma_Polyhedra_Library::Constraint_System::begin(), Parma_Polyhedra_Library::EMPTY, Parma_Polyhedra_Library::Constraint_System::end(), Parma_Polyhedra_Library::Implementation::Wrap_Dim_Translations::first_quadrant, Parma_Polyhedra_Library::Variable::id(), Parma_Polyhedra_Library::Implementation::Wrap_Dim_Translations::last_quadrant, Parma_Polyhedra_Library::mul_2exp_assign(), and Parma_Polyhedra_Library::Implementation::Wrap_Dim_Translations::var.

Referenced by wrap_assign().

61  {
62  const dimension_type space_dim = pointset.space_dimension();
63  for (Wrap_Translations::const_iterator i = first; i != end; ++i) {
64  const Wrap_Dim_Translations& wrap_dim_translations = *i;
65  const Variable x(wrap_dim_translations.var);
66  const Coefficient& first_quadrant = wrap_dim_translations.first_quadrant;
67  const Coefficient& last_quadrant = wrap_dim_translations.last_quadrant;
68  Coefficient& quadrant = tmp1;
69  Coefficient& shift = tmp2;
70  PSET hull(space_dim, EMPTY);
71  for (quadrant = first_quadrant; quadrant <= last_quadrant; ++quadrant) {
72  PSET p(pointset);
73  if (quadrant != 0) {
74  mul_2exp_assign(shift, quadrant, w);
75  p.affine_image(x, x - shift, 1);
76  }
77  // `x' has just been wrapped.
78  vars.erase(x.id());
79 
80  // Refine `p' with all the constraints in `cs' not depending
81  // on variables in `vars'.
82  if (vars.empty()) {
83  p.refine_with_constraints(cs);
84  }
85  else {
86  for (Constraint_System::const_iterator j = cs.begin(),
87  cs_end = cs.end(); j != cs_end; ++j) {
88  if (j->expression().all_zeroes(vars)) {
89  // `*j' does not depend on variables in `vars'.
90  p.refine_with_constraint(*j);
91  }
92  }
93  }
94  p.refine_with_constraint(min_value <= x);
95  p.refine_with_constraint(x <= max_value);
96  hull.upper_bound_assign(p);
97  }
98  pointset.m_swap(hull);
99  }
100 }
The empty element, i.e., the empty set.
size_t dimension_type
An unsigned integral type for representing space dimensions.
void mul_2exp_assign(Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, unsigned int exp)
Assigns to x the value .
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.