24 #include "ppl-config.h"
41 s <<
"PPL::Generator::" << method <<
":" << std::endl
44 throw std::invalid_argument(s.str());
49 const char* reason)
const {
51 s <<
"PPL::Generator::" << method <<
":" << std::endl
53 throw std::invalid_argument(s.str());
58 Coefficient_traits::const_reference d,
61 throw std::invalid_argument(
"PPL::point(e, d):\n"
93 Coefficient_traits::const_reference d,
96 throw std::invalid_argument(
"PPL::closure_point(e, d):\n"
131 throw std::invalid_argument(
"PPL::ray(e):\n"
132 "e == 0, but the origin cannot be a ray.");
146 throw std::invalid_argument(
"PPL::line(e):\n"
147 "e == 0, but the origin cannot be a line.");
161 expr.swap_space_dimensions(v1, v2);
170 expr.remove_space_dimensions(vars);
172 if (is_line_or_ray() && expr.all_homogeneous_terms_are_zero()) {
174 set_is_ray_or_point();
175 expr.set_inhomogeneous_term(1);
176 if (is_not_necessarily_closed()) {
177 set_epsilon_coefficient(1);
193 if (cycle.size() < 2) {
198 expr.permute_space_dimensions(cycle);
208 expr.linear_combine(y.
expr, i);
217 if (x_is_line_or_equality != y_is_line_or_equality) {
219 return y_is_line_or_equality ? 2 : -2;
234 if (x_type != y.
type()) {
249 return x_expr.is_equal_to(y_expr);
259 return expr.is_equal_to(y.
expr) && kind_ == y.
kind_
265 if (is_line_or_equality()) {
266 expr.sign_normalize();
274 return compare(*
this, tmp) == 0;
282 PPL_ASSERT(zero_dim_point_p == 0);
286 PPL_ASSERT(zero_dim_closure_point_p == 0);
287 zero_dim_closure_point_p
293 PPL_ASSERT(zero_dim_point_p != 0);
294 delete zero_dim_point_p;
295 zero_dim_point_p = 0;
297 PPL_ASSERT(zero_dim_closure_point_p != 0);
298 delete zero_dim_closure_point_p;
299 zero_dim_closure_point_p = 0;
304 bool needed_divisor =
false;
305 bool extra_parentheses =
false;
321 if (expr.inhomogeneous_term() != 1) {
322 needed_divisor =
true;
323 if (!expr.all_zeroes(1, num_variables + 1)) {
324 extra_parentheses =
true;
334 i_end = expr.lower_bound(
Variable(num_variables)); i != i_end; ++i) {
360 if (extra_parentheses) {
363 if (needed_divisor) {
364 s <<
"/" << expr.inhomogeneous_term();
400 PPL_ASSERT(topology() == p.
topology()
402 && type() == CLOSURE_POINT
403 && p.
type() == POINT);
415 const bool rel_prime = (gcd == 1);
422 const Coefficient& cp_div = rel_prime ? cp.expr.inhomogeneous_term() : cp_0_scaled;
434 if (is_not_necessarily_closed() && expr.space_dimension() == 0) {
436 std::cerr <<
"Generator has fewer coefficients than the minimum "
437 <<
"allowed by its topology."
448 std::cerr <<
"Generators should be strongly normalized!"
458 if (expr.inhomogeneous_term() != 0) {
460 std::cerr <<
"Lines must have a zero inhomogeneous term!"
465 if (!is_necessarily_closed() && epsilon_coefficient() != 0) {
467 std::cerr <<
"Lines and rays must have a zero coefficient "
468 <<
"for the epsilon dimension!"
475 if (expr.all_homogeneous_terms_are_zero()) {
477 std::cerr <<
"The origin of the vector space cannot be a line or a ray!"
485 if (expr.inhomogeneous_term() <= 0) {
487 std::cerr <<
"Points must have a positive divisor!"
492 if (!is_necessarily_closed()) {
493 if (epsilon_coefficient() <= 0) {
495 std::cerr <<
"In the NNC topology, points must have epsilon > 0"
504 if (expr.inhomogeneous_term() <= 0) {
506 std::cerr <<
"Closure points must have a positive divisor!"
void linear_combine(const Generator &y, dimension_type i)
Linearly combines *this with y so that i-th coefficient is 0.
dimension_type space_dimension() const
Returns the dimension of the smallest vector space enclosing all the variables whose indexes are in t...
size_t dimension_type
An unsigned integral type for representing space dimensions.
An std::set of variables' indexes.
void throw_invalid_argument(const char *method, const char *reason) const
Throw a std::invalid_argument exception containing the appropriate error message. ...
A line, ray, point or closure point.
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...
static Generator ray(const Linear_Expression &e, Representation r=default_representation)
Returns the ray of direction e.
bool is_equal_to(const Generator &y) const
Returns true if *this is identical to y.
std::ostream & operator<<(std::ostream &s, const Ask_Tell< D > &x)
static const Generator * zero_dim_closure_point_p
Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional...
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 fancy_print(std::ostream &s) const
A print function, with fancy, more human-friendly output.
void set_inhomogeneous_term(Coefficient_traits::const_reference n)
Sets the inhomogeneous term of *this to n.
bool is_equivalent_to(const Generator &y) const
Returns true if and only if *this and y are equivalent generators.
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...
void exact_div_assign(Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, const Checked_Number< T, Policy > &z)
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.
bool is_equal_to(const Linear_Expression &x) const
Kind kind_
The kind of *this.
static Generator line(const Linear_Expression &e, Representation r=default_representation)
Returns the line of direction e.
A dimension of the vector space.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
static void initialize()
Initializes the class.
Type type() const
Returns the generator type of *this.
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...
static void finalize()
Finalizes the class.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
bool all_homogeneous_terms_are_zero() const
Returns true if and only if all the homogeneous terms of *this are .
int compare(const Linear_Expression &x, const Linear_Expression &y)
bool remove_space_dimensions(const Variables_Set &vars)
Removes all the specified dimensions from the generator.
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.
static const Generator * zero_dim_point_p
Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional...
bool check_strong_normalized() const
Returns true if and only if the coefficients are strongly normalized.
void neg_assign(GMP_Integer &x)
void strong_normalize()
Strong normalization: ensures that different Generator objects represent different hyperplanes or hyp...
#define PPL_OUTPUT_DEFINITIONS(class_name)
The entire library is confined to this namespace.
Topology topology() const
Returns the topological kind of *this.
void gcd_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
static const Linear_Expression & zero()
Returns the (zero-dimension space) constant 0.
void permute_space_dimensions(const std::vector< Variable > &cycle)
Permutes the space dimensions of the generator.
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
bool is_line_or_equality() const
Returns true if and only if *this row represents a line or an equality.
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. ...
void swap_space_dimensions(Variable v1, Variable v2)
Swaps the coefficients of the variables v1 and v2 .
Topology topology_
The topology of *this.