Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members | Related Pages

Parma_Polyhedra_Library::Generator Class Reference

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

List of all members.

Public Types

enum  Type { LINE, RAY, POINT, CLOSURE_POINT }
 The generator type. More...

Public Member Functions

 Generator (const Generator &g)
 Ordinary copy-constructor.
 ~Generator ()
 Destructor.
Generatoroperator= (const Generator &g)
 Assignment operator.
dimension_type space_dimension () const
 Returns the dimension of the vector space enclosing *this.
Type type () const
 Returns the generator type of *this.
bool is_line () const
 Returns true if and only if *this is a line.
bool is_ray () const
 Returns true if and only if *this is a ray.
bool is_point () const
 Returns true if and only if *this is a point.
bool is_closure_point () const
 Returns true if and only if *this is a closure point.
const Integercoefficient (Variable v) const
 Returns the coefficient of v in *this.
const Integerdivisor () const
 If *this is either a point or a closure point, returns its divisor.
bool OK () const
 Checks if all the invariants are satisfied.

Static Public Member Functions

Generator line (const LinExpression &e)
 Shorthand for Generator Generator::line(const LinExpression& e).
Generator ray (const LinExpression &e)
 Shorthand for Generator Generator::ray(const LinExpression& e).
Generator point (const LinExpression &e=LinExpression::zero(), const Integer &d=Integer_one())
 Shorthand for Generator Generator::point(const LinExpression& e, const Integer& d).
Generator closure_point (const LinExpression &e=LinExpression::zero(), const Integer &d=Integer_one())
 Shorthand for Generator Generator::closure_point(const LinExpression& e, const Integer& d).
const Generatorzero_dim_point ()
 Returns the origin of the zero-dimensional space $\Rset^0$.
const Generatorzero_dim_closure_point ()
 Returns, as a closure point, the origin of the zero-dimensional space $\Rset^0$.

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &s, const Generator &g)
 Output operator.
void swap (Parma_Polyhedra_Library::Generator &x, Parma_Polyhedra_Library::Generator &y)
 Specializes std::swap.


Detailed Description

A line, ray, point or closure point.

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

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 Integer 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 = Generator::zero_dim_point();
  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
Closures 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 = Generator::zero_dim_closure_point();
  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;
    LinExpression e;
    for (int i = g1.space_dimension() - 1; i >= 0; i--)
      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.


Member Enumeration Documentation

enum Parma_Polyhedra_Library::Generator::Type
 

The generator type.

Enumeration values:
LINE  The generator is a line.
RAY  The generator is a ray.
POINT  The generator is a point.
CLOSURE_POINT  The generator is a closure point.


Member Function Documentation

Generator line const LinExpression e  )  [static]
 

Shorthand for Generator Generator::line(const LinExpression& e).

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

Generator ray const LinExpression e  )  [static]
 

Shorthand for Generator Generator::ray(const LinExpression& e).

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

Generator point const LinExpression e = LinExpression::zero(),
const Integer d = Integer_one()
[static]
 

Shorthand for Generator Generator::point(const LinExpression& e, const Integer& d).

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

Exceptions:
std::invalid_argument Thrown if d is zero.

Generator closure_point const LinExpression e = LinExpression::zero(),
const Integer d = Integer_one()
[static]
 

Shorthand for Generator Generator::closure_point(const LinExpression& e, const Integer& d).

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

Exceptions:
std::invalid_argument Thrown if d is zero.

const Integer& Parma_Polyhedra_Library::Generator::coefficient Variable  v  )  const
 

Returns the coefficient of v in *this.

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

const Integer& Parma_Polyhedra_Library::Generator::divisor  )  const
 

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

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


Generated on Fri Aug 20 20:04:45 2004 for PPL by doxygen 1.3.8-20040812