PPL  1.2
Parma_Polyhedra_Library::I_Constraint_Common< Derived > Class Template Reference

#include <intervals_defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::I_Constraint_Common< Derived >:
Collaboration diagram for Parma_Polyhedra_Library::I_Constraint_Common< Derived >:

Public Member Functions

template<typename T >
Result convert_real (T &to) const
 
template<typename T >
Result convert_real (T &to1, Result &rel2, T &to2) const
 
template<typename T >
Result convert_integer (T &to) const
 

Detailed Description

template<typename Derived>
class Parma_Polyhedra_Library::I_Constraint_Common< Derived >

Definition at line 202 of file intervals_defs.hh.

Member Function Documentation

template<typename Derived>
template<typename T >
Result Parma_Polyhedra_Library::I_Constraint_Common< Derived >::convert_integer ( T &  to) const
inline

Definition at line 338 of file intervals_defs.hh.

338  {
339  Result rel = convert_real(to);
340  switch (rel) {
341  case V_LT:
342  if (is_integer(to)) {
343  rel = sub_assign_r(to, to, T(1), (ROUND_UP | ROUND_STRICT_RELATION));
344  rel = result_relation_class(rel);
345  return (rel == V_EQ) ? V_LE : rel;
346  }
347  /* Fall through */
348  case V_LE:
349  rel = floor_assign_r(to, to, ROUND_UP);
350  rel = result_relation_class(rel);
351  PPL_ASSERT(rel == V_EQ);
352  return V_LE;
353  case V_GT:
354  if (is_integer(to)) {
355  rel = add_assign_r(to, to, T(1), (ROUND_DOWN | ROUND_STRICT_RELATION));
356  rel = result_relation_class(rel);
357  return (rel == V_EQ) ? V_GE : rel;
358  }
359  /* Fall through */
360  case V_GE:
361  rel = ceil_assign_r(to, to, ROUND_DOWN);
362  rel = result_relation_class(rel);
363  PPL_ASSERT(rel == V_EQ);
364  return V_GE;
365  case V_EQ:
366  if (is_integer(to)) {
367  return V_EQ;
368  }
369  return V_EMPTY;
370  case V_NE:
371  if (is_integer(to)) {
372  return V_NE;
373  }
374  return V_LGE;
375  default:
376  return rel;
377  }
378  }
The computed result is exact.
Definition: Result_defs.hh:81
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type is_integer(const T &x)
Result
Possible outcomes of a checked arithmetic computation.
Definition: Result_defs.hh:76
The computed result is inexact and rounded down.
Definition: Result_defs.hh:87
The exact result is not comparable.
Definition: Result_defs.hh:78
The computed result is inexact.
Definition: Result_defs.hh:90
Result result_relation_class(Result r)
The computed result may be inexact and rounded up.
Definition: Result_defs.hh:93
The computed result may be inexact and rounded down.
Definition: Result_defs.hh:96
The computed result is inexact and rounded up.
Definition: Result_defs.hh:84
The computed result may be inexact.
Definition: Result_defs.hh:99
template<typename Derived>
template<typename T >
Result Parma_Polyhedra_Library::I_Constraint_Common< Derived >::convert_real ( T &  to) const
inline

Definition at line 205 of file intervals_defs.hh.

Referenced by Parma_Polyhedra_Library::I_Constraint_Common< I_Constraint< T, Val_Or_Ref_Criteria, extended > >::convert_integer().

205  {
206  const Derived& c = static_cast<const Derived&>(*this);
207  Result r = c.rel();
208  switch (r) {
209  case V_EMPTY:
210  case V_LGE:
211  return r;
212  case V_LE:
213  r = assign_r(to, c.value(), (ROUND_UP | ROUND_STRICT_RELATION));
214  r = result_relation_class(r);
215  if (r == V_EQ) {
216  return V_LE;
217  }
218  goto lt;
219  case V_LT:
220  r = assign_r(to, c.value(), ROUND_UP);
221  r = result_relation_class(r);
222  lt:
223  switch (r) {
224  case V_EMPTY:
225  case V_LT_PLUS_INFINITY:
226  case V_EQ_MINUS_INFINITY:
227  return r;
228  case V_LT:
229  case V_LE:
230  case V_EQ:
231  return V_LT;
232  default:
233  break;
234  }
235  break;
236  case V_GE:
237  r = assign_r(to, c.value(), (ROUND_DOWN | ROUND_STRICT_RELATION));
238  r = result_relation_class(r);
239  if (r == V_EQ) {
240  return V_GE;
241  }
242  goto gt;
243  case V_GT:
244  r = assign_r(to, c.value(), ROUND_DOWN);
245  r = result_relation_class(r);
246  gt:
247  switch (r) {
248  case V_EMPTY:
249  case V_GT_MINUS_INFINITY:
250  case V_EQ_PLUS_INFINITY:
251  return r;
252  case V_LT:
253  case V_LE:
254  case V_EQ:
255  return V_GT;
256  default:
257  break;
258  }
259  break;
260  case V_EQ:
261  r = assign_r(to, c.value(), ROUND_CHECK);
262  r = result_relation_class(r);
263  PPL_ASSERT(r != V_LT && r != V_GT);
264  if (r == V_EQ) {
265  return V_EQ;
266  }
267  else {
268  return V_EMPTY;
269  }
270  case V_NE:
271  r = assign_r(to, c.value(), ROUND_CHECK);
272  r = result_relation_class(r);
273  if (r == V_EQ) {
274  return V_NE;
275  }
276  else {
277  return V_LGE;
278  }
279  default:
280  break;
281  }
282  PPL_UNREACHABLE;
283  return V_EMPTY;
284  }
Enable_If< Is_Native_Or_Checked< To >::value &&Is_Special< From >::value, Result >::type assign_r(To &to, const From &, Rounding_Dir dir)
The computed result is exact.
Definition: Result_defs.hh:81
A positive integer overflow occurred (rounding up).
Definition: Result_defs.hh:111
bool lt(Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
Result
Possible outcomes of a checked arithmetic computation.
Definition: Result_defs.hh:76
bool gt(Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
The computed result is inexact and rounded down.
Definition: Result_defs.hh:87
The exact result is not comparable.
Definition: Result_defs.hh:78
The computed result is inexact.
Definition: Result_defs.hh:90
Result result_relation_class(Result r)
The computed result may be inexact and rounded up.
Definition: Result_defs.hh:93
The computed result may be inexact and rounded down.
Definition: Result_defs.hh:96
A negative integer overflow occurred (rounding down).
Definition: Result_defs.hh:114
Coefficient c
Definition: PIP_Tree.cc:64
The computed result is inexact and rounded up.
Definition: Result_defs.hh:84
The computed result may be inexact.
Definition: Result_defs.hh:99
template<typename Derived>
template<typename T >
Result Parma_Polyhedra_Library::I_Constraint_Common< Derived >::convert_real ( T &  to1,
Result rel2,
T &  to2 
) const
inline

Definition at line 286 of file intervals_defs.hh.

286  {
287  const Derived& c = static_cast<const Derived&>(*this);
288  Result rel1;
289  if (c.rel() != V_EQ) {
290  rel2 = convert(to2);
291  return V_LGE;
292  }
293  rel2 = assign_r(to2, c.value(), ROUND_UP);
294  rel2 = result_relation_class(rel2);
295  switch (rel2) {
296  case V_EMPTY:
297  case V_EQ_MINUS_INFINITY:
298  case V_EQ:
299  return V_LGE;
300  default:
301  break;
302  }
303  rel1 = assign_r(to1, c.value(), ROUND_DOWN);
304  rel1 = result_relation_class(rel1);
305  switch (rel1) {
306  case V_EQ:
307  PPL_ASSERT(rel2 == V_LE);
308  goto eq;
309  case V_EQ_PLUS_INFINITY:
310  case V_EMPTY:
311  rel2 = rel1;
312  return V_LGE;
313  case V_GE:
314  if (rel2 == V_LE && to1 == to2) {
315  eq:
316  rel2 = V_EQ;
317  return V_LGE;
318  }
319  /* Fall through*/
320  case V_GT:
321  case V_GT_MINUS_INFINITY:
322  return rel1;
323  default:
324  PPL_UNREACHABLE;
325  return V_EMPTY;
326  }
327  switch (rel2) {
328  case V_LE:
329  case V_LT:
330  case V_LT_PLUS_INFINITY:
331  return rel1;
332  default:
333  PPL_UNREACHABLE;
334  return V_EMPTY;
335  }
336  }
Enable_If< Is_Native_Or_Checked< To >::value &&Is_Special< From >::value, Result >::type assign_r(To &to, const From &, Rounding_Dir dir)
The computed result is exact.
Definition: Result_defs.hh:81
A positive integer overflow occurred (rounding up).
Definition: Result_defs.hh:111
Result
Possible outcomes of a checked arithmetic computation.
Definition: Result_defs.hh:76
The computed result is inexact and rounded down.
Definition: Result_defs.hh:87
The exact result is not comparable.
Definition: Result_defs.hh:78
bool eq(Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
Result result_relation_class(Result r)
The computed result may be inexact and rounded up.
Definition: Result_defs.hh:93
The computed result may be inexact and rounded down.
Definition: Result_defs.hh:96
A negative integer overflow occurred (rounding down).
Definition: Result_defs.hh:114
Coefficient c
Definition: PIP_Tree.cc:64
The computed result is inexact and rounded up.
Definition: Result_defs.hh:84
The computed result may be inexact.
Definition: Result_defs.hh:99

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