#include <Generator.defs.hh>
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. | |
Generator & | operator= (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_line_or_ray () const |
Returns true if and only if *this is a line or 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. | |
Coefficient_traits::const_reference | coefficient (Variable v) const |
Returns the coefficient of v in *this . | |
Coefficient_traits::const_reference | divisor () const |
If *this is either a point or a closure point, returns its divisor. | |
memory_size_type | total_memory_in_bytes () const |
Returns a lower bound to the total size in bytes of the memory occupied by *this . | |
memory_size_type | external_memory_in_bytes () const |
Returns the size in bytes of the memory managed by *this . | |
bool | is_equivalent_to (const Generator &y) const |
Returns true if and only if *this and y are equivalent generators. | |
void | ascii_dump () const |
Writes to std::cerr an ASCII representation of *this . | |
void | ascii_dump (std::ostream &s) const |
Writes to s an ASCII representation of *this . | |
void | print () const |
Prints *this to std::cerr using operator<< . | |
bool | ascii_load (std::istream &s) |
Loads from s an ASCII representation (as produced by ascii_dump) and sets *this accordingly. Returns true if successful, false otherwise. | |
bool | OK () const |
Checks if all the invariants are satisfied. | |
void | swap (Generator &y) |
Swaps *this with y . | |
Static Public Member Functions | |
static Generator | line (const Linear_Expression &e) |
Returns the line of direction e . | |
static Generator | ray (const Linear_Expression &e) |
Returns the ray of direction e . | |
static Generator | point (const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one()) |
Returns the point at e / d . | |
static Generator | closure_point (const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one()) |
Returns the closure point at e / d . | |
static dimension_type | max_space_dimension () |
Returns the maximum space dimension a Generator can handle. | |
static const Generator & | zero_dim_point () |
Returns the origin of the zero-dimensional space ![]() | |
static const Generator & | zero_dim_closure_point () |
Returns, as a closure point, the origin of the zero-dimensional space ![]() | |
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 . | |
void | throw_dimension_incompatible (const char *method, const char *name_var, Variable v) const |
Throw a std::invalid_argument exception containing the appropriate error message. | |
void | throw_invalid_argument (const char *method, const char *reason) const |
Throw a std::invalid_argument exception containing the appropriate error message. | |
friend | Parma_Polyhedra_Library::Linear_Expression::Linear_Expression (const Generator &g) |
Generator (const Generator &g, dimension_type dimension) | |
Copy-constructor with given space dimension. | |
bool | is_ray_or_point () const |
Returns true if and only if *this is not a line. | |
void | set_is_line () |
Sets the Linear_Row kind to LINE_OR_EQUALITY . | |
void | set_is_ray_or_point () |
Sets the Linear_Row kind to RAY_OR_POINT_OR_INEQUALITY . | |
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 . | |
Generator () | |
Default constructor: private and not implemented. | |
Friends | |
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 |
class | Parma_Polyhedra_Library::Grid_Generator_System |
std::ostream & | operator<< (std::ostream &s, const Generator &g) |
Output operator. | |
Related Functions | |
(Note that these are not member functions.) | |
void | swap (Parma_Polyhedra_Library::Generator &x, Parma_Polyhedra_Library::Generator &y) |
Specializes std::swap . | |
bool | operator== (const Generator &x, const Generator &y) |
Returns true if and only if x is equivalent to y . | |
bool | operator!= (const Generator &x, const Generator &y) |
Returns true if and only if x is not equivalent to y . | |
std::ostream & | operator<< (std::ostream &s, const Generator::Type &t) |
Output operator. |
An object of the class Generator is one of the following:
where is the dimension of the space and, for points and closure points,
is the divisor.
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.x
, y
and z
are defined as follows: Variable x(0); Variable y(1); Variable z(2);
point
is optional. Generator origin0 = Generator::zero_dim_point(); Generator origin0_alt = point();
point
(the divisor): Obviously, the divisor can be usefully exploited to specify points having some non-integer (but rational) coordinates. For instance, the point Generator c = closure_point(1*x + 0*y + 2*z);
Generator closure_origin0 = Generator::zero_dim_closure_point(); Generator closure_origin0_alt = closure_point();
g1
is a point having coordinates g2
having coordinates if (g1.is_point()) { cout << "Point g1: " << g1 << endl; Linear_Expression 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;
Point g1: p((2*A - B + 3*C)/2) Closure point g2: cp((2*A - 2*B + 9*C)/2)
Definition at line 241 of file Generator.defs.hh.
The generator type.
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. |
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 300 of file Generator.defs.hh.
00300 { 00302 LINE, 00304 RAY, 00306 POINT, 00308 CLOSURE_POINT 00309 };
Parma_Polyhedra_Library::Generator::Generator | ( | const Generator & | g | ) | [inline] |
Ordinary copy-constructor.
Definition at line 38 of file Generator.inlines.hh.
00039 : Linear_Row(g) { 00040 }
Parma_Polyhedra_Library::Generator::~Generator | ( | ) | [inline] |
Parma_Polyhedra_Library::Generator::Generator | ( | Linear_Expression & | e, | |
Type | type, | |||
Topology | topology | |||
) | [inline, private] |
Builds a generator of type type
and topology topology
, stealing the coefficients from e
.
Definition at line 29 of file Generator.inlines.hh.
References CLOSURE_POINT, Parma_Polyhedra_Library::Linear_Row::flags(), LINE, Parma_Polyhedra_Library::Linear_Row::LINE_OR_EQUALITY, Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, Parma_Polyhedra_Library::Linear_Row::RAY_OR_POINT_OR_INEQUALITY, and Parma_Polyhedra_Library::Linear_Row::swap().
00029 { 00030 assert(type != CLOSURE_POINT || topology == NOT_NECESSARILY_CLOSED); 00031 Linear_Row::swap(e); 00032 flags() = Flags(topology, (type == LINE 00033 ? LINE_OR_EQUALITY 00034 : RAY_OR_POINT_OR_INEQUALITY)); 00035 }
Parma_Polyhedra_Library::Generator::Generator | ( | const Generator & | g, | |
dimension_type | dimension | |||
) | [inline, private] |
Copy-constructor with given space dimension.
Definition at line 43 of file Generator.inlines.hh.
00044 : Linear_Row(g, dimension, dimension) { 00045 }
Parma_Polyhedra_Library::Generator::Generator | ( | ) | [private] |
Default constructor: private and not implemented.
PPL::Generator Parma_Polyhedra_Library::Generator::line | ( | const Linear_Expression & | e | ) | [inline, static] |
Returns the line of direction e
.
Shorthand for Generator Generator::line(const Linear_Expression& e).
std::invalid_argument | Thrown if the homogeneous part of e represents the origin of the vector space. |
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 162 of file Generator.inlines.hh.
Referenced by Parma_Polyhedra_Library::Polyhedron::add_generator().
00162 { 00163 return Generator::line(e); 00164 }
PPL::Generator Parma_Polyhedra_Library::Generator::ray | ( | const Linear_Expression & | e | ) | [inline, static] |
Returns the ray of direction e
.
Shorthand for Generator Generator::ray(const Linear_Expression& e).
std::invalid_argument | Thrown if the homogeneous part of e represents the origin of the vector space. |
Definition at line 168 of file Generator.inlines.hh.
Referenced by Parma_Polyhedra_Library::Polyhedron::add_generator().
00168 { 00169 return Generator::ray(e); 00170 }
PPL::Generator Parma_Polyhedra_Library::Generator::point | ( | const Linear_Expression & | e = Linear_Expression::zero() , |
|
Coefficient_traits::const_reference | d = Coefficient_one() | |||
) | [inline, static] |
Returns the point at e
/ d
.
Shorthand for Generator Generator::point(const Linear_Expression& e, Coefficient_traits::const_reference d).
Both e
and d
are optional arguments, with default values Linear_Expression::zero() and Coefficient_one(), respectively.
std::invalid_argument | Thrown if d is zero. |
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 174 of file Generator.inlines.hh.
Referenced by Parma_Polyhedra_Library::Polyhedron::add_generator(), and zero_dim_point().
00174 { 00175 return Generator::point(e, d); 00176 }
PPL::Generator Parma_Polyhedra_Library::Generator::closure_point | ( | const Linear_Expression & | e = Linear_Expression::zero() , |
|
Coefficient_traits::const_reference | d = Coefficient_one() | |||
) | [inline, static] |
Returns the closure point at e
/ d
.
Shorthand for Generator Generator::closure_point(const Linear_Expression& e, Coefficient_traits::const_reference d).
Both e
and d
are optional arguments, with default values Linear_Expression::zero() and Coefficient_one(), respectively.
std::invalid_argument | Thrown if d is zero. |
Definition at line 180 of file Generator.inlines.hh.
Referenced by zero_dim_closure_point().
00181 { 00182 return Generator::closure_point(e, d); 00183 }
Assignment operator.
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 52 of file Generator.inlines.hh.
References Parma_Polyhedra_Library::Row::operator=().
Referenced by Parma_Polyhedra_Library::Grid_Generator::operator=().
00052 { 00053 Linear_Row::operator=(g); 00054 return *this; 00055 }
dimension_type Parma_Polyhedra_Library::Generator::max_space_dimension | ( | ) | [inline, static] |
Returns the maximum space dimension a Generator can handle.
Reimplemented from Parma_Polyhedra_Library::Linear_Row.
Definition at line 58 of file Generator.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::max_space_dimension().
00058 { 00059 return Linear_Row::max_space_dimension(); 00060 }
dimension_type Parma_Polyhedra_Library::Generator::space_dimension | ( | ) | const [inline] |
Returns the dimension of the vector space enclosing *this
.
Reimplemented from Parma_Polyhedra_Library::Linear_Row.
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 63 of file Generator.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::space_dimension().
Referenced by Parma_Polyhedra_Library::Polyhedron::add_generator(), coefficient(), Parma_Polyhedra_Library::LP_Problem::evaluate_objective_function(), Parma_Polyhedra_Library::Generator_System::insert(), Parma_Polyhedra_Library::Generator_System::insert_pending(), is_equivalent_to(), is_matching_closure_point(), Parma_Polyhedra_Library::LP_Problem::OK(), Parma_Polyhedra_Library::Topology_Adjusted_Scalar_Product_Sign::operator()(), Parma_Polyhedra_Library::Polyhedron::relation_with(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), Parma_Polyhedra_Library::Constraint_System::satisfies_all_constraints(), Parma_Polyhedra_Library::Grid_Generator::space_dimension(), Parma_Polyhedra_Library::Polyhedron::throw_dimension_incompatible(), throw_dimension_incompatible(), and Parma_Polyhedra_Library::BD_Shape< T >::throw_dimension_incompatible().
00063 { 00064 return Linear_Row::space_dimension(); 00065 }
Generator::Type Parma_Polyhedra_Library::Generator::type | ( | ) | const [inline] |
Returns the generator type of *this
.
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 88 of file Generator.inlines.hh.
References CLOSURE_POINT, is_line(), is_line_or_ray(), Parma_Polyhedra_Library::Linear_Row::is_necessarily_closed(), LINE, POINT, RAY, and Parma_Polyhedra_Library::Row::size().
Referenced by Parma_Polyhedra_Library::Polyhedron::add_generator(), Parma_Polyhedra_Library::Generator_System::ascii_dump(), Parma_Polyhedra_Library::BD_Shape< T >::BD_Shape(), generator_term(), 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(), OK(), 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::shrink_bounding_box(), and Parma_Polyhedra_Library::Grid_Generator::type().
00088 { 00089 if (is_line()) 00090 return LINE; 00091 if (is_line_or_ray()) 00092 return RAY; 00093 if (is_necessarily_closed()) 00094 return POINT; 00095 else { 00096 // Checking the value of the epsilon coefficient. 00097 const Generator& g = *this; 00098 return (g[size() - 1] == 0) ? CLOSURE_POINT : POINT; 00099 } 00100 }
bool Parma_Polyhedra_Library::Generator::is_line | ( | ) | const [inline] |
Returns true
if and only if *this
is a line.
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 68 of file Generator.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::is_line_or_equality().
Referenced by Parma_Polyhedra_Library::Polyhedron::add_recycled_generators(), Parma_Polyhedra_Library::Polyhedron::bounds(), Parma_Polyhedra_Library::Polyhedron::is_included_in(), Parma_Polyhedra_Library::Grid_Generator::is_line(), Parma_Polyhedra_Library::Polyhedron::max_min(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), Parma_Polyhedra_Library::Generator_System::satisfied_by_all_generators(), Parma_Polyhedra_Library::Constraint_System::satisfies_all_constraints(), and type().
00068 { 00069 return is_line_or_equality(); 00070 }
bool Parma_Polyhedra_Library::Generator::is_ray | ( | ) | const [inline] |
Returns true
if and only if *this
is a ray.
Definition at line 83 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::Grid_Generator::is_parameter().
00083 { 00084 return is_ray_or_point() && is_line_or_ray(); 00085 }
bool Parma_Polyhedra_Library::Generator::is_line_or_ray | ( | ) | const [inline] |
Returns true
if and only if *this
is a line or a ray.
Definition at line 78 of file Generator.inlines.hh.
Referenced by Parma_Polyhedra_Library::Generator_System::add_corresponding_points(), Parma_Polyhedra_Library::Polyhedron::bounds(), Parma_Polyhedra_Library::Generator_System::insert(), Parma_Polyhedra_Library::Generator_System::insert_pending(), Parma_Polyhedra_Library::Grid_Generator::is_line_or_parameter(), is_ray(), Parma_Polyhedra_Library::Polyhedron::max_min(), Parma_Polyhedra_Library::Generator_System::remove_invalid_lines_and_rays(), and type().
bool Parma_Polyhedra_Library::Generator::is_point | ( | ) | const [inline] |
Returns true
if and only if *this
is a point.
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 103 of file Generator.inlines.hh.
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::LP_Problem::evaluate_objective_function(), Parma_Polyhedra_Library::Grid_Generator::is_point(), Parma_Polyhedra_Library::Polyhedron::is_topologically_closed(), Parma_Polyhedra_Library::Polyhedron::max_min(), Parma_Polyhedra_Library::Generator_System::relation_with(), and Parma_Polyhedra_Library::Generator_System::const_iterator::skip_forward().
bool Parma_Polyhedra_Library::Generator::is_closure_point | ( | ) | const [inline] |
Returns true
if and only if *this
is a closure point.
Definition at line 108 of file Generator.inlines.hh.
References CLOSURE_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::is_topologically_closed(), Parma_Polyhedra_Library::Polyhedron::max_min(), and Parma_Polyhedra_Library::Generator_System::const_iterator::skip_forward().
00108 { 00109 return type() == CLOSURE_POINT; 00110 }
Coefficient_traits::const_reference Parma_Polyhedra_Library::Generator::coefficient | ( | Variable | v | ) | const [inline] |
Returns the coefficient of v
in *this
.
std::invalid_argument | Thrown if the index of v is greater than or equal to the space dimension of *this . |
Definition at line 123 of file Generator.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::coefficient(), Parma_Polyhedra_Library::Variable::id(), space_dimension(), Parma_Polyhedra_Library::Variable::space_dimension(), and throw_dimension_incompatible().
Referenced by Parma_Polyhedra_Library::BD_Shape< T >::BD_Shape(), Parma_Polyhedra_Library::BHRZ03_Certificate::BHRZ03_Certificate(), Parma_Polyhedra_Library::BHRZ03_Certificate::compare(), Parma_Polyhedra_Library::LP_Problem::evaluate_objective_function(), Parma_Polyhedra_Library::Polyhedron::map_space_dimensions(), Parma_Polyhedra_Library::Grid::map_space_dimensions(), ppl_Generator_coefficient(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), and Parma_Polyhedra_Library::Polyhedron::shrink_bounding_box().
00123 { 00124 if (v.space_dimension() > space_dimension()) 00125 throw_dimension_incompatible("coefficient(v)", "v", v); 00126 return Linear_Row::coefficient(v.id()); 00127 }
Coefficient_traits::const_reference Parma_Polyhedra_Library::Generator::divisor | ( | ) | const [inline] |
If *this
is either a point or a closure point, returns its divisor.
std::invalid_argument | Thrown if *this is neither a point nor a closure point. |
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 130 of file Generator.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::inhomogeneous_term(), is_ray_or_point(), and throw_invalid_argument().
Referenced by Parma_Polyhedra_Library::Polyhedron::add_generator(), Parma_Polyhedra_Library::BD_Shape< T >::BD_Shape(), Parma_Polyhedra_Library::LP_Problem::evaluate_objective_function(), generator_term(), Parma_Polyhedra_Library::Polyhedron::map_space_dimensions(), ppl_Generator_divisor(), and Parma_Polyhedra_Library::Polyhedron::shrink_bounding_box().
00130 { 00131 Coefficient_traits::const_reference d = Linear_Row::inhomogeneous_term(); 00132 if (!is_ray_or_point() || d == 0) 00133 throw_invalid_argument("divisor()", 00134 "*this is neither a point nor a closure point"); 00135 return d; 00136 }
const Generator & Parma_Polyhedra_Library::Generator::zero_dim_point | ( | ) | [inline, static] |
Returns the origin of the zero-dimensional space .
Definition at line 149 of file Generator.inlines.hh.
References point().
Referenced by Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_project(), and Parma_Polyhedra_Library::Generator_System::zero_dim_univ().
const Generator & Parma_Polyhedra_Library::Generator::zero_dim_closure_point | ( | ) | [inline, static] |
Returns, as a closure point, the origin of the zero-dimensional space .
Definition at line 155 of file Generator.inlines.hh.
References closure_point().
Referenced by Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_project().
00155 { 00156 static const Generator zdcp = closure_point(); 00157 return zdcp; 00158 }
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
.
Reimplemented from Parma_Polyhedra_Library::Row.
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 144 of file Generator.inlines.hh.
References Parma_Polyhedra_Library::Checked::total_memory_in_bytes().
00144 { 00145 return Linear_Row::total_memory_in_bytes(); 00146 }
memory_size_type Parma_Polyhedra_Library::Generator::external_memory_in_bytes | ( | ) | const [inline] |
Returns the size in bytes of the memory managed by *this
.
Reimplemented from Parma_Polyhedra_Library::Row.
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 139 of file Generator.inlines.hh.
References Parma_Polyhedra_Library::Checked::external_memory_in_bytes().
Referenced by Parma_Polyhedra_Library::LP_Problem::external_memory_in_bytes().
00139 { 00140 return Linear_Row::external_memory_in_bytes(); 00141 }
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 125 of file Generator.cc.
References Parma_Polyhedra_Library::Linear_Row::is_necessarily_closed(), Parma_Polyhedra_Library::Row::normalize(), POINT, space_dimension(), and type().
Referenced by operator!=(), and operator==().
00125 { 00126 const Generator& x = *this; 00127 const dimension_type x_space_dim = x.space_dimension(); 00128 if (x_space_dim != y.space_dimension()) 00129 return false; 00130 00131 const Type x_type = x.type(); 00132 if (x_type != y.type()) 00133 return false; 00134 00135 if (x_type == POINT 00136 && !(x.is_necessarily_closed() && y.is_necessarily_closed())) { 00137 // Due to the presence of epsilon-coefficients, syntactically 00138 // different points may actually encode the same generator. 00139 // First, drop the epsilon-coefficient ... 00140 Linear_Expression x_expr(x); 00141 Linear_Expression y_expr(y); 00142 // ... second, re-normalize ... 00143 x_expr.normalize(); 00144 y_expr.normalize(); 00145 // ... and finally check for syntactic equality. 00146 for (dimension_type i = x_space_dim + 1; i-- > 0; ) 00147 if (x_expr[i] != y_expr[i]) 00148 return false; 00149 return true; 00150 } 00151 00152 // Here the epsilon-coefficient, if present, is zero. 00153 // It is sufficient to check for syntactic equality. 00154 for (dimension_type i = x_space_dim + 1; i-- > 0; ) 00155 if (x[i] != y[i]) 00156 return false; 00157 return true; 00158 }
void Parma_Polyhedra_Library::Generator::ascii_dump | ( | ) | const |
Writes to std::cerr
an ASCII representation of *this
.
Reimplemented from Parma_Polyhedra_Library::Linear_Row.
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Referenced by Parma_Polyhedra_Library::LP_Problem::ascii_dump(), and Parma_Polyhedra_Library::Grid_Generator::ascii_dump().
void Parma_Polyhedra_Library::Generator::ascii_dump | ( | std::ostream & | s | ) | const [inline] |
Writes to s
an ASCII representation of *this
.
Reimplemented from Parma_Polyhedra_Library::Linear_Row.
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 198 of file Generator.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::ascii_dump().
00198 { 00199 Linear_Row::ascii_dump(s); 00200 }
void Parma_Polyhedra_Library::Generator::print | ( | ) | const |
Prints *this
to std::cerr
using operator<<
.
Reimplemented from Parma_Polyhedra_Library::Linear_Row.
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
bool Parma_Polyhedra_Library::Generator::ascii_load | ( | std::istream & | s | ) | [inline] |
Loads from s
an ASCII representation (as produced by ascii_dump) and sets *this
accordingly. Returns true
if successful, false
otherwise.
Reimplemented from Parma_Polyhedra_Library::Linear_Row.
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 203 of file Generator.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::ascii_load().
Referenced by Parma_Polyhedra_Library::Grid_Generator::ascii_load().
00203 { 00204 return Linear_Row::ascii_load(s); 00205 }
bool Parma_Polyhedra_Library::Generator::OK | ( | ) | const |
Checks if all the invariants are satisfied.
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 292 of file Generator.cc.
References Parma_Polyhedra_Library::Linear_Row::all_homogeneous_terms_are_zero(), CLOSURE_POINT, Parma_Polyhedra_Library::Linear_Row::is_necessarily_closed(), LINE, POINT, RAY, Parma_Polyhedra_Library::Row::size(), Parma_Polyhedra_Library::Linear_Row::strong_normalize(), and type().
00292 { 00293 const Generator& g = *this; 00294 00295 // Topology consistency check. 00296 const dimension_type min_size = is_necessarily_closed() ? 1 : 2; 00297 if (size() < min_size) { 00298 #ifndef NDEBUG 00299 std::cerr << "Generator has fewer coefficients than the minimum " 00300 << "allowed by its topology:" 00301 << std::endl 00302 << "size is " << size() 00303 << ", minimum is " << min_size << "." 00304 << std::endl; 00305 #endif 00306 return false; 00307 } 00308 00309 // Normalization check. 00310 Generator tmp = g; 00311 tmp.strong_normalize(); 00312 if (tmp != g) { 00313 #ifndef NDEBUG 00314 std::cerr << "Generators should be strongly normalized!" 00315 << std::endl; 00316 #endif 00317 return false; 00318 } 00319 00320 switch (g.type()) { 00321 case LINE: 00322 // Intentionally fall through. 00323 case RAY: 00324 if (g[0] != 0) { 00325 #ifndef NDEBUG 00326 std::cerr << "Lines must have a zero inhomogeneous term!" 00327 << std::endl; 00328 #endif 00329 return false; 00330 } 00331 if (!g.is_necessarily_closed() && g[size() - 1] != 0) { 00332 #ifndef NDEBUG 00333 std::cerr << "Lines and rays must have a zero coefficient " 00334 << "for the epsilon dimension!" 00335 << std::endl; 00336 #endif 00337 return false; 00338 } 00339 // The following test is correct, since we already checked 00340 // that the epsilon coordinate is zero. 00341 if (g.all_homogeneous_terms_are_zero()) { 00342 #ifndef NDEBUG 00343 std::cerr << "The origin of the vector space cannot be a line or a ray!" 00344 << std::endl; 00345 #endif 00346 return false; 00347 } 00348 break; 00349 00350 case POINT: 00351 if (g[0] <= 0) { 00352 #ifndef NDEBUG 00353 std::cerr << "Points must have a positive divisor!" 00354 << std::endl; 00355 #endif 00356 return false; 00357 } 00358 if (!g.is_necessarily_closed()) 00359 if (g[size() - 1] <= 0) { 00360 #ifndef NDEBUG 00361 std::cerr << "In the NNC topology, points must have epsilon > 0" 00362 << std::endl; 00363 #endif 00364 return false; 00365 } 00366 break; 00367 00368 case CLOSURE_POINT: 00369 if (g[0] <= 0) { 00370 #ifndef NDEBUG 00371 std::cerr << "Closure points must have a positive divisor!" 00372 << std::endl; 00373 #endif 00374 return false; 00375 } 00376 break; 00377 } 00378 00379 // All tests passed. 00380 return true; 00381 }
void Parma_Polyhedra_Library::Generator::swap | ( | Generator & | y | ) | [inline] |
Swaps *this
with y
.
Definition at line 208 of file Generator.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::swap().
Referenced by Parma_Polyhedra_Library::Grid_Generator::Grid_Generator(), Parma_Polyhedra_Library::Grid_Generator::swap(), and swap().
00208 { 00209 Linear_Row::swap(y); 00210 }
void Parma_Polyhedra_Library::Generator::throw_dimension_incompatible | ( | const char * | method, | |
const char * | name_var, | |||
Variable | v | |||
) | const [private] |
Throw a std::invalid_argument
exception containing the appropriate error message.
Definition at line 35 of file Generator.cc.
References Parma_Polyhedra_Library::Variable::space_dimension(), and space_dimension().
Referenced by coefficient().
00037 { 00038 std::ostringstream s; 00039 s << "PPL::Generator::" << method << ":" << std::endl 00040 << "this->space_dimension() == " << space_dimension() << ", " 00041 << name_var << ".space_dimension() == " << v.space_dimension() << "."; 00042 throw std::invalid_argument(s.str()); 00043 }
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.
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 46 of file Generator.cc.
Referenced by divisor().
00047 { 00048 std::ostringstream s; 00049 s << "PPL::Generator::" << method << ":" << std::endl 00050 << reason << "."; 00051 throw std::invalid_argument(s.str()); 00052 }
Parma_Polyhedra_Library::Generator::Parma_Polyhedra_Library::Linear_Expression::Linear_Expression | ( | const Generator & | g | ) | [private] |
bool Parma_Polyhedra_Library::Generator::is_ray_or_point | ( | ) | const [inline, private] |
Returns true
if and only if *this
is not a line.
Definition at line 73 of file Generator.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::is_ray_or_point_or_inequality().
Referenced by divisor(), and is_ray().
00073 { 00074 return is_ray_or_point_or_inequality(); 00075 }
void Parma_Polyhedra_Library::Generator::set_is_line | ( | ) | [inline, private] |
Sets the Linear_Row kind to LINE_OR_EQUALITY
.
Reimplemented in Parma_Polyhedra_Library::Grid_Generator.
Definition at line 113 of file Generator.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::set_is_line_or_equality().
Referenced by Parma_Polyhedra_Library::Polyhedron::add_recycled_generators(), and Parma_Polyhedra_Library::Grid_Generator::set_is_line().
00113 { 00114 set_is_line_or_equality(); 00115 }
void Parma_Polyhedra_Library::Generator::set_is_ray_or_point | ( | ) | [inline, private] |
Sets the Linear_Row kind to RAY_OR_POINT_OR_INEQUALITY
.
Definition at line 118 of file Generator.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::set_is_ray_or_point_or_inequality().
Referenced by Parma_Polyhedra_Library::Grid_Generator::coefficient_swap(), and Parma_Polyhedra_Library::Grid_Generator::set_is_parameter_or_point().
00118 { 00119 set_is_ray_or_point_or_inequality(); 00120 }
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 249 of file Generator.cc.
References CLOSURE_POINT, Parma_Polyhedra_Library::exact_div_assign(), Parma_Polyhedra_Library::gcd_assign(), POINT, space_dimension(), TEMP_INTEGER, Parma_Polyhedra_Library::Linear_Row::topology(), and type().
Referenced by Parma_Polyhedra_Library::Polyhedron::is_topologically_closed(), and Parma_Polyhedra_Library::Generator_System::const_iterator::skip_forward().
00249 { 00250 assert(topology() == p.topology() 00251 && space_dimension() == p.space_dimension() 00252 && type() == CLOSURE_POINT 00253 && p.type() == POINT); 00254 const Generator& cp = *this; 00255 if (cp[0] == p[0]) { 00256 // Divisors are equal: we can simply compare coefficients 00257 // (disregarding the epsilon coefficient). 00258 for (dimension_type i = cp.size() - 2; i > 0; --i) 00259 if (cp[i] != p[i]) 00260 return false; 00261 return true; 00262 } 00263 else { 00264 // Divisors are different: divide them by their GCD 00265 // to simplify the following computation. 00266 TEMP_INTEGER(gcd); 00267 gcd_assign(gcd, cp[0], p[0]); 00268 const bool rel_prime = (gcd == 1); 00269 TEMP_INTEGER(cp_0_scaled); 00270 TEMP_INTEGER(p_0_scaled); 00271 if (!rel_prime) { 00272 exact_div_assign(cp_0_scaled, cp[0], gcd); 00273 exact_div_assign(p_0_scaled, p[0], gcd); 00274 } 00275 const Coefficient& cp_div = rel_prime ? cp[0] : cp_0_scaled; 00276 const Coefficient& p_div = rel_prime ? p[0] : p_0_scaled; 00277 TEMP_INTEGER(prod1); 00278 TEMP_INTEGER(prod2); 00279 for (dimension_type i = cp.size() - 2; i > 0; --i) { 00280 prod1 = cp[i] * p_div; 00281 prod2 = p[i] * cp_div; 00282 if (prod1 != prod2) 00283 return false; 00284 } 00285 return true; 00286 } 00287 }
friend class Parma_Polyhedra_Library::Scalar_Products [friend] |
Definition at line 412 of file Generator.defs.hh.
friend class Parma_Polyhedra_Library::Topology_Adjusted_Scalar_Product_Sign [friend] |
Definition at line 413 of file Generator.defs.hh.
friend class Parma_Polyhedra_Library::Topology_Adjusted_Scalar_Product_Assign [friend] |
Definition at line 414 of file Generator.defs.hh.
friend class Parma_Polyhedra_Library::Generator_System [friend] |
Definition at line 415 of file Generator.defs.hh.
friend class Parma_Polyhedra_Library::Generator_System::const_iterator [friend] |
Definition at line 416 of file Generator.defs.hh.
friend class Parma_Polyhedra_Library::Polyhedron [friend] |
Definition at line 418 of file Generator.defs.hh.
friend class Parma_Polyhedra_Library::Grid_Generator [friend] |
Definition at line 419 of file Generator.defs.hh.
friend class Parma_Polyhedra_Library::Grid_Generator_System [friend] |
Definition at line 421 of file Generator.defs.hh.
std::ostream & operator<< | ( | std::ostream & | s, | |
const Generator & | g | |||
) | [friend] |
Output operator.
Definition at line 162 of file Generator.cc.
00162 { 00163 bool needed_divisor = false; 00164 bool extra_parentheses = false; 00165 const int num_variables = g.space_dimension(); 00166 Generator::Type t = g.type(); 00167 switch (t) { 00168 case Generator::LINE: 00169 s << "l("; 00170 break; 00171 case Generator::RAY: 00172 s << "r("; 00173 break; 00174 case Generator::POINT: 00175 s << "p("; 00176 goto any_point; 00177 case Generator::CLOSURE_POINT: 00178 s << "c("; 00179 any_point: 00180 if (g[0] != 1) { 00181 needed_divisor = true; 00182 int num_non_zero_coefficients = 0; 00183 for (int v = 0; v < num_variables; ++v) 00184 if (g[v+1] != 0) 00185 if (++num_non_zero_coefficients > 1) { 00186 extra_parentheses = true; 00187 s << "("; 00188 break; 00189 } 00190 } 00191 break; 00192 } 00193 00194 bool first = true; 00195 for (int v = 0; v < num_variables; ++v) { 00196 Coefficient gv = g[v+1]; 00197 if (gv != 0) { 00198 if (!first) { 00199 if (gv > 0) 00200 s << " + "; 00201 else { 00202 s << " - "; 00203 neg_assign(gv); 00204 } 00205 } 00206 else 00207 first = false; 00208 if (gv == -1) 00209 s << "-"; 00210 else if (gv != 1) 00211 s << gv << "*"; 00212 s << PPL::Variable(v); 00213 } 00214 } 00215 if (first) 00216 // A point or closure point in the origin. 00217 s << 0; 00218 if (extra_parentheses) 00219 s << ")"; 00220 if (needed_divisor) 00221 s << "/" << g[0]; 00222 s << ")"; 00223 return s; 00224 }
void swap | ( | Parma_Polyhedra_Library::Generator & | x, | |
Parma_Polyhedra_Library::Generator & | y | |||
) | [related] |
Specializes std::swap
.
Definition at line 218 of file Generator.inlines.hh.
References swap().
00219 { 00220 x.swap(y); 00221 }
Returns true
if and only if x
is equivalent to y
.
Definition at line 187 of file Generator.inlines.hh.
References is_equivalent_to().
Returns true
if and only if x
is not equivalent to y
.
Definition at line 193 of file Generator.inlines.hh.
References is_equivalent_to().
std::ostream & operator<< | ( | std::ostream & | s, | |
const Generator::Type & | t | |||
) | [related] |
Output operator.
Definition at line 228 of file Generator.cc.
References CLOSURE_POINT, LINE, POINT, and RAY.
00228 { 00229 const char* n = 0; 00230 switch (t) { 00231 case Generator::LINE: 00232 n = "LINE"; 00233 break; 00234 case Generator::RAY: 00235 n = "RAY"; 00236 break; 00237 case Generator::POINT: 00238 n = "POINT"; 00239 break; 00240 case Generator::CLOSURE_POINT: 00241 n = "CLOSURE_POINT"; 00242 break; 00243 } 00244 s << n; 00245 return s; 00246 }