PPL  1.2
Parma_Polyhedra_Library::Generator Class Reference

A line, ray, point or closure point. More...

#include <Generator_defs.hh>

Collaboration diagram for Parma_Polyhedra_Library::Generator:

Public Types

enum  Type { LINE, RAY, POINT, CLOSURE_POINT }
 The generator type. More...
 
typedef Expression_Hide_Last< Expression_Hide_Inhomo< Linear_Expression > > expr_type
 The type of the (adapted) internal expression. More...
 

Public Member Functions

 Generator (Representation r=default_representation)
 Constructs the point at the origin. More...
 
 Generator (const Generator &g)
 
 Generator (const Generator &g, Representation r)
 Copy constructor with given representation. More...
 
 Generator (const Generator &g, dimension_type space_dim)
 
 Generator (const Generator &g, dimension_type space_dim, Representation r)
 Copy constructor with given representation and space dimension. More...
 
 ~Generator ()
 Destructor. More...
 
Generatoroperator= (const Generator &g)
 Assignment operator. More...
 
Representation representation () const
 Returns the current representation of *this. More...
 
void set_representation (Representation r)
 Converts *this to the specified representation. More...
 
dimension_type space_dimension () const
 Returns the dimension of the vector space enclosing *this. More...
 
void set_space_dimension (dimension_type space_dim)
 
void swap_space_dimensions (Variable v1, Variable v2)
 Swaps the coefficients of the variables v1 and v2 . More...
 
bool remove_space_dimensions (const Variables_Set &vars)
 Removes all the specified dimensions from the generator. More...
 
void permute_space_dimensions (const std::vector< Variable > &cycle)
 Permutes the space dimensions of the generator. More...
 
void shift_space_dimensions (Variable v, dimension_type n)
 
Type type () const
 Returns the generator type of *this. More...
 
bool is_line () const
 Returns true if and only if *this is a line. More...
 
bool is_ray () const
 Returns true if and only if *this is a ray. More...
 
bool is_line_or_ray () const
 Returns true if and only if *this is a line or a ray. More...
 
bool is_point () const
 Returns true if and only if *this is a point. More...
 
bool is_closure_point () const
 Returns true if and only if *this is a closure point. More...
 
Coefficient_traits::const_reference coefficient (Variable v) const
 Returns the coefficient of v in *this. More...
 
Coefficient_traits::const_reference divisor () const
 If *this is either a point or a closure point, returns its divisor. More...
 
memory_size_type total_memory_in_bytes () const
 Returns a lower bound to 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 is_equivalent_to (const Generator &y) const
 Returns true if and only if *this and y are equivalent generators. More...
 
bool is_equal_to (const Generator &y) const
 Returns true if *this is identical to y. More...
 
bool OK () const
 Checks if all the invariants are satisfied. More...
 
void ascii_dump () const
 Writes to std::cerr an ASCII representation of *this. More...
 
void ascii_dump (std::ostream &s) const
 Writes to s an ASCII representation of *this. More...
 
void print () const
 Prints *this to std::cerr using operator<<. More...
 
bool ascii_load (std::istream &s)
 Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise. More...
 
void m_swap (Generator &y)
 Swaps *this with y. More...
 
expr_type expression () const
 Partial read access to the (adapted) internal expression. More...
 

Static Public Member Functions

static Generator line (const Linear_Expression &e, Representation r=default_representation)
 Returns the line of direction e. More...
 
static Generator ray (const Linear_Expression &e, Representation r=default_representation)
 Returns the ray of direction e. More...
 
static Generator point (const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
 Returns the point at e / d. More...
 
static Generator point (Representation r)
 Returns the origin. More...
 
static Generator point (const Linear_Expression &e, Representation r)
 Returns the point at e. More...
 
static Generator closure_point (const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
 Returns the closure point at e / d. More...
 
static Generator closure_point (Representation r)
 Returns the closure point at the origin. More...
 
static Generator closure_point (const Linear_Expression &e, Representation r)
 Returns the closure point at e. More...
 
static dimension_type max_space_dimension ()
 Returns the maximum space dimension a Generator can handle. More...
 
static void initialize ()
 Initializes the class. More...
 
static void finalize ()
 Finalizes the class. More...
 
static const Generatorzero_dim_point ()
 Returns the origin of the zero-dimensional space $\Rset^0$. More...
 
static const Generatorzero_dim_closure_point ()
 Returns, as a closure point, the origin of the zero-dimensional space $\Rset^0$. More...
 

Static Public Attributes

static const Representation default_representation = SPARSE
 The representation used for new Generators. More...
 

Private Types

enum  Kind { LINE_OR_EQUALITY = 0, RAY_OR_POINT_OR_INEQUALITY = 1 }
 The possible kinds of Generator objects. More...
 

Private Member Functions

 Generator (Linear_Expression &e, Type type, Topology topology)
 Builds a generator of type type and topology topology, stealing the coefficients from e. More...
 
 Generator (Linear_Expression &e, Kind kind, Topology topology)
 
 Generator (dimension_type space_dim, Kind kind, Topology topology, Representation r=default_representation)
 
bool is_line_or_equality () const
 Returns true if and only if *this row represents a line or an equality. More...
 
bool is_ray_or_point_or_inequality () const
 Returns true if and only if *this row represents a ray, a point or an inequality. More...
 
void set_is_line_or_equality ()
 Sets to LINE_OR_EQUALITY the kind of *this row. More...
 
void set_is_ray_or_point_or_inequality ()
 Sets to RAY_OR_POINT_OR_INEQUALITY the kind of *this row. More...
 
void mark_as_necessarily_closed ()
 Marks the epsilon dimension as a standard dimension. More...
 
void mark_as_not_necessarily_closed ()
 Marks the last dimension as the epsilon dimension. More...
 
void linear_combine (const Generator &y, dimension_type i)
 Linearly combines *this with y so that i-th coefficient is 0. More...
 
void set_space_dimension_no_ok (dimension_type space_dim)
 
void throw_dimension_incompatible (const char *method, const char *v_name, Variable v) const
 Throw a std::invalid_argument exception containing the appropriate error message. More...
 
void throw_invalid_argument (const char *method, const char *reason) const
 Throw a std::invalid_argument exception containing the appropriate error message. More...
 
bool is_ray_or_point () const
 Returns true if and only if *this is not a line. More...
 
void set_is_line ()
 Sets the Generator kind to LINE_OR_EQUALITY. More...
 
void set_is_ray_or_point ()
 Sets the Generator kind to RAY_OR_POINT_OR_INEQUALITY. More...
 
bool is_matching_closure_point (const Generator &p) const
 Returns true if and only if the closure point *this has the same coordinates of the point p. More...
 
Coefficient_traits::const_reference epsilon_coefficient () const
 Returns the epsilon coefficient. The generator must be NNC. More...
 
void set_epsilon_coefficient (Coefficient_traits::const_reference n)
 Sets the epsilon coefficient to n. The generator must be NNC. More...
 
void sign_normalize ()
 Normalizes the sign of the coefficients so that the first non-zero (homogeneous) coefficient of a line-or-equality is positive. More...
 
void strong_normalize ()
 Strong normalization: ensures that different Generator objects represent different hyperplanes or hyperspaces. More...
 
bool check_strong_normalized () const
 Returns true if and only if the coefficients are strongly normalized. More...
 
void fancy_print (std::ostream &s) const
 A print function, with fancy, more human-friendly output. More...
 
Flags inspection methods
Topology topology () const
 Returns the topological kind of *this. More...
 
bool is_not_necessarily_closed () const
 Returns true if and only if the topology of *this row is not necessarily closed. More...
 
bool is_necessarily_closed () const
 Returns true if and only if the topology of *this row is necessarily closed. More...
 
Flags coercion methods
void set_topology (Topology x)
 Sets to x the topological kind of *this row. More...
 
void set_necessarily_closed ()
 Sets to NECESSARILY_CLOSED the topological kind of *this row. More...
 
void set_not_necessarily_closed ()
 Sets to NOT_NECESSARILY_CLOSED the topological kind of *this row. More...
 

Private Attributes

Linear_Expression expr
 The linear expression encoding *this. More...
 
Kind kind_
 The kind of *this. More...
 
Topology topology_
 The topology of *this. More...
 

Static Private Attributes

static const Generatorzero_dim_point_p = 0
 Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional space $\Rset^0$. More...
 
static const Generatorzero_dim_closure_point_p = 0
 Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional space $\Rset^0$, as a closure point. More...
 

Friends

class Expression_Adapter< Generator >
 
class Linear_System< Generator >
 
class Parma_Polyhedra_Library::Scalar_Products
 
class Parma_Polyhedra_Library::Topology_Adjusted_Scalar_Product_Sign
 
class Parma_Polyhedra_Library::Topology_Adjusted_Scalar_Product_Assign
 
class Parma_Polyhedra_Library::Generator_System
 
class Parma_Polyhedra_Library::Generator_System_const_iterator
 
class Parma_Polyhedra_Library::Polyhedron
 
class Parma_Polyhedra_Library::Grid_Generator_System
 
class Parma_Polyhedra_Library::MIP_Problem
 
class Parma_Polyhedra_Library::Grid
 
std::ostream & Parma_Polyhedra_Library::IO_Operators::operator<< (std::ostream &s, const Generator &g)
 
int compare (const Generator &x, const Generator &y)
 

Related Functions

(Note that these are not member functions.)

int compare (const Generator &x, const Generator &y)
 
std::ostream & operator<< (std::ostream &s, const Generator &g)
 
std::ostream & operator<< (std::ostream &s, const Generator::Type &t)
 
int compare (const Generator &x, const Generator &y)
 The basic comparison function. More...
 
std::ostream & operator<< (std::ostream &s, const Generator &g)
 Output operator. More...
 
void swap (Generator &x, Generator &y)
 Swaps x with y. More...
 
Generator line (const Linear_Expression &e, Representation r=Generator::default_representation)
 Shorthand for Generator::line(const Linear_Expression& e, Representation r). More...
 
Generator ray (const Linear_Expression &e, Representation r=Generator::default_representation)
 Shorthand for Generator::ray(const Linear_Expression& e, Representation r). More...
 
Generator point (const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=Generator::default_representation)
 Shorthand for Generator::point(const Linear_Expression& e, Coefficient_traits::const_reference d, Representation r). More...
 
Generator point (Representation r)
 Shorthand for Generator::point(Representation r). More...
 
Generator point (const Linear_Expression &e, Representation r)
 Shorthand for Generator::point(const Linear_Expression& e, Representation r). More...
 
Generator closure_point (const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=Generator::default_representation)
 Shorthand for Generator::closure_point(const Linear_Expression& e, Coefficient_traits::const_reference d, Representation r). More...
 
Generator closure_point (Representation r)
 Shorthand for Generator::closure_point(Representation r). More...
 
Generator closure_point (const Linear_Expression &e, Representation r)
 Shorthand for Generator::closure_point(const Linear_Expression& e, Representation r). More...
 
bool operator== (const Generator &x, const Generator &y)
 Returns true if and only if x is equivalent to y. More...
 
bool operator!= (const Generator &x, const Generator &y)
 Returns true if and only if x is not equivalent to y. More...
 
template<typename To >
bool rectilinear_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, Rounding_Dir dir)
 Computes the rectilinear (or Manhattan) distance between x and y. More...
 
template<typename Temp , typename To >
bool rectilinear_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, Rounding_Dir dir)
 Computes the rectilinear (or Manhattan) distance between x and y. More...
 
template<typename Temp , typename To >
bool rectilinear_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)
 Computes the rectilinear (or Manhattan) distance between x and y. More...
 
template<typename To >
bool euclidean_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, Rounding_Dir dir)
 Computes the euclidean distance between x and y. More...
 
template<typename Temp , typename To >
bool rectilinear_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, Rounding_Dir dir)
 Computes the euclidean distance between x and y. More...
 
template<typename Temp , typename To >
bool euclidean_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)
 Computes the euclidean distance between x and y. More...
 
template<typename To >
bool l_infinity_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, Rounding_Dir dir)
 Computes the $L_\infty$ distance between x and y. More...
 
template<typename Temp , typename To >
bool l_infinity_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, Rounding_Dir dir)
 Computes the $L_\infty$ distance between x and y. More...
 
template<typename Temp , typename To >
bool l_infinity_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)
 Computes the $L_\infty$ distance between x and y. More...
 
std::ostream & operator<< (std::ostream &s, const Generator::Type &t)
 Output operator. More...
 
Generator line (const Linear_Expression &e, Representation r)
 
Generator ray (const Linear_Expression &e, Representation r)
 
Generator point (const Linear_Expression &e, Coefficient_traits::const_reference d, Representation r)
 
Generator point (Representation r)
 
Generator point (const Linear_Expression &e, Representation r)
 
Generator closure_point (const Linear_Expression &e, Coefficient_traits::const_reference d, Representation r)
 
Generator closure_point (Representation r)
 
Generator closure_point (const Linear_Expression &e, Representation r)
 
bool operator== (const Generator &x, const Generator &y)
 
bool operator!= (const Generator &x, const Generator &y)
 
template<typename Specialization , typename Temp , typename To >
bool l_m_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, const Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)
 
template<typename Temp , typename To >
bool rectilinear_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, const Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)
 
template<typename Temp , typename To >
bool rectilinear_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, const Rounding_Dir dir)
 
template<typename To >
bool rectilinear_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, const Rounding_Dir dir)
 
template<typename Temp , typename To >
bool euclidean_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, const Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)
 
template<typename Temp , typename To >
bool euclidean_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, const Rounding_Dir dir)
 
template<typename To >
bool euclidean_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, const Rounding_Dir dir)
 
template<typename Temp , typename To >
bool l_infinity_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, const Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)
 
template<typename Temp , typename To >
bool l_infinity_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, const Rounding_Dir dir)
 
template<typename To >
bool l_infinity_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, const Rounding_Dir dir)
 
void swap (Generator &x, Generator &y)
 

Detailed Description

A line, ray, point or closure point.

An object of the class Generator is one of the following:

  • a line $\vect{l} = (a_0, \ldots, a_{n-1})^\transpose$;
  • a ray $\vect{r} = (a_0, \ldots, a_{n-1})^\transpose$;
  • a point $\vect{p} = (\frac{a_0}{d}, \ldots, \frac{a_{n-1}}{d})^\transpose$;
  • a closure point $\vect{c} = (\frac{a_0}{d}, \ldots, \frac{a_{n-1}}{d})^\transpose$;

where $n$ is the dimension of the space and, for points and closure points, $d > 0$ is the divisor.

A note on terminology.
As observed in Section Representations of Convex Polyhedra, there are cases when, in order to represent a polyhedron $\cP$ using the generator system $\cG = (L, R, P, C)$, we need to include in the finite set $P$ even points of $\cP$ that are not vertices of $\cP$. This situation is even more frequent when working with NNC polyhedra and it is the reason why we prefer to use the word `point' where other libraries use the word `vertex'.
How to build a generator.
Each type of generator is built by applying the corresponding function (line, ray, point or closure_point) to a linear expression, representing a direction in the space; the space dimension of the generator is defined as the space dimension of the corresponding linear expression. Linear expressions used to define a generator should be homogeneous (any constant term will be simply ignored). When defining points and closure points, an optional Coefficient argument can be used as a common divisor for all the coefficients occurring in the provided linear expression; the default value for this argument is 1.
In all the following examples it is assumed that variables x, y and z are defined as follows:
Variable x(0);
Variable y(1);
Variable z(2);
Example 1
The following code builds a line with direction $x-y-z$ and having space dimension $3$:
Generator l = line(x - y - z);
As mentioned above, the constant term of the linear expression is not relevant. Thus, the following code has the same effect:
Generator l = line(x - y - z + 15);
By definition, the origin of the space is not a line, so that the following code throws an exception:
Generator l = line(0*x);
Example 2
The following code builds a ray with the same direction as the line in Example 1:
Generator r = ray(x - y - z);
As is the case for lines, when specifying a ray the constant term of the linear expression is not relevant; also, an exception is thrown when trying to build a ray from the origin of the space.
Example 3
The following code builds the point $\vect{p} = (1, 0, 2)^\transpose \in \Rset^3$:
Generator p = point(1*x + 0*y + 2*z);
The same effect can be obtained by using the following code:
Generator p = point(x + 2*z);
Similarly, the origin $\vect{0} \in \Rset^3$ can be defined using either one of the following lines of code:
Generator origin3 = point(0*x + 0*y + 0*z);
Generator origin3_alt = point(0*z);
Note however that the following code would have defined a different point, namely $\vect{0} \in \Rset^2$:
Generator origin2 = point(0*y);
The following two lines of code both define the only point having space dimension zero, namely $\vect{0} \in \Rset^0$. In the second case we exploit the fact that the first argument of the function point is optional.
Generator origin0_alt = point();
Example 4
The point $\vect{p}$ specified in Example 3 above can also be obtained with the following code, where we provide a non-default value for the second argument of the function point (the divisor):
Generator p = point(2*x + 0*y + 4*z, 2);
Obviously, the divisor can be usefully exploited to specify points having some non-integer (but rational) coordinates. For instance, the point $\vect{q} = (-1.5, 3.2, 2.1)^\transpose \in \Rset^3$ can be specified by the following code:
Generator q = point(-15*x + 32*y + 21*z, 10);
If a zero divisor is provided, an exception is thrown.
Example 5
Closure points are specified in the same way we defined points, but invoking their specific constructor function. For instance, the closure point $\vect{c} = (1, 0, 2)^\transpose \in \Rset^3$ is defined by
Generator c = closure_point(1*x + 0*y + 2*z);
For the particular case of the (only) closure point having space dimension zero, we can use any of the following:
Generator closure_origin0_alt = closure_point();
How to inspect a generator
Several methods are provided to examine a generator and extract all the encoded information: its space dimension, its type and the value of its integer coefficients.
Example 6
The following code shows how it is possible to access each single coefficient of a generator. If g1 is a point having coordinates $(a_0, \ldots, a_{n-1})^\transpose$, we construct the closure point g2 having coordinates $(a_0, 2 a_1, \ldots, (i+1)a_i, \ldots, n a_{n-1})^\transpose$.
if (g1.is_point()) {
cout << "Point g1: " << g1 << endl;
Linear_Expression e;
for (dimension_type i = g1.space_dimension(); i-- > 0; )
e += (i + 1) * g1.coefficient(Variable(i)) * Variable(i);
Generator g2 = closure_point(e, g1.divisor());
cout << "Closure point g2: " << g2 << endl;
}
else
cout << "Generator g1 is not a point." << endl;
Therefore, for the point
Generator g1 = point(2*x - y + 3*z, 2);
we would obtain the following output:
Point g1: p((2*A - B + 3*C)/2)
Closure point g2: cp((2*A - 2*B + 9*C)/2)
When working with (closure) points, be careful not to confuse the notion of coefficient with the notion of coordinate: these are equivalent only when the divisor of the (closure) point is 1.

Definition at line 285 of file Generator_defs.hh.

Member Typedef Documentation

The type of the (adapted) internal expression.

Definition at line 531 of file Generator_defs.hh.

Constructor & Destructor Documentation

Parma_Polyhedra_Library::Generator::Generator ( Representation  r = default_representation)
inlineexplicit

Constructs the point at the origin.

Definition at line 113 of file Generator_inlines.hh.

References Parma_Polyhedra_Library::Coefficient_one(), expr, OK(), Parma_Polyhedra_Library::Linear_Expression::set_inhomogeneous_term(), and space_dimension().

114  : expr(r),
118  PPL_ASSERT(space_dimension() == 0);
119  PPL_ASSERT(OK());
120 }
Linear_Expression expr
The linear expression encoding *this.
void set_inhomogeneous_term(Coefficient_traits::const_reference n)
Sets the inhomogeneous term of *this to n.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Generator.cc:432
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
Topology topology_
The topology of *this.
Parma_Polyhedra_Library::Generator::Generator ( const Generator g)
inline

Ordinary copy constructor. The representation of the new Generator will be the same as g.

Definition at line 167 of file Generator_inlines.hh.

168  : expr(g.expr),
169  kind_(g.kind_),
170  topology_(g.topology_) {
171 }
Linear_Expression expr
The linear expression encoding *this.
Topology topology_
The topology of *this.
Parma_Polyhedra_Library::Generator::Generator ( const Generator g,
Representation  r 
)
inline

Copy constructor with given representation.

Definition at line 174 of file Generator_inlines.hh.

References OK().

175  : expr(g.expr, r),
176  kind_(g.kind_),
177  topology_(g.topology_) {
178  // This does not assert OK() because it's called by OK().
179  PPL_ASSERT(OK());
180 }
Linear_Expression expr
The linear expression encoding *this.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Generator.cc:432
Topology topology_
The topology of *this.
Parma_Polyhedra_Library::Generator::Generator ( const Generator g,
dimension_type  space_dim 
)
inline

Copy constructor with given space dimension. The representation of the new Generator will be the same as g.

Definition at line 183 of file Generator_inlines.hh.

References OK(), and space_dimension().

184  : expr(g.expr, g.is_necessarily_closed() ? space_dim : (space_dim + 1)),
185  kind_(g.kind_),
186  topology_(g.topology_) {
187  PPL_ASSERT(OK());
188  PPL_ASSERT(space_dimension() == space_dim);
189 }
Linear_Expression expr
The linear expression encoding *this.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Generator.cc:432
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Topology topology_
The topology of *this.
Parma_Polyhedra_Library::Generator::Generator ( const Generator g,
dimension_type  space_dim,
Representation  r 
)
inline

Copy constructor with given representation and space dimension.

Definition at line 192 of file Generator_inlines.hh.

References OK(), and space_dimension().

194  : expr(g.expr, g.is_necessarily_closed() ? space_dim : (space_dim + 1), r),
195  kind_(g.kind_),
196  topology_(g.topology_) {
197  PPL_ASSERT(OK());
198  PPL_ASSERT(space_dimension() == space_dim);
199 }
Linear_Expression expr
The linear expression encoding *this.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Generator.cc:432
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Topology topology_
The topology of *this.
Parma_Polyhedra_Library::Generator::~Generator ( )
inline

Destructor.

Definition at line 202 of file Generator_inlines.hh.

202  {
203 }
Parma_Polyhedra_Library::Generator::Generator ( Linear_Expression e,
Type  type,
Topology  topology 
)
inlineprivate

Builds a generator of type type and topology topology, stealing the coefficients from e.

If the topology is NNC, the last dimension of e is used as the epsilon coefficient.

Definition at line 139 of file Generator_inlines.hh.

References CLOSURE_POINT, expr, kind_, LINE, LINE_OR_EQUALITY, Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, RAY_OR_POINT_OR_INEQUALITY, Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), Parma_Polyhedra_Library::Linear_Expression::space_dimension(), strong_normalize(), and swap().

140  : topology_(topology) {
141  PPL_ASSERT(type != CLOSURE_POINT || topology == NOT_NECESSARILY_CLOSED);
142  swap(expr, e);
145  }
146  if (type == LINE) {
148  }
149  else {
151  }
153 }
void set_space_dimension(dimension_type n)
Sets the dimension of the vector space enclosing *this to n .
Linear_Expression expr
The linear expression encoding *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void swap(Generator &x, Generator &y)
Swaps x with y.
Type type() const
Returns the generator type of *this.
void strong_normalize()
Strong normalization: ensures that different Generator objects represent different hyperplanes or hyp...
Topology topology() const
Returns the topological kind of *this.
Topology topology_
The topology of *this.
Parma_Polyhedra_Library::Generator::Generator ( Linear_Expression e,
Kind  kind,
Topology  topology 
)
inlineprivate

Definition at line 156 of file Generator_inlines.hh.

References expr, Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), Parma_Polyhedra_Library::Linear_Expression::space_dimension(), strong_normalize(), and swap().

157  : kind_(kind),
159  swap(expr, e);
162  }
164 }
void set_space_dimension(dimension_type n)
Sets the dimension of the vector space enclosing *this to n .
Linear_Expression expr
The linear expression encoding *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void swap(Generator &x, Generator &y)
Swaps x with y.
void strong_normalize()
Strong normalization: ensures that different Generator objects represent different hyperplanes or hyp...
Topology topology() const
Returns the topological kind of *this.
Topology topology_
The topology of *this.
Parma_Polyhedra_Library::Generator::Generator ( dimension_type  space_dim,
Kind  kind,
Topology  topology,
Representation  r = default_representation 
)
inlineprivate

Definition at line 123 of file Generator_inlines.hh.

References expr, is_necessarily_closed(), OK(), Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), and space_dimension().

125  : expr(r),
126  kind_(kind),
128  if (is_necessarily_closed()) {
129  expr.set_space_dimension(space_dim);
130  }
131  else {
132  expr.set_space_dimension(space_dim + 1);
133  }
134  PPL_ASSERT(space_dimension() == space_dim);
135  PPL_ASSERT(OK());
136 }
void set_space_dimension(dimension_type n)
Sets the dimension of the vector space enclosing *this to n .
Linear_Expression expr
The linear expression encoding *this.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Generator.cc:432
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Topology topology() const
Returns the topological kind of *this.
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
Topology topology_
The topology of *this.

Member Function Documentation

void Parma_Polyhedra_Library::Generator::ascii_dump ( ) const

Writes to std::cerr an ASCII representation of *this.

void Parma_Polyhedra_Library::Generator::ascii_dump ( std::ostream &  s) const
inline

Writes to s an ASCII representation of *this.

Definition at line 449 of file Generator_inlines.hh.

References Parma_Polyhedra_Library::Linear_Expression::ascii_dump(), CLOSURE_POINT, expr, is_necessarily_closed(), LINE, POINT, RAY, and type().

449  {
450 
451  expr.ascii_dump(s);
452 
453  s << " ";
454 
455  switch (type()) {
456  case Generator::LINE:
457  s << "L ";
458  break;
459  case Generator::RAY:
460  s << "R ";
461  break;
462  case Generator::POINT:
463  s << "P ";
464  break;
466  s << "C ";
467  break;
468  }
469  if (is_necessarily_closed()) {
470  s << "(C)";
471  }
472  else {
473  s << "(NNC)";
474  }
475  s << "\n";
476 }
Linear_Expression expr
The linear expression encoding *this.
void ascii_dump() const
Writes to std::cerr an ASCII representation of *this.
Type type() const
Returns the generator type of *this.
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
bool Parma_Polyhedra_Library::Generator::ascii_load ( std::istream &  s)
inline

Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise.

Definition at line 479 of file Generator_inlines.hh.

References Parma_Polyhedra_Library::Linear_Expression::ascii_load(), CLOSURE_POINT, expr, is_necessarily_closed(), is_not_necessarily_closed(), LINE, mark_as_necessarily_closed(), mark_as_not_necessarily_closed(), POINT, RAY, set_is_line(), set_is_ray_or_point(), and type().

479  {
480  std::string str;
481 
482  expr.ascii_load(s);
483 
484  if (!(s >> str)) {
485  return false;
486  }
487  if (str == "L") {
488  set_is_line();
489  }
490  else if (str == "R" || str == "P" || str == "C") {
492  }
493  else {
494  return false;
495  }
496 
497  std::string str2;
498 
499  if (!(s >> str2)) {
500  return false;
501  }
502  if (str2 == "(C)") {
504  // TODO: Avoid using the mark_as_*() methods if possible.
506  }
507  }
508  else {
509  if (str2 == "(NNC)") {
510  if (is_necessarily_closed()) {
511  // TODO: Avoid using the mark_as_*() methods if possible.
513  }
514  }
515  else {
516  return false;
517  }
518  }
519 
520  // Checking for equality of actual and declared types.
521  switch (type()) {
522  case Generator::LINE:
523  if (str != "L") {
524  return false;
525  }
526  break;
527  case Generator::RAY:
528  if (str != "R") {
529  return false;
530  }
531  break;
532  case Generator::POINT:
533  if (str != "P") {
534  return false;
535  }
536  break;
538  if (str != "C") {
539  return false;
540  }
541  break;
542  }
543 
544  return true;
545 }
bool is_not_necessarily_closed() const
Returns true if and only if the topology of *this row is not necessarily closed.
Linear_Expression expr
The linear expression encoding *this.
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
void set_is_ray_or_point()
Sets the Generator kind to RAY_OR_POINT_OR_INEQUALITY.
Type type() const
Returns the generator type of *this.
void mark_as_necessarily_closed()
Marks the epsilon dimension as a standard dimension.
void mark_as_not_necessarily_closed()
Marks the last dimension as the epsilon dimension.
void set_is_line()
Sets the Generator kind to LINE_OR_EQUALITY.
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
bool Parma_Polyhedra_Library::Generator::check_strong_normalized ( ) const
private

Returns true if and only if the coefficients are strongly normalized.

Definition at line 271 of file Generator.cc.

References Parma_Polyhedra_Library::compare(), and strong_normalize().

271  {
272  Generator tmp = *this;
273  tmp.strong_normalize();
274  return compare(*this, tmp) == 0;
275 }
friend int compare(const Generator &x, const Generator &y)
Generator(Representation r=default_representation)
Constructs the point at the origin.
PPL::Generator Parma_Polyhedra_Library::Generator::closure_point ( const Linear_Expression e = Linear_Expression::zero(),
Coefficient_traits::const_reference  d = Coefficient_one(),
Representation  r = default_representation 
)
static

Returns the closure point at e / d.

Both e and d are optional arguments, with default values Linear_Expression::zero() and Coefficient_one(), respectively.

Exceptions
std::invalid_argumentThrown if d is zero.

Definition at line 92 of file Generator.cc.

References expr, Parma_Polyhedra_Library::neg_assign(), Parma_Polyhedra_Library::Linear_Expression::normalize(), Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, POINT, and Parma_Polyhedra_Library::Linear_Expression::set_inhomogeneous_term().

Referenced by closure_point().

94  {
95  if (d == 0) {
96  throw std::invalid_argument("PPL::closure_point(e, d):\n"
97  "d == 0.");
98  }
99  Linear_Expression ec(e, r);
100  ec.set_inhomogeneous_term(d);
101 
103 
104  // If the divisor is negative, we negate it as well as
105  // all the coefficients of the point, because we want to preserve
106  // the invariant: the divisor of a point is strictly positive.
107  if (d < 0) {
108  neg_assign(g.expr);
109  }
110 
111  // Enforce normalization.
112  g.expr.normalize();
113  return g;
114 }
Generator(Representation r=default_representation)
Constructs the point at the origin.
void neg_assign(GMP_Integer &x)
PPL::Generator Parma_Polyhedra_Library::Generator::closure_point ( Representation  r)
static

Returns the closure point at the origin.

Definition at line 123 of file Generator.cc.

References Parma_Polyhedra_Library::Coefficient_one(), and Parma_Polyhedra_Library::Linear_Expression::zero().

123  {
125 }
static Generator closure_point(const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
Returns the closure point at e / d.
Definition: Generator.cc:92
static const Linear_Expression & zero()
Returns the (zero-dimension space) constant 0.
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
PPL::Generator Parma_Polyhedra_Library::Generator::closure_point ( const Linear_Expression e,
Representation  r 
)
static

Returns the closure point at e.

Definition at line 117 of file Generator.cc.

References Parma_Polyhedra_Library::Coefficient_one().

118  {
119  return closure_point(e, Coefficient_one(), r);
120 }
static Generator closure_point(const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
Returns the closure point at e / d.
Definition: Generator.cc:92
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
Coefficient_traits::const_reference Parma_Polyhedra_Library::Generator::coefficient ( Variable  v) const
inline

Returns the coefficient of v in *this.

Exceptions
std::invalid_argumentThrown if the index of v is greater than or equal to the space dimension of *this.

Definition at line 325 of file Generator_inlines.hh.

References Parma_Polyhedra_Library::Linear_Expression::coefficient(), expr, Parma_Polyhedra_Library::Variable::space_dimension(), space_dimension(), and throw_dimension_incompatible().

Referenced by Parma_Polyhedra_Library::Termination_Helpers::all_affine_ranking_functions_PR(), Parma_Polyhedra_Library::Termination_Helpers::all_affine_ranking_functions_PR_original(), Parma_Polyhedra_Library::Box< ITV >::Box(), Parma_Polyhedra_Library::MIP_Problem::choose_branching_variable(), Parma_Polyhedra_Library::Polyhedron::constrains(), Parma_Polyhedra_Library::MIP_Problem::is_mip_satisfiable(), l_m_distance_assign(), Parma_Polyhedra_Library::Octagonal_Shape< T >::Octagonal_Shape(), Parma_Polyhedra_Library::Termination_Helpers::one_affine_ranking_function_PR(), Parma_Polyhedra_Library::Termination_Helpers::one_affine_ranking_function_PR_original(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), and Parma_Polyhedra_Library::MIP_Problem::solve_mip().

325  {
326  if (v.space_dimension() > space_dimension()) {
327  throw_dimension_incompatible("coefficient(v)", "v", v);
328  }
329  return expr.coefficient(v);
330 }
Linear_Expression expr
The linear expression encoding *this.
Coefficient_traits::const_reference coefficient(Variable v) const
Returns the coefficient of v in *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void throw_dimension_incompatible(const char *method, const char *v_name, Variable v) const
Throw a std::invalid_argument exception containing the appropriate error message. ...
Definition: Generator.cc:37
Coefficient_traits::const_reference Parma_Polyhedra_Library::Generator::divisor ( ) const
inline

If *this is either a point or a closure point, returns its divisor.

Exceptions
std::invalid_argumentThrown if *this is neither a point nor a closure point.

Definition at line 333 of file Generator_inlines.hh.

References expr, Parma_Polyhedra_Library::Linear_Expression::inhomogeneous_term(), is_ray_or_point(), and throw_invalid_argument().

Referenced by Parma_Polyhedra_Library::Polyhedron::add_generator(), Parma_Polyhedra_Library::Termination_Helpers::all_affine_ranking_functions_PR(), Parma_Polyhedra_Library::Termination_Helpers::all_affine_ranking_functions_PR_original(), Parma_Polyhedra_Library::BD_Shape< T >::BD_Shape(), Parma_Polyhedra_Library::Box< ITV >::Box(), Parma_Polyhedra_Library::MIP_Problem::choose_branching_variable(), Parma_Polyhedra_Library::MIP_Problem::evaluate_objective_function(), Parma_Polyhedra_Library::MIP_Problem::is_mip_satisfiable(), l_m_distance_assign(), Parma_Polyhedra_Library::Polyhedron::map_space_dimensions(), Parma_Polyhedra_Library::Octagonal_Shape< T >::Octagonal_Shape(), Parma_Polyhedra_Library::Implementation::Termination::one_affine_ranking_function_MS(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::Grid::relation_with(), Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), and Parma_Polyhedra_Library::MIP_Problem::solve_mip().

333  {
334  Coefficient_traits::const_reference d = expr.inhomogeneous_term();
335  if (!is_ray_or_point() || d == 0) {
336  throw_invalid_argument("divisor()",
337  "*this is neither a point nor a closure point");
338  }
339  return d;
340 }
void throw_invalid_argument(const char *method, const char *reason) const
Throw a std::invalid_argument exception containing the appropriate error message. ...
Definition: Generator.cc:48
Linear_Expression expr
The linear expression encoding *this.
Coefficient_traits::const_reference inhomogeneous_term() const
Returns the inhomogeneous term of *this.
bool is_ray_or_point() const
Returns true if and only if *this is not a line.
Coefficient_traits::const_reference Parma_Polyhedra_Library::Generator::epsilon_coefficient ( ) const
inlineprivate

Returns the epsilon coefficient. The generator must be NNC.

Definition at line 343 of file Generator_inlines.hh.

References Parma_Polyhedra_Library::Linear_Expression::coefficient(), expr, is_not_necessarily_closed(), and Parma_Polyhedra_Library::Linear_Expression::space_dimension().

Referenced by Parma_Polyhedra_Library::Generator_System::add_corresponding_closure_points(), Parma_Polyhedra_Library::Generator_System::add_corresponding_points(), Parma_Polyhedra_Library::Polyhedron::positive_time_elapse_assign_impl(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_generators(), and type().

343  {
344  PPL_ASSERT(is_not_necessarily_closed());
345  return expr.coefficient(Variable(expr.space_dimension() - 1));
346 }
bool is_not_necessarily_closed() const
Returns true if and only if the topology of *this row is not necessarily closed.
Linear_Expression expr
The linear expression encoding *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Coefficient_traits::const_reference coefficient(Variable v) const
Returns the coefficient of v in *this.
Generator::expr_type Parma_Polyhedra_Library::Generator::expression ( ) const
inline
memory_size_type Parma_Polyhedra_Library::Generator::external_memory_in_bytes ( ) const
inline

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

Definition at line 357 of file Generator_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::external_memory_in_bytes().

Referenced by Parma_Polyhedra_Library::MIP_Problem::external_memory_in_bytes(), and total_memory_in_bytes().

357  {
359 }
Linear_Expression expr
The linear expression encoding *this.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
void Parma_Polyhedra_Library::Generator::fancy_print ( std::ostream &  s) const
private

A print function, with fancy, more human-friendly output.

This is used by operator<<().

Definition at line 303 of file Generator.cc.

References c, CLOSURE_POINT, LINE, Parma_Polyhedra_Library::neg_assign(), Parma_Polyhedra_Library::IO_Operators::operator<<(), POINT, PPL_DIRTY_TEMP_COEFFICIENT, and RAY.

Referenced by operator<<().

303  {
304  bool needed_divisor = false;
305  bool extra_parentheses = false;
306  const dimension_type num_variables = space_dimension();
307  const Generator::Type t = type();
308  switch (t) {
309  case Generator::LINE:
310  s << "l(";
311  break;
312  case Generator::RAY:
313  s << "r(";
314  break;
315  case Generator::POINT:
316  s << "p(";
317  goto any_point;
319  s << "c(";
320  any_point:
321  if (expr.inhomogeneous_term() != 1) {
322  needed_divisor = true;
323  if (!expr.all_zeroes(1, num_variables + 1)) {
324  extra_parentheses = true;
325  s << "(";
326  }
327  }
328  break;
329  }
330 
332  bool first = true;
333  for (Linear_Expression::const_iterator i = expr.begin(),
334  i_end = expr.lower_bound(Variable(num_variables)); i != i_end; ++i) {
335  c = *i;
336  if (!first) {
337  if (c > 0) {
338  s << " + ";
339  }
340  else {
341  s << " - ";
342  neg_assign(c);
343  }
344  }
345  else {
346  first = false;
347  }
348  if (c == -1) {
349  s << "-";
350  }
351  else if (c != 1) {
352  s << c << "*";
353  }
354  IO_Operators::operator<<(s, i.variable());
355  }
356  if (first) {
357  // A point or closure point in the origin.
358  s << 0;
359  }
360  if (extra_parentheses) {
361  s << ")";
362  }
363  if (needed_divisor) {
364  s << "/" << expr.inhomogeneous_term();
365  }
366  s << ")";
367 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
Linear_Expression expr
The linear expression encoding *this.
Coefficient_traits::const_reference inhomogeneous_term() const
Returns the inhomogeneous term of *this.
#define PPL_DIRTY_TEMP_COEFFICIENT(id)
Declare a local variable named id, of type Coefficient, and containing an unknown initial value...
std::ostream & operator<<(std::ostream &s, const Ask_Tell< D > &x)
bool all_zeroes(const Variables_Set &vars) const
Returns true if the coefficient of each variable in vars[i] is .
Type type() const
Returns the generator type of *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void neg_assign(GMP_Integer &x)
Coefficient c
Definition: PIP_Tree.cc:64
void Parma_Polyhedra_Library::Generator::finalize ( )
static

Finalizes the class.

Definition at line 292 of file Generator.cc.

Referenced by Parma_Polyhedra_Library::Init::~Init().

292  {
293  PPL_ASSERT(zero_dim_point_p != 0);
294  delete zero_dim_point_p;
295  zero_dim_point_p = 0;
296 
297  PPL_ASSERT(zero_dim_closure_point_p != 0);
300 }
static const Generator * zero_dim_closure_point_p
Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional...
static const Generator * zero_dim_point_p
Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional...
void Parma_Polyhedra_Library::Generator::initialize ( )
static

Initializes the class.

Definition at line 281 of file Generator.cc.

Referenced by Parma_Polyhedra_Library::Init::Init().

281  {
282  PPL_ASSERT(zero_dim_point_p == 0);
284  = new Generator(point());
285 
286  PPL_ASSERT(zero_dim_closure_point_p == 0);
288  = new Generator(closure_point());
289 }
static const Generator * zero_dim_closure_point_p
Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional...
static Generator closure_point(const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
Returns the closure point at e / d.
Definition: Generator.cc:92
Generator(Representation r=default_representation)
Constructs the point at the origin.
static Generator point(const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
Returns the point at e / d.
Definition: Generator.cc:57
static const Generator * zero_dim_point_p
Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional...
bool Parma_Polyhedra_Library::Generator::is_equal_to ( const Generator y) const

Returns true if *this is identical to y.

This is faster than is_equivalent_to(), but it may return `false' even for equivalent generators.

Definition at line 258 of file Generator.cc.

References expr, kind_, and topology_.

258  {
259  return expr.is_equal_to(y.expr) && kind_ == y.kind_
260  && topology_ == y.topology_;
261 }
Linear_Expression expr
The linear expression encoding *this.
bool is_equal_to(const Linear_Expression &x) const
Topology topology_
The topology of *this.
bool Parma_Polyhedra_Library::Generator::is_equivalent_to ( const Generator y) const

Returns true if and only if *this and y are equivalent generators.

Generators having different space dimensions are not equivalent.

Definition at line 226 of file Generator.cc.

References expr, expression(), Parma_Polyhedra_Library::Linear_Expression::is_equal_to(), is_necessarily_closed(), Parma_Polyhedra_Library::Linear_Expression::normalize(), space_dimension(), and type().

Referenced by operator!=(), and operator==().

226  {
227  const Generator& x = *this;
228  const dimension_type x_space_dim = x.space_dimension();
229  if (x_space_dim != y.space_dimension()) {
230  return false;
231  }
232 
233  const Type x_type = x.type();
234  if (x_type != y.type()) {
235  return false;
236  }
237 
238  if (x_type == POINT
239  && !(x.is_necessarily_closed() && y.is_necessarily_closed())) {
240  // Due to the presence of epsilon-coefficients, syntactically
241  // different points may actually encode the same generator.
242  // First, drop the epsilon-coefficient ...
243  Linear_Expression x_expr(x.expression());
244  Linear_Expression y_expr(y.expression());
245  // ... second, re-normalize ...
246  x_expr.normalize();
247  y_expr.normalize();
248  // ... and finally check for syntactic equality.
249  return x_expr.is_equal_to(y_expr);
250  }
251 
252  // Here the epsilon-coefficient, if present, is zero.
253  // It is sufficient to check for syntactic equality.
254  return x.expr.is_equal_to(y.expr);
255 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
Generator(Representation r=default_representation)
Constructs the point at the origin.
bool Parma_Polyhedra_Library::Generator::is_line_or_equality ( ) const
inlineprivate

Returns true if and only if *this row represents a line or an equality.

Definition at line 50 of file Generator_inlines.hh.

References kind_, and LINE_OR_EQUALITY.

Referenced by Parma_Polyhedra_Library::Polyhedron::BFT00_poly_hull_assign_if_exact(), compare(), and is_line().

bool Parma_Polyhedra_Library::Generator::is_matching_closure_point ( const Generator p) const
private

Returns true if and only if the closure point *this has the same coordinates of the point p.

It is assumed that *this is a closure point, p is a point and both topologies and space dimensions agree.

Definition at line 399 of file Generator.cc.

References Parma_Polyhedra_Library::exact_div_assign(), expr, Parma_Polyhedra_Library::gcd_assign(), Parma_Polyhedra_Library::Linear_Expression::inhomogeneous_term(), Parma_Polyhedra_Library::Linear_Expression::is_equal_to(), PPL_DIRTY_TEMP_COEFFICIENT, space_dimension(), Parma_Polyhedra_Library::Linear_Expression::space_dimension(), topology(), and type().

Referenced by Parma_Polyhedra_Library::Polyhedron::is_topologically_closed(), and Parma_Polyhedra_Library::Generator_System_const_iterator::skip_forward().

399  {
400  PPL_ASSERT(topology() == p.topology()
401  && space_dimension() == p.space_dimension()
402  && type() == CLOSURE_POINT
403  && p.type() == POINT);
404  const Generator& cp = *this;
405  if (cp.expr.inhomogeneous_term() == p.expr.inhomogeneous_term()) {
406  // Divisors are equal: we can simply compare coefficients
407  // (disregarding the epsilon coefficient).
408  return cp.expr.is_equal_to(p.expr, 1, cp.expr.space_dimension());
409  }
410  else {
411  // Divisors are different: divide them by their GCD
412  // to simplify the following computation.
414  gcd_assign(gcd, cp.expr.inhomogeneous_term(), p.expr.inhomogeneous_term());
415  const bool rel_prime = (gcd == 1);
416  PPL_DIRTY_TEMP_COEFFICIENT(cp_0_scaled);
417  PPL_DIRTY_TEMP_COEFFICIENT(p_0_scaled);
418  if (!rel_prime) {
419  exact_div_assign(cp_0_scaled, cp.expr.inhomogeneous_term(), gcd);
420  exact_div_assign(p_0_scaled, p.expr.inhomogeneous_term(), gcd);
421  }
422  const Coefficient& cp_div = rel_prime ? cp.expr.inhomogeneous_term() : cp_0_scaled;
423  const Coefficient& p_div = rel_prime ? p.expr.inhomogeneous_term() : p_0_scaled;
424  return cp.expr.is_equal_to(p.expr, p_div, cp_div, 1, cp.expr.space_dimension());
425  }
426 }
#define PPL_DIRTY_TEMP_COEFFICIENT(id)
Declare a local variable named id, of type Coefficient, and containing an unknown initial value...
void exact_div_assign(Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, const Checked_Number< T, Policy > &z)
Generator(Representation r=default_representation)
Constructs the point at the origin.
Type type() const
Returns the generator type of *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
Topology topology() const
Returns the topological kind of *this.
void gcd_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
bool Parma_Polyhedra_Library::Generator::is_necessarily_closed ( ) const
inlineprivate
bool Parma_Polyhedra_Library::Generator::is_not_necessarily_closed ( ) const
inlineprivate

Returns true if and only if the topology of *this row is not necessarily closed.

Definition at line 35 of file Generator_inlines.hh.

References Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, and topology().

Referenced by ascii_load(), epsilon_coefficient(), expression(), mark_as_necessarily_closed(), and set_epsilon_coefficient().

35  {
36  return (topology() == NOT_NECESSARILY_CLOSED);
37 }
Topology topology() const
Returns the topological kind of *this.
bool Parma_Polyhedra_Library::Generator::is_point ( ) const
inline

Returns true if and only if *this is a point.

Definition at line 305 of file Generator_inlines.hh.

References POINT, and type().

Referenced by Parma_Polyhedra_Library::Polyhedron::add_generator(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_combining_constraints(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_evolving_points(), Parma_Polyhedra_Library::Polyhedron::BHZ09_NNC_poly_hull_assign_if_exact(), Parma_Polyhedra_Library::Box< ITV >::Box(), Parma_Polyhedra_Library::MIP_Problem::evaluate_objective_function(), Parma_Polyhedra_Library::Polyhedron::frequency(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_image(), Parma_Polyhedra_Library::Polyhedron::is_topologically_closed(), Parma_Polyhedra_Library::Polyhedron::max_min(), Parma_Polyhedra_Library::Implementation::Termination::one_affine_ranking_function_MS(), Parma_Polyhedra_Library::Termination_Helpers::one_affine_ranking_function_PR(), Parma_Polyhedra_Library::Termination_Helpers::one_affine_ranking_function_PR_original(), Parma_Polyhedra_Library::Polyhedron::positive_time_elapse_assign_impl(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::Generator_System::relation_with(), Parma_Polyhedra_Library::Grid::relation_with(), Parma_Polyhedra_Library::Generator_System_const_iterator::skip_forward(), and Parma_Polyhedra_Library::Polyhedron::strongly_minimize_generators().

305  {
306  return type() == POINT;
307 }
Type type() const
Returns the generator type of *this.
bool Parma_Polyhedra_Library::Generator::is_ray ( ) const
inline

Returns true if and only if *this is a ray.

Definition at line 278 of file Generator_inlines.hh.

References is_line_or_ray(), and is_ray_or_point().

Referenced by Parma_Polyhedra_Library::Polyhedron::BHRZ03_evolving_rays(), and Parma_Polyhedra_Library::Box< ITV >::relation_with().

278  {
279  return is_ray_or_point() && is_line_or_ray();
280 }
bool is_line_or_ray() const
Returns true if and only if *this is a line or a ray.
bool is_ray_or_point() const
Returns true if and only if *this is not a line.
bool Parma_Polyhedra_Library::Generator::is_ray_or_point ( ) const
inlineprivate

Returns true if and only if *this is not a line.

Definition at line 268 of file Generator_inlines.hh.

References is_ray_or_point_or_inequality().

Referenced by divisor(), and is_ray().

268  {
270 }
bool is_ray_or_point_or_inequality() const
Returns true if and only if *this row represents a ray, a point or an inequality. ...
bool Parma_Polyhedra_Library::Generator::is_ray_or_point_or_inequality ( ) const
inlineprivate

Returns true if and only if *this row represents a ray, a point or an inequality.

Definition at line 55 of file Generator_inlines.hh.

References kind_, and RAY_OR_POINT_OR_INEQUALITY.

Referenced by is_ray_or_point().

PPL::Generator Parma_Polyhedra_Library::Generator::line ( const Linear_Expression e,
Representation  r = default_representation 
)
static

Returns the line of direction e.

Exceptions
std::invalid_argumentThrown if the homogeneous part of e represents the origin of the vector space.

Definition at line 143 of file Generator.cc.

References Parma_Polyhedra_Library::Linear_Expression::all_homogeneous_terms_are_zero(), LINE, Parma_Polyhedra_Library::NECESSARILY_CLOSED, and Parma_Polyhedra_Library::Linear_Expression::set_inhomogeneous_term().

Referenced by Parma_Polyhedra_Library::Polyhedron::add_generator(), line(), and Parma_Polyhedra_Library::Polyhedron::unconstrain().

143  {
144  // The origin of the space cannot be a line.
145  if (e.all_homogeneous_terms_are_zero()) {
146  throw std::invalid_argument("PPL::line(e):\n"
147  "e == 0, but the origin cannot be a line.");
148  }
149 
150  Linear_Expression ec(e, r);
151  ec.set_inhomogeneous_term(0);
153 
154  return g;
155 }
Generator(Representation r=default_representation)
Constructs the point at the origin.
void Parma_Polyhedra_Library::Generator::linear_combine ( const Generator y,
dimension_type  i 
)
private

Linearly combines *this with y so that i-th coefficient is 0.

Parameters
yThe Generator that will be combined with *this object;
iThe index of the coefficient that has to become $0$.

Computes a linear combination of *this and y having the i-th coefficient equal to $0$. Then it assigns the resulting Generator to *this and normalizes it.

Definition at line 207 of file Generator.cc.

References expr.

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

207  {
208  expr.linear_combine(y.expr, i);
210 }
Linear_Expression expr
The linear expression encoding *this.
void strong_normalize()
Strong normalization: ensures that different Generator objects represent different hyperplanes or hyp...
void linear_combine(const Linear_Expression &y, Variable v)
void Parma_Polyhedra_Library::Generator::m_swap ( Generator y)
inline

Swaps *this with y.

Definition at line 548 of file Generator_inlines.hh.

References expr, kind_, swap(), Parma_Polyhedra_Library::swap(), and topology_.

Referenced by swap().

548  {
549  using std::swap;
550  swap(expr, y.expr);
551  swap(kind_, y.kind_);
552  swap(topology_, y.topology_);
553 }
void swap(CO_Tree &x, CO_Tree &y)
Linear_Expression expr
The linear expression encoding *this.
void swap(Generator &x, Generator &y)
Swaps x with y.
Topology topology_
The topology of *this.
void Parma_Polyhedra_Library::Generator::mark_as_necessarily_closed ( )
inlineprivate

Marks the epsilon dimension as a standard dimension.

The row topology is changed to NECESSARILY_CLOSED, and the number of space dimensions is increased by 1.

Definition at line 91 of file Generator_inlines.hh.

References is_not_necessarily_closed(), Parma_Polyhedra_Library::NECESSARILY_CLOSED, and topology_.

Referenced by ascii_load().

91  {
92  PPL_ASSERT(is_not_necessarily_closed());
94 }
bool is_not_necessarily_closed() const
Returns true if and only if the topology of *this row is not necessarily closed.
Topology topology_
The topology of *this.
void Parma_Polyhedra_Library::Generator::mark_as_not_necessarily_closed ( )
inlineprivate

Marks the last dimension as the epsilon dimension.

The row topology is changed to NOT_NECESSARILY_CLOSED, and the number of space dimensions is decreased by 1.

Definition at line 97 of file Generator_inlines.hh.

References is_necessarily_closed(), Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, and topology_.

Referenced by ascii_load().

97  {
98  PPL_ASSERT(is_necessarily_closed());
100 }
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
Topology topology_
The topology of *this.
dimension_type Parma_Polyhedra_Library::Generator::max_space_dimension ( )
inlinestatic

Returns the maximum space dimension a Generator can handle.

Definition at line 224 of file Generator_inlines.hh.

References Parma_Polyhedra_Library::Linear_Expression::max_space_dimension().

224  {
226 }
static dimension_type max_space_dimension()
Returns the maximum space dimension a Linear_Expression can handle.
bool Parma_Polyhedra_Library::Generator::OK ( ) const

Checks if all the invariants are satisfied.

Definition at line 432 of file Generator.cc.

References strong_normalize().

Referenced by Parma_Polyhedra_Library::Polyhedron::BFT00_poly_hull_assign_if_exact(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_evolving_rays(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_image(), Generator(), Parma_Polyhedra_Library::Polyhedron::positive_time_elapse_assign_impl(), set_space_dimension(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_generators(), and Parma_Polyhedra_Library::Polyhedron::time_elapse_assign().

432  {
433  // Topology consistency checks.
435 #ifndef NDEBUG
436  std::cerr << "Generator has fewer coefficients than the minimum "
437  << "allowed by its topology."
438  << std::endl;
439 #endif
440  return false;
441  }
442 
443  // Normalization check.
444  Generator tmp = *this;
445  tmp.strong_normalize();
446  if (tmp != *this) {
447 #ifndef NDEBUG
448  std::cerr << "Generators should be strongly normalized!"
449  << std::endl;
450 #endif
451  return false;
452  }
453 
454  switch (type()) {
455  case LINE:
456  // Intentionally fall through.
457  case RAY:
458  if (expr.inhomogeneous_term() != 0) {
459 #ifndef NDEBUG
460  std::cerr << "Lines must have a zero inhomogeneous term!"
461  << std::endl;
462 #endif
463  return false;
464  }
465  if (!is_necessarily_closed() && epsilon_coefficient() != 0) {
466 #ifndef NDEBUG
467  std::cerr << "Lines and rays must have a zero coefficient "
468  << "for the epsilon dimension!"
469  << std::endl;
470 #endif
471  return false;
472  }
473  // The following test is correct, since we already checked
474  // that the epsilon coordinate is zero.
476 #ifndef NDEBUG
477  std::cerr << "The origin of the vector space cannot be a line or a ray!"
478  << std::endl;
479 #endif
480  return false;
481  }
482  break;
483 
484  case POINT:
485  if (expr.inhomogeneous_term() <= 0) {
486 #ifndef NDEBUG
487  std::cerr << "Points must have a positive divisor!"
488  << std::endl;
489 #endif
490  return false;
491  }
492  if (!is_necessarily_closed()) {
493  if (epsilon_coefficient() <= 0) {
494 #ifndef NDEBUG
495  std::cerr << "In the NNC topology, points must have epsilon > 0"
496  << std::endl;
497 #endif
498  return false;
499  }
500  }
501  break;
502 
503  case CLOSURE_POINT:
504  if (expr.inhomogeneous_term() <= 0) {
505 #ifndef NDEBUG
506  std::cerr << "Closure points must have a positive divisor!"
507  << std::endl;
508 #endif
509  return false;
510  }
511  break;
512  }
513 
514  // All tests passed.
515  return true;
516 }
bool is_not_necessarily_closed() const
Returns true if and only if the topology of *this row is not necessarily closed.
Linear_Expression expr
The linear expression encoding *this.
Coefficient_traits::const_reference inhomogeneous_term() const
Returns the inhomogeneous term of *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Generator(Representation r=default_representation)
Constructs the point at the origin.
Type type() const
Returns the generator type of *this.
bool all_homogeneous_terms_are_zero() const
Returns true if and only if all the homogeneous terms of *this are .
Coefficient_traits::const_reference epsilon_coefficient() const
Returns the epsilon coefficient. The generator must be NNC.
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
Generator & Parma_Polyhedra_Library::Generator::operator= ( const Generator g)
inline

Assignment operator.

Definition at line 206 of file Generator_inlines.hh.

References swap().

206  {
207  Generator tmp = g;
208  swap(*this, tmp);
209 
210  return *this;
211 }
void swap(Generator &x, Generator &y)
Swaps x with y.
Generator(Representation r=default_representation)
Constructs the point at the origin.
void Parma_Polyhedra_Library::Generator::permute_space_dimensions ( const std::vector< Variable > &  cycle)

Permutes the space dimensions of the generator.

Parameters
cycleA vector representing a cycle of the permutation according to which the space dimensions must be rearranged.

The cycle vector represents a cycle of a permutation of space dimensions. For example, the permutation $ \{ x_1 \mapsto x_2, x_2 \mapsto x_3, x_3 \mapsto x_1 \}$ can be represented by the vector containing $ x_1, x_2, x_3 $.

Definition at line 192 of file Generator.cc.

192  {
193  if (cycle.size() < 2) {
194  // No-op. No need to call sign_normalize().
195  return;
196  }
197 
199 
200  // *this is still normalized but may be not strongly normalized: sign
201  // normalization is necessary.
202  sign_normalize();
203  PPL_ASSERT(OK());
204 }
Linear_Expression expr
The linear expression encoding *this.
void permute_space_dimensions(const std::vector< Variable > &cycle)
Permutes the space dimensions of the expression.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Generator.cc:432
void sign_normalize()
Normalizes the sign of the coefficients so that the first non-zero (homogeneous) coefficient of a lin...
Definition: Generator.cc:264
PPL::Generator Parma_Polyhedra_Library::Generator::point ( const Linear_Expression e = Linear_Expression::zero(),
Coefficient_traits::const_reference  d = Coefficient_one(),
Representation  r = default_representation 
)
static

Returns the point at e / d.

Both e and d are optional arguments, with default values Linear_Expression::zero() and Coefficient_one(), respectively.

Exceptions
std::invalid_argumentThrown if d is zero.

Definition at line 57 of file Generator.cc.

References expr, Parma_Polyhedra_Library::NECESSARILY_CLOSED, Parma_Polyhedra_Library::neg_assign(), Parma_Polyhedra_Library::Linear_Expression::normalize(), POINT, and Parma_Polyhedra_Library::Linear_Expression::set_inhomogeneous_term().

Referenced by Parma_Polyhedra_Library::Polyhedron::add_generator(), Parma_Polyhedra_Library::Box< ITV >::max_min(), Parma_Polyhedra_Library::Grid::max_min(), and point().

59  {
60  if (d == 0) {
61  throw std::invalid_argument("PPL::point(e, d):\n"
62  "d == 0.");
63  }
64  Linear_Expression ec(e, r);
65  ec.set_inhomogeneous_term(d);
67 
68  // If the divisor is negative, we negate it as well as
69  // all the coefficients of the point, because we want to preserve
70  // the invariant: the divisor of a point is strictly positive.
71  if (d < 0) {
72  neg_assign(g.expr);
73  }
74 
75  // Enforce normalization.
76  g.expr.normalize();
77  return g;
78 }
Generator(Representation r=default_representation)
Constructs the point at the origin.
void neg_assign(GMP_Integer &x)
PPL::Generator Parma_Polyhedra_Library::Generator::point ( Representation  r)
static

Returns the origin.

Definition at line 87 of file Generator.cc.

References Parma_Polyhedra_Library::Coefficient_one(), and Parma_Polyhedra_Library::Linear_Expression::zero().

87  {
89 }
static Generator point(const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
Returns the point at e / d.
Definition: Generator.cc:57
static const Linear_Expression & zero()
Returns the (zero-dimension space) constant 0.
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
PPL::Generator Parma_Polyhedra_Library::Generator::point ( const Linear_Expression e,
Representation  r 
)
static

Returns the point at e.

Definition at line 81 of file Generator.cc.

References Parma_Polyhedra_Library::Coefficient_one().

82  {
83  return point(e, Coefficient_one(), r);
84 }
static Generator point(const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
Returns the point at e / d.
Definition: Generator.cc:57
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
void Parma_Polyhedra_Library::Generator::print ( ) const

Prints *this to std::cerr using operator<<.

PPL::Generator Parma_Polyhedra_Library::Generator::ray ( const Linear_Expression e,
Representation  r = default_representation 
)
static

Returns the ray of direction e.

Exceptions
std::invalid_argumentThrown if the homogeneous part of e represents the origin of the vector space.

Definition at line 128 of file Generator.cc.

References Parma_Polyhedra_Library::Linear_Expression::all_homogeneous_terms_are_zero(), Parma_Polyhedra_Library::NECESSARILY_CLOSED, RAY, and Parma_Polyhedra_Library::Linear_Expression::set_inhomogeneous_term().

Referenced by Parma_Polyhedra_Library::Polyhedron::add_generator(), and ray().

128  {
129  // The origin of the space cannot be a ray.
130  if (e.all_homogeneous_terms_are_zero()) {
131  throw std::invalid_argument("PPL::ray(e):\n"
132  "e == 0, but the origin cannot be a ray.");
133  }
134 
135  Linear_Expression ec(e, r);
136  ec.set_inhomogeneous_term(0);
138 
139  return g;
140 }
Generator(Representation r=default_representation)
Constructs the point at the origin.
bool Parma_Polyhedra_Library::Generator::remove_space_dimensions ( const Variables_Set vars)

Removes all the specified dimensions from the generator.

The space dimension of the variable with the highest space dimension in vars must be at most the space dimension of this.

If all dimensions with nonzero coefficients are removed from a ray or a line, it is changed into a point and this method returns false . Otherwise, it returns true .

Definition at line 168 of file Generator.cc.

References Parma_Polyhedra_Library::Variables_Set::space_dimension().

168  {
169  PPL_ASSERT(vars.space_dimension() <= space_dimension());
171 
173  // Become a point.
178  }
179 
180  PPL_ASSERT(OK());
181  return false;
182  }
183  else {
185  PPL_ASSERT(OK());
186  return true;
187  }
188 }
bool is_not_necessarily_closed() const
Returns true if and only if the topology of *this row is not necessarily closed.
Linear_Expression expr
The linear expression encoding *this.
bool is_line_or_ray() const
Returns true if and only if *this is a line or a ray.
void set_inhomogeneous_term(Coefficient_traits::const_reference n)
Sets the inhomogeneous term of *this to n.
void set_is_ray_or_point()
Sets the Generator kind to RAY_OR_POINT_OR_INEQUALITY.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Generator.cc:432
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
bool all_homogeneous_terms_are_zero() const
Returns true if and only if all the homogeneous terms of *this are .
void remove_space_dimensions(const Variables_Set &vars)
Removes all the specified dimensions from the expression.
void strong_normalize()
Strong normalization: ensures that different Generator objects represent different hyperplanes or hyp...
void set_epsilon_coefficient(Coefficient_traits::const_reference n)
Sets the epsilon coefficient to n. The generator must be NNC.
Representation Parma_Polyhedra_Library::Generator::representation ( ) const
inline

Returns the current representation of *this.

Definition at line 214 of file Generator_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::representation().

214  {
215  return expr.representation();
216 }
Linear_Expression expr
The linear expression encoding *this.
Representation representation() const
Returns the current representation of *this.
void Parma_Polyhedra_Library::Generator::set_epsilon_coefficient ( Coefficient_traits::const_reference  n)
inlineprivate

Sets the epsilon coefficient to n. The generator must be NNC.

Definition at line 350 of file Generator_inlines.hh.

References expr, is_not_necessarily_closed(), Parma_Polyhedra_Library::Linear_Expression::set_coefficient(), and Parma_Polyhedra_Library::Linear_Expression::space_dimension().

Referenced by Parma_Polyhedra_Library::Generator_System::add_corresponding_closure_points(), Parma_Polyhedra_Library::Generator_System::add_corresponding_points(), Parma_Polyhedra_Library::Generator_System::convert_into_non_necessarily_closed(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_image(), Parma_Polyhedra_Library::Generator_System::insert(), Parma_Polyhedra_Library::Generator_System::insert_pending(), and Parma_Polyhedra_Library::Polyhedron::strongly_minimize_generators().

350  {
351  PPL_ASSERT(is_not_necessarily_closed());
352  expr.set_coefficient(Variable(expr.space_dimension() - 1), n);
353 }
bool is_not_necessarily_closed() const
Returns true if and only if the topology of *this row is not necessarily closed.
Linear_Expression expr
The linear expression encoding *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void set_coefficient(Variable v, Coefficient_traits::const_reference n)
Sets the coefficient of v in *this to n.
void Parma_Polyhedra_Library::Generator::set_is_line ( )
inlineprivate

Sets the Generator kind to LINE_OR_EQUALITY.

Definition at line 315 of file Generator_inlines.hh.

References set_is_line_or_equality().

Referenced by ascii_load().

315  {
317 }
void set_is_line_or_equality()
Sets to LINE_OR_EQUALITY the kind of *this row.
void Parma_Polyhedra_Library::Generator::set_is_line_or_equality ( )
inlineprivate

Sets to LINE_OR_EQUALITY the kind of *this row.

Definition at line 65 of file Generator_inlines.hh.

References kind_, and LINE_OR_EQUALITY.

Referenced by set_is_line().

void Parma_Polyhedra_Library::Generator::set_is_ray_or_point ( )
inlineprivate

Sets the Generator kind to RAY_OR_POINT_OR_INEQUALITY.

Definition at line 320 of file Generator_inlines.hh.

References set_is_ray_or_point_or_inequality().

Referenced by ascii_load().

320  {
322 }
void set_is_ray_or_point_or_inequality()
Sets to RAY_OR_POINT_OR_INEQUALITY the kind of *this row.
void Parma_Polyhedra_Library::Generator::set_is_ray_or_point_or_inequality ( )
inlineprivate
void Parma_Polyhedra_Library::Generator::set_necessarily_closed ( )
inlineprivate

Sets to NECESSARILY_CLOSED the topological kind of *this row.

Definition at line 103 of file Generator_inlines.hh.

References Parma_Polyhedra_Library::NECESSARILY_CLOSED, and set_topology().

103  {
105 }
void set_topology(Topology x)
Sets to x the topological kind of *this row.
void Parma_Polyhedra_Library::Generator::set_not_necessarily_closed ( )
inlineprivate

Sets to NOT_NECESSARILY_CLOSED the topological kind of *this row.

Definition at line 108 of file Generator_inlines.hh.

References Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, and set_topology().

Referenced by Parma_Polyhedra_Library::Generator_System::insert().

108  {
110 }
void set_topology(Topology x)
Sets to x the topological kind of *this row.
void Parma_Polyhedra_Library::Generator::set_representation ( Representation  r)
inline

Converts *this to the specified representation.

Definition at line 219 of file Generator_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::set_representation().

219  {
221 }
Linear_Expression expr
The linear expression encoding *this.
void set_representation(Representation r)
Converts *this to the specified representation.
void Parma_Polyhedra_Library::Generator::set_space_dimension ( dimension_type  space_dim)
inline

Sets the dimension of the vector space enclosing *this to space_dim .

Definition at line 252 of file Generator_inlines.hh.

References OK(), and set_space_dimension_no_ok().

Referenced by Parma_Polyhedra_Library::Generator_System::insert(), and Parma_Polyhedra_Library::Generator_System::insert_pending().

252  {
253  set_space_dimension_no_ok(space_dim);
254  PPL_ASSERT(OK());
255 }
void set_space_dimension_no_ok(dimension_type space_dim)
bool OK() const
Checks if all the invariants are satisfied.
Definition: Generator.cc:432
void Parma_Polyhedra_Library::Generator::set_space_dimension_no_ok ( dimension_type  space_dim)
inlineprivate

Sets the dimension of the vector space enclosing *this to space_dim . Sets the space dimension of the rows in the system to space_dim .

This method is for internal use, it does *not* assert OK() at the end, so it can be used for invalid objects.

Definition at line 229 of file Generator_inlines.hh.

References expr, Parma_Polyhedra_Library::NECESSARILY_CLOSED, Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), space_dimension(), Parma_Polyhedra_Library::Linear_Expression::space_dimension(), strong_normalize(), Parma_Polyhedra_Library::Linear_Expression::swap_space_dimensions(), and topology().

Referenced by set_space_dimension().

229  {
230  const dimension_type old_expr_space_dim = expr.space_dimension();
231  if (topology() == NECESSARILY_CLOSED) {
232  expr.set_space_dimension(space_dim);
233  }
234  else {
235  const dimension_type old_space_dim = space_dimension();
236  if (space_dim > old_space_dim) {
237  expr.set_space_dimension(space_dim + 1);
238  expr.swap_space_dimensions(Variable(space_dim), Variable(old_space_dim));
239  }
240  else {
241  expr.swap_space_dimensions(Variable(space_dim), Variable(old_space_dim));
242  expr.set_space_dimension(space_dim + 1);
243  }
244  }
245  PPL_ASSERT(space_dimension() == space_dim);
246  if (expr.space_dimension() < old_expr_space_dim) {
248  }
249 }
void set_space_dimension(dimension_type n)
Sets the dimension of the vector space enclosing *this to n .
size_t dimension_type
An unsigned integral type for representing space dimensions.
Linear_Expression expr
The linear expression encoding *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void swap_space_dimensions(Variable v1, Variable v2)
Swaps the coefficients of the variables v1 and v2 .
void strong_normalize()
Strong normalization: ensures that different Generator objects represent different hyperplanes or hyp...
Topology topology() const
Returns the topological kind of *this.
void Parma_Polyhedra_Library::Generator::set_topology ( Topology  x)
inlineprivate

Sets to x the topological kind of *this row.

Definition at line 75 of file Generator_inlines.hh.

References expr, Parma_Polyhedra_Library::NECESSARILY_CLOSED, Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), Parma_Polyhedra_Library::Linear_Expression::space_dimension(), topology(), and topology_.

Referenced by Parma_Polyhedra_Library::Generator_System::insert_pending(), set_necessarily_closed(), and set_not_necessarily_closed().

75  {
76  if (topology() == x) {
77  return;
78  }
79  if (topology() == NECESSARILY_CLOSED) {
80  // Add a column for the epsilon dimension.
82  }
83  else {
84  PPL_ASSERT(expr.space_dimension() > 0);
86  }
87  topology_ = x;
88 }
void set_space_dimension(dimension_type n)
Sets the dimension of the vector space enclosing *this to n .
Linear_Expression expr
The linear expression encoding *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Topology topology() const
Returns the topological kind of *this.
Topology topology_
The topology of *this.
void Parma_Polyhedra_Library::Generator::shift_space_dimensions ( Variable  v,
dimension_type  n 
)
inline

Shift by n positions the coefficients of variables, starting from the coefficient of v. This increases the space dimension by n.

Definition at line 258 of file Generator_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::shift_space_dimensions().

258  {
260 }
Linear_Expression expr
The linear expression encoding *this.
void shift_space_dimensions(Variable v, dimension_type n)
void Parma_Polyhedra_Library::Generator::sign_normalize ( )
private

Normalizes the sign of the coefficients so that the first non-zero (homogeneous) coefficient of a line-or-equality is positive.

Definition at line 264 of file Generator.cc.

Referenced by Parma_Polyhedra_Library::Polyhedron::BFT00_poly_hull_assign_if_exact(), and strong_normalize().

264  {
265  if (is_line_or_equality()) {
267  }
268 }
Linear_Expression expr
The linear expression encoding *this.
bool is_line_or_equality() const
Returns true if and only if *this row represents a line or an equality.
dimension_type Parma_Polyhedra_Library::Generator::space_dimension ( ) const
inline

Returns the dimension of the vector space enclosing *this.

Definition at line 45 of file Generator_inlines.hh.

References expression(), and Parma_Polyhedra_Library::Expression_Hide_Last< T >::space_dimension().

Referenced by Parma_Polyhedra_Library::Polyhedron::add_generator(), coefficient(), Parma_Polyhedra_Library::MIP_Problem::evaluate_objective_function(), Generator(), Parma_Polyhedra_Library::Generator_System::insert(), Parma_Polyhedra_Library::Generator_System::insert_pending(), is_equivalent_to(), is_matching_closure_point(), Parma_Polyhedra_Library::MIP_Problem::is_satisfied(), Parma_Polyhedra_Library::MIP_Problem::is_saturated(), l_m_distance_assign(), Parma_Polyhedra_Library::Topology_Adjusted_Scalar_Product_Sign::operator()(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::Polyhedron::relation_with(), Parma_Polyhedra_Library::Grid::relation_with(), Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), Parma_Polyhedra_Library::Constraint_System::satisfies_all_constraints(), set_space_dimension_no_ok(), throw_dimension_incompatible(), Parma_Polyhedra_Library::Box< ITV >::throw_dimension_incompatible(), Parma_Polyhedra_Library::Octagonal_Shape< T >::throw_dimension_incompatible(), Parma_Polyhedra_Library::BD_Shape< T >::throw_dimension_incompatible(), Parma_Polyhedra_Library::Grid::throw_dimension_incompatible(), and Parma_Polyhedra_Library::Polyhedron::throw_dimension_incompatible().

45  {
46  return expression().space_dimension();
47 }
expr_type expression() const
Partial read access to the (adapted) internal expression.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void Parma_Polyhedra_Library::Generator::strong_normalize ( )
inlineprivate

Strong normalization: ensures that different Generator objects represent different hyperplanes or hyperspaces.

Applies both Generator::normalize() and Generator::sign_normalize().

Definition at line 367 of file Generator_inlines.hh.

References expr, Parma_Polyhedra_Library::Linear_Expression::normalize(), and sign_normalize().

Referenced by check_strong_normalized(), Generator(), OK(), and set_space_dimension_no_ok().

367  {
368  expr.normalize();
369  sign_normalize();
370 }
Linear_Expression expr
The linear expression encoding *this.
void sign_normalize()
Normalizes the sign of the coefficients so that the first non-zero (homogeneous) coefficient of a lin...
Definition: Generator.cc:264
void Parma_Polyhedra_Library::Generator::swap_space_dimensions ( Variable  v1,
Variable  v2 
)

Swaps the coefficients of the variables v1 and v2 .

Definition at line 158 of file Generator.cc.

References Parma_Polyhedra_Library::Variable::space_dimension().

158  {
159  PPL_ASSERT(v1.space_dimension() <= space_dimension());
160  PPL_ASSERT(v2.space_dimension() <= space_dimension());
161  expr.swap_space_dimensions(v1, v2);
162  // *this is still normalized but it may not be strongly normalized.
163  sign_normalize();
164  PPL_ASSERT(OK());
165 }
Linear_Expression expr
The linear expression encoding *this.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Generator.cc:432
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void sign_normalize()
Normalizes the sign of the coefficients so that the first non-zero (homogeneous) coefficient of a lin...
Definition: Generator.cc:264
void swap_space_dimensions(Variable v1, Variable v2)
Swaps the coefficients of the variables v1 and v2 .
void Parma_Polyhedra_Library::Generator::throw_dimension_incompatible ( const char *  method,
const char *  v_name,
Variable  v 
) const
private

Throw a std::invalid_argument exception containing the appropriate error message.

Definition at line 37 of file Generator.cc.

References Parma_Polyhedra_Library::Variable::space_dimension(), and space_dimension().

Referenced by coefficient().

39  {
40  std::ostringstream s;
41  s << "PPL::Generator::" << method << ":" << std::endl
42  << "this->space_dimension() == " << space_dimension() << ", "
43  << v_name << ".space_dimension() == " << v.space_dimension() << ".";
44  throw std::invalid_argument(s.str());
45 }
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void Parma_Polyhedra_Library::Generator::throw_invalid_argument ( const char *  method,
const char *  reason 
) const
private

Throw a std::invalid_argument exception containing the appropriate error message.

Definition at line 48 of file Generator.cc.

Referenced by divisor().

49  {
50  std::ostringstream s;
51  s << "PPL::Generator::" << method << ":" << std::endl
52  << reason << ".";
53  throw std::invalid_argument(s.str());
54 }
Topology Parma_Polyhedra_Library::Generator::topology ( ) const
inlineprivate
memory_size_type Parma_Polyhedra_Library::Generator::total_memory_in_bytes ( ) const
inline

Returns a lower bound to the total size in bytes of the memory occupied by *this.

Definition at line 362 of file Generator_inlines.hh.

References external_memory_in_bytes().

362  {
363  return sizeof(*this) + external_memory_in_bytes();
364 }
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
Generator::Type Parma_Polyhedra_Library::Generator::type ( ) const
inline

Returns the generator type of *this.

Definition at line 283 of file Generator_inlines.hh.

References CLOSURE_POINT, epsilon_coefficient(), is_line(), is_line_or_ray(), is_necessarily_closed(), LINE, POINT, and RAY.

Referenced by Parma_Polyhedra_Library::Polyhedron::add_generator(), Parma_Polyhedra_Library::Termination_Helpers::all_affine_ranking_functions_PR(), Parma_Polyhedra_Library::Termination_Helpers::all_affine_ranking_functions_PR_original(), ascii_dump(), ascii_load(), Parma_Polyhedra_Library::BD_Shape< T >::BD_Shape(), Parma_Polyhedra_Library::Box< ITV >::Box(), is_closure_point(), is_equivalent_to(), Parma_Polyhedra_Library::Polyhedron::is_included_in(), is_matching_closure_point(), is_point(), Parma_Polyhedra_Library::Polyhedron::map_space_dimensions(), Parma_Polyhedra_Library::Octagonal_Shape< T >::Octagonal_Shape(), Parma_Polyhedra_Library::Polyhedron::positive_time_elapse_assign_impl(), Parma_Polyhedra_Library::Generator_System::relation_with(), Parma_Polyhedra_Library::Generator_System::satisfied_by_all_generators(), Parma_Polyhedra_Library::Constraint_System::satisfies_all_constraints(), Parma_Polyhedra_Library::Polyhedron::simplify_using_context_assign(), and Parma_Polyhedra_Library::Polyhedron::time_elapse_assign().

283  {
284  if (is_line()) {
285  return LINE;
286  }
287  if (is_line_or_ray()) {
288  return RAY;
289  }
290  if (is_necessarily_closed()) {
291  return POINT;
292  }
293  else {
294  // Checking the value of the epsilon coefficient.
295  if (epsilon_coefficient() == 0) {
296  return CLOSURE_POINT;
297  }
298  else {
299  return POINT;
300  }
301  }
302 }
bool is_line_or_ray() const
Returns true if and only if *this is a line or a ray.
Coefficient_traits::const_reference epsilon_coefficient() const
Returns the epsilon coefficient. The generator must be NNC.
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
bool is_line() const
Returns true if and only if *this is a line.
const Generator & Parma_Polyhedra_Library::Generator::zero_dim_closure_point ( )
inlinestatic

Returns, as a closure point, the origin of the zero-dimensional space $\Rset^0$.

Definition at line 379 of file Generator_inlines.hh.

References zero_dim_closure_point_p.

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

379  {
380  PPL_ASSERT(zero_dim_closure_point_p != 0);
381  return *zero_dim_closure_point_p;
382 }
static const Generator * zero_dim_closure_point_p
Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional...
const Generator & Parma_Polyhedra_Library::Generator::zero_dim_point ( )
inlinestatic

Returns the origin of the zero-dimensional space $\Rset^0$.

Definition at line 373 of file Generator_inlines.hh.

References zero_dim_point_p.

Referenced by Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_project(), and Parma_Polyhedra_Library::Generator_System::initialize().

373  {
374  PPL_ASSERT(zero_dim_point_p != 0);
375  return *zero_dim_point_p;
376 }
static const Generator * zero_dim_point_p
Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional...

Friends And Related Function Documentation

Generator closure_point ( const Linear_Expression e,
Coefficient_traits::const_reference  d,
Representation  r 
)
related

Definition at line 417 of file Generator_inlines.hh.

References closure_point().

419  {
420  return Generator::closure_point(e, d, r);
421 }
static Generator closure_point(const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
Returns the closure point at e / d.
Definition: Generator.cc:92
Generator closure_point ( Representation  r)
related

Definition at line 425 of file Generator_inlines.hh.

References closure_point().

425  {
426  return Generator::closure_point(r);
427 }
static Generator closure_point(const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
Returns the closure point at e / d.
Definition: Generator.cc:92
Generator closure_point ( const Linear_Expression e,
Representation  r 
)
related

Definition at line 431 of file Generator_inlines.hh.

References closure_point().

432  {
433  return Generator::closure_point(e, r);
434 }
static Generator closure_point(const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
Returns the closure point at e / d.
Definition: Generator.cc:92
Generator closure_point ( Representation  r)
related
int compare ( const Generator x,
const Generator y 
)
related

The basic comparison function.

Returns
The returned absolute value can be $0$, $1$ or $2$.
Parameters
xA row of coefficients;
yAnother row.

Compares x and y, where x and y may be of different size, in which case the "missing" coefficients are assumed to be zero. The comparison is such that:

  1. equalities are smaller than inequalities;
  2. lines are smaller than points and rays;
  3. the ordering is lexicographic;
  4. the positions compared are, in decreasing order of significance, 1, 2, ..., size(), 0;
  5. the result is negative, zero, or positive if x is smaller than, equal to, or greater than y, respectively;
  6. when x and y are different, the absolute value of the result is 1 if the difference is due to the coefficient in position 0; it is 2 otherwise.

When x and y represent the hyper-planes associated to two equality or inequality constraints, the coefficient at 0 is the known term. In this case, the return value can be characterized as follows:

  • -2, if x is smaller than y and they are not parallel;
  • -1, if x is smaller than y and they are parallel;
  • 0, if x and y are equal;
  • +1, if y is smaller than x and they are parallel;
  • +2, if y is smaller than x and they are not parallel.
int compare ( const Generator x,
const Generator y 
)
related

Definition at line 214 of file Generator.cc.

References Parma_Polyhedra_Library::compare(), expr, and is_line_or_equality().

214  {
215  const bool x_is_line_or_equality = x.is_line_or_equality();
216  const bool y_is_line_or_equality = y.is_line_or_equality();
217  if (x_is_line_or_equality != y_is_line_or_equality) {
218  // Equalities (lines) precede inequalities (ray/point).
219  return y_is_line_or_equality ? 2 : -2;
220  }
221 
222  return compare(x.expr, y.expr);
223 }
friend int compare(const Generator &x, const Generator &y)
int compare ( const Generator x,
const Generator y 
)
friend
template<typename Temp , typename To >
bool euclidean_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
const Rounding_Dir  dir,
Temp &  tmp0,
Temp &  tmp1,
Temp &  tmp2 
)
related

Definition at line 659 of file Generator_inlines.hh.

665  {
666  return l_m_distance_assign<Euclidean_Distance_Specialization<Temp> >
667  (r, x, y, dir, tmp0, tmp1, tmp2);
668 }
template<typename Temp , typename To >
bool euclidean_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
const Rounding_Dir  dir 
)
related

Definition at line 673 of file Generator_inlines.hh.

References PPL_DIRTY_TEMP.

676  {
677  typedef Checked_Number<Temp, Extended_Number_Policy> Checked_Temp;
678  PPL_DIRTY_TEMP(Checked_Temp, tmp0);
679  PPL_DIRTY_TEMP(Checked_Temp, tmp1);
680  PPL_DIRTY_TEMP(Checked_Temp, tmp2);
681  return euclidean_distance_assign(r, x, y, dir, tmp0, tmp1, tmp2);
682 }
#define PPL_DIRTY_TEMP(T, id)
bool euclidean_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, Rounding_Dir dir)
Computes the euclidean distance between x and y.
template<typename To >
bool euclidean_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
const Rounding_Dir  dir 
)
related

Definition at line 687 of file Generator_inlines.hh.

690  {
691  return euclidean_distance_assign<To, To>(r, x, y, dir);
692 }
template<typename To >
bool euclidean_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
Rounding_Dir  dir 
)
related

Computes the euclidean distance between x and y.

If the euclidean distance between x and y is defined, stores an approximation of it into r and returns true; returns false otherwise.

The direction of the approximation is specified by dir.

All computations are performed using variables of type Checked_Number<To, Extended_Number_Policy>.

Note
Distances are only defined between generators that are points and/or closure points; for rays or lines, false is returned.
template<typename Temp , typename To >
bool euclidean_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
Rounding_Dir  dir,
Temp &  tmp0,
Temp &  tmp1,
Temp &  tmp2 
)
related

Computes the euclidean distance between x and y.

If the euclidean distance between x and y is defined, stores an approximation of it into r and returns true; returns false otherwise.

The direction of the approximation is specified by dir.

All computations are performed using the temporary variables tmp0, tmp1 and tmp2.

Note
Distances are only defined between generators that are points and/or closure points; for rays or lines, false is returned.
friend class Expression_Adapter< Generator >
friend

Definition at line 730 of file Generator_defs.hh.

template<typename Temp , typename To >
bool l_infinity_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
const Rounding_Dir  dir,
Temp &  tmp0,
Temp &  tmp1,
Temp &  tmp2 
)
related

Definition at line 697 of file Generator_inlines.hh.

703  {
704  return l_m_distance_assign<L_Infinity_Distance_Specialization<Temp> >
705  (r, x, y, dir, tmp0, tmp1, tmp2);
706 }
template<typename Temp , typename To >
bool l_infinity_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
const Rounding_Dir  dir 
)
related

Definition at line 711 of file Generator_inlines.hh.

References PPL_DIRTY_TEMP.

714  {
715  typedef Checked_Number<Temp, Extended_Number_Policy> Checked_Temp;
716  PPL_DIRTY_TEMP(Checked_Temp, tmp0);
717  PPL_DIRTY_TEMP(Checked_Temp, tmp1);
718  PPL_DIRTY_TEMP(Checked_Temp, tmp2);
719  return l_infinity_distance_assign(r, x, y, dir, tmp0, tmp1, tmp2);
720 }
bool l_infinity_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, Rounding_Dir dir)
Computes the distance between x and y.
#define PPL_DIRTY_TEMP(T, id)
template<typename To >
bool l_infinity_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
const Rounding_Dir  dir 
)
related

Definition at line 725 of file Generator_inlines.hh.

728  {
729  return l_infinity_distance_assign<To, To>(r, x, y, dir);
730 }
template<typename To >
bool l_infinity_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
Rounding_Dir  dir 
)
related

Computes the $L_\infty$ distance between x and y.

If the $L_\infty$ distance between x and y is defined, stores an approximation of it into r and returns true; returns false otherwise.

The direction of the approximation is specified by dir.

All computations are performed using variables of type Checked_Number<To, Extended_Number_Policy>.

Note
Distances are only defined between generators that are points and/or closure points; for rays or lines, false is returned.
template<typename Temp , typename To >
bool l_infinity_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
Rounding_Dir  dir 
)
related

Computes the $L_\infty$ distance between x and y.

If the $L_\infty$ distance between x and y is defined, stores an approximation of it into r and returns true; returns false otherwise.

The direction of the approximation is specified by dir.

All computations are performed using variables of type Checked_Number<Temp, Extended_Number_Policy>.

Note
Distances are only defined between generators that are points and/or closure points; for rays or lines, false is returned.
template<typename Temp , typename To >
bool l_infinity_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
Rounding_Dir  dir,
Temp &  tmp0,
Temp &  tmp1,
Temp &  tmp2 
)
related

Computes the $L_\infty$ distance between x and y.

If the $L_\infty$ distance between x and y is defined, stores an approximation of it into r and returns true; returns false otherwise.

The direction of the approximation is specified by dir.

All computations are performed using the temporary variables tmp0, tmp1 and tmp2.

Note
Distances are only defined between generators that are points and/or closure points; for rays or lines, false is returned.
template<typename Specialization , typename Temp , typename To >
bool l_m_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
const Rounding_Dir  dir,
Temp &  tmp0,
Temp &  tmp1,
Temp &  tmp2 
)
related

Definition at line 560 of file Generator_inlines.hh.

References Parma_Polyhedra_Library::assign_r(), coefficient(), Parma_Polyhedra_Library::combine(), divisor(), Parma_Polyhedra_Library::finalize(), Parma_Polyhedra_Library::inverse(), is_line_or_ray(), Parma_Polyhedra_Library::maybe_assign(), PPL_DIRTY_TEMP, Parma_Polyhedra_Library::ROUND_NOT_NEEDED, Parma_Polyhedra_Library::Boundary_NS::sgn(), and space_dimension().

566  {
567  // Generator kind compatibility check: we only compute distances
568  // between (closure) points.
569  if (x.is_line_or_ray() || y.is_line_or_ray()) {
570  return false;
571  }
572  const dimension_type x_space_dim = x.space_dimension();
573  // Dimension-compatibility check.
574  if (x_space_dim != y.space_dimension()) {
575  return false;
576  }
577 
578  // All zero-dim generators have distance zero.
579  if (x_space_dim == 0) {
580  assign_r(r, 0, ROUND_NOT_NEEDED);
581  return true;
582  }
583 
584  PPL_DIRTY_TEMP(mpq_class, x_coord);
585  PPL_DIRTY_TEMP(mpq_class, y_coord);
586  PPL_DIRTY_TEMP(mpq_class, x_div);
587  PPL_DIRTY_TEMP(mpq_class, y_div);
588  assign_r(x_div, x.divisor(), ROUND_NOT_NEEDED);
589  assign_r(y_div, y.divisor(), ROUND_NOT_NEEDED);
590 
591  assign_r(tmp0, 0, ROUND_NOT_NEEDED);
592  // TODO: This loop can be optimized more, if needed.
593  for (dimension_type i = x_space_dim; i-- > 0; ) {
594  assign_r(x_coord, x.coefficient(Variable(i)), ROUND_NOT_NEEDED);
595  div_assign_r(x_coord, x_coord, x_div, ROUND_NOT_NEEDED);
596  assign_r(y_coord, y.coefficient(Variable(i)), ROUND_NOT_NEEDED);
597  div_assign_r(y_coord, y_coord, y_div, ROUND_NOT_NEEDED);
598  const Temp* tmp1p;
599  const Temp* tmp2p;
600 
601  if (x_coord > y_coord) {
602  maybe_assign(tmp1p, tmp1, x_coord, dir);
603  maybe_assign(tmp2p, tmp2, y_coord, inverse(dir));
604  }
605  else {
606  maybe_assign(tmp1p, tmp1, y_coord, dir);
607  maybe_assign(tmp2p, tmp2, x_coord, inverse(dir));
608  }
609  sub_assign_r(tmp1, *tmp1p, *tmp2p, dir);
610  PPL_ASSERT(sgn(tmp1) >= 0);
611  Specialization::combine(tmp0, tmp1, dir);
612  }
613  Specialization::finalize(tmp0, dir);
614  assign_r(r, tmp0, dir);
615  return true;
616 }
Enable_If< Is_Native_Or_Checked< To >::value &&Is_Special< From >::value, Result >::type assign_r(To &to, const From &, Rounding_Dir dir)
size_t dimension_type
An unsigned integral type for representing space dimensions.
Rounding_Dir inverse(Rounding_Dir dir)
void finalize()
Finalizes the library.
Definition: initializer.hh:60
#define PPL_DIRTY_TEMP(T, id)
I_Result combine(Result l, Result u)
int sgn(Boundary_Type type, const T &x, const Info &info)
Result maybe_assign(const To *&top, To &tmp, const From &from, Rounding_Dir dir)
Assigns to top a pointer to a location that holds the conversion, according to dir, of from to type To. When necessary, and only when necessary, the variable tmp is used to hold the result of conversion.
Generator line ( const Linear_Expression e,
Representation  r 
)
related

Definition at line 386 of file Generator_inlines.hh.

References line().

386  {
387  return Generator::line(e, r);
388 }
static Generator line(const Linear_Expression &e, Representation r=default_representation)
Returns the line of direction e.
Definition: Generator.cc:143
friend class Linear_System< Generator >
friend

Definition at line 731 of file Generator_defs.hh.

bool operator!= ( const Generator x,
const Generator y 
)
related

Definition at line 444 of file Generator_inlines.hh.

References is_equivalent_to().

444  {
445  return !x.is_equivalent_to(y);
446 }
bool operator!= ( const Generator x,
const Generator y 
)
related

Returns true if and only if x is not equivalent to y.

std::ostream & operator<< ( std::ostream &  s,
const Generator g 
)
related

Output operator.

std::ostream & operator<< ( std::ostream &  s,
const Generator g 
)
related

Definition at line 371 of file Generator.cc.

References fancy_print().

371  {
372  g.fancy_print(s);
373  return s;
374 }
std::ostream & operator<< ( std::ostream &  s,
const Generator::Type t 
)
related

Definition at line 378 of file Generator.cc.

References CLOSURE_POINT, LINE, POINT, and RAY.

378  {
379  const char* n = 0;
380  switch (t) {
381  case Generator::LINE:
382  n = "LINE";
383  break;
384  case Generator::RAY:
385  n = "RAY";
386  break;
387  case Generator::POINT:
388  n = "POINT";
389  break;
391  n = "CLOSURE_POINT";
392  break;
393  }
394  s << n;
395  return s;
396 }
std::ostream & operator<< ( std::ostream &  s,
const Generator::Type t 
)
related

Output operator.

bool operator== ( const Generator x,
const Generator y 
)
related

Definition at line 438 of file Generator_inlines.hh.

References is_equivalent_to().

438  {
439  return x.is_equivalent_to(y);
440 }
bool operator== ( const Generator x,
const Generator y 
)
related

Returns true if and only if x is equivalent to y.

Definition at line 735 of file Generator_defs.hh.

Definition at line 736 of file Generator_defs.hh.

friend class Parma_Polyhedra_Library::Grid
friend

Definition at line 742 of file Generator_defs.hh.

Definition at line 740 of file Generator_defs.hh.

std::ostream& Parma_Polyhedra_Library::IO_Operators::operator<< ( std::ostream &  s,
const Generator g 
)
friend

Definition at line 741 of file Generator_defs.hh.

Definition at line 738 of file Generator_defs.hh.

Definition at line 732 of file Generator_defs.hh.

friend class Parma_Polyhedra_Library::Topology_Adjusted_Scalar_Product_Assign
friend

Definition at line 734 of file Generator_defs.hh.

Generator point ( const Linear_Expression e,
Coefficient_traits::const_reference  d,
Representation  r 
)
related

Definition at line 398 of file Generator_inlines.hh.

References point().

399  {
400  return Generator::point(e, d, r);
401 }
static Generator point(const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
Returns the point at e / d.
Definition: Generator.cc:57
Generator point ( Representation  r)
related

Definition at line 405 of file Generator_inlines.hh.

References point().

405  {
406  return Generator::point(r);
407 }
static Generator point(const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
Returns the point at e / d.
Definition: Generator.cc:57
Generator point ( const Linear_Expression e,
Representation  r 
)
related

Definition at line 411 of file Generator_inlines.hh.

References point().

411  {
412  return Generator::point(e, r);
413 }
static Generator point(const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
Returns the point at e / d.
Definition: Generator.cc:57
Generator point ( Representation  r)
related
Generator ray ( const Linear_Expression e,
Representation  r 
)
related

Definition at line 392 of file Generator_inlines.hh.

References ray().

392  {
393  return Generator::ray(e, r);
394 }
static Generator ray(const Linear_Expression &e, Representation r=default_representation)
Returns the ray of direction e.
Definition: Generator.cc:128
template<typename Temp , typename To >
bool rectilinear_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
const Rounding_Dir  dir,
Temp &  tmp0,
Temp &  tmp1,
Temp &  tmp2 
)
related

Definition at line 621 of file Generator_inlines.hh.

627  {
628  return l_m_distance_assign<Rectilinear_Distance_Specialization<Temp> >
629  (r, x, y, dir, tmp0, tmp1, tmp2);
630 }
template<typename Temp , typename To >
bool rectilinear_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
const Rounding_Dir  dir 
)
related

Definition at line 635 of file Generator_inlines.hh.

References PPL_DIRTY_TEMP.

638  {
639  typedef Checked_Number<Temp, Extended_Number_Policy> Checked_Temp;
640  PPL_DIRTY_TEMP(Checked_Temp, tmp0);
641  PPL_DIRTY_TEMP(Checked_Temp, tmp1);
642  PPL_DIRTY_TEMP(Checked_Temp, tmp2);
643  return rectilinear_distance_assign(r, x, y, dir, tmp0, tmp1, tmp2);
644 }
bool rectilinear_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const Generator &x, const Generator &y, Rounding_Dir dir)
Computes the rectilinear (or Manhattan) distance between x and y.
#define PPL_DIRTY_TEMP(T, id)
template<typename To >
bool rectilinear_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
const Rounding_Dir  dir 
)
related

Definition at line 649 of file Generator_inlines.hh.

652  {
653  return rectilinear_distance_assign<To, To>(r, x, y, dir);
654 }
template<typename To >
bool rectilinear_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
Rounding_Dir  dir 
)
related

Computes the rectilinear (or Manhattan) distance between x and y.

If the rectilinear distance between x and y is defined, stores an approximation of it into r and returns true; returns false otherwise.

The direction of the approximation is specified by dir.

All computations are performed using variables of type Checked_Number<To, Extended_Number_Policy>.

Note
Distances are only defined between generators that are points and/or closure points; for rays or lines, false is returned.
template<typename Temp , typename To >
bool rectilinear_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
Rounding_Dir  dir 
)
related

Computes the rectilinear (or Manhattan) distance between x and y.

If the rectilinear distance between x and y is defined, stores an approximation of it into r and returns true; returns false otherwise.

The direction of the approximation is specified by dir.

All computations are performed using variables of type Checked_Number<Temp, Extended_Number_Policy>.

Note
Distances are only defined between generators that are points and/or closure points; for rays or lines, false is returned.
template<typename Temp , typename To >
bool rectilinear_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
Rounding_Dir  dir,
Temp &  tmp0,
Temp &  tmp1,
Temp &  tmp2 
)
related

Computes the rectilinear (or Manhattan) distance between x and y.

If the rectilinear distance between x and y is defined, stores an approximation of it into r and returns true; returns false otherwise.

The direction of the approximation is specified by dir.

All computations are performed using the temporary variables tmp0, tmp1 and tmp2.

Note
Distances are only defined between generators that are points and/or closure points; for rays or lines, false is returned.
template<typename Temp , typename To >
bool rectilinear_distance_assign ( Checked_Number< To, Extended_Number_Policy > &  r,
const Generator x,
const Generator y,
Rounding_Dir  dir 
)
related

Computes the euclidean distance between x and y.

If the euclidean distance between x and y is defined, stores an approximation of it into r and returns true; returns false otherwise.

The direction of the approximation is specified by dir.

All computations are performed using variables of type Checked_Number<Temp, Extended_Number_Policy>.

Note
Distances are only defined between generators that are points and/or closure points; for rays or lines, false is returned.
void swap ( Generator x,
Generator y 
)
related

Swaps x with y.

Referenced by Generator(), m_swap(), and operator=().

void swap ( Generator x,
Generator y 
)
related

Definition at line 734 of file Generator_inlines.hh.

References m_swap().

734  {
735  x.m_swap(y);
736 }

Member Data Documentation

const Representation Parma_Polyhedra_Library::Generator::default_representation = SPARSE
static

The representation used for new Generators.

Note
The copy constructor and the copy constructor with specified size use the representation of the original object, so that it is indistinguishable from the original object.

Definition at line 294 of file Generator_defs.hh.

Linear_Expression Parma_Polyhedra_Library::Generator::expr
private

The linear expression encoding *this.

Definition at line 543 of file Generator_defs.hh.

Referenced by Parma_Polyhedra_Library::Generator_System::add_corresponding_closure_points(), Parma_Polyhedra_Library::Generator_System::add_corresponding_points(), Parma_Polyhedra_Library::Generator_System::affine_image(), ascii_dump(), ascii_load(), Parma_Polyhedra_Library::Scalar_Products::assign(), Parma_Polyhedra_Library::Polyhedron::BFT00_poly_hull_assign_if_exact(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_evolving_rays(), closure_point(), coefficient(), compare(), Parma_Polyhedra_Library::Generator_System::convert_into_non_necessarily_closed(), divisor(), epsilon_coefficient(), Parma_Polyhedra_Library::MIP_Problem::evaluate_objective_function(), expression(), external_memory_in_bytes(), Parma_Polyhedra_Library::Polyhedron::frequency(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_image(), Generator(), Parma_Polyhedra_Library::Scalar_Products::homogeneous_assign(), Parma_Polyhedra_Library::Scalar_Products::homogeneous_sign(), Parma_Polyhedra_Library::Generator_System::insert(), Parma_Polyhedra_Library::Generator_System::insert_pending(), is_equal_to(), is_equivalent_to(), is_line_or_ray(), is_matching_closure_point(), linear_combine(), m_swap(), Parma_Polyhedra_Library::Polyhedron::max_min(), Parma_Polyhedra_Library::Topology_Adjusted_Scalar_Product_Sign::operator()(), point(), Parma_Polyhedra_Library::Polyhedron::positive_time_elapse_assign_impl(), Parma_Polyhedra_Library::Scalar_Products::reduced_sign(), Parma_Polyhedra_Library::Generator_System::remove_invalid_lines_and_rays(), representation(), set_epsilon_coefficient(), set_representation(), set_space_dimension_no_ok(), set_topology(), shift_space_dimensions(), Parma_Polyhedra_Library::Scalar_Products::sign(), strong_normalize(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_generators(), and Parma_Polyhedra_Library::Polyhedron::time_elapse_assign().

Kind Parma_Polyhedra_Library::Generator::kind_
private
Topology Parma_Polyhedra_Library::Generator::topology_
private

The topology of *this.

Definition at line 549 of file Generator_defs.hh.

Referenced by is_equal_to(), m_swap(), mark_as_necessarily_closed(), mark_as_not_necessarily_closed(), set_topology(), and topology().

const PPL::Generator * Parma_Polyhedra_Library::Generator::zero_dim_closure_point_p = 0
staticprivate

Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional space $\Rset^0$, as a closure point.

Definition at line 561 of file Generator_defs.hh.

Referenced by zero_dim_closure_point().

const PPL::Generator * Parma_Polyhedra_Library::Generator::zero_dim_point_p = 0
staticprivate

Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional space $\Rset^0$.

Definition at line 555 of file Generator_defs.hh.

Referenced by zero_dim_point().


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