24 #include "ppl-config.h"
40 s <<
"PPL::Grid_Generator::" << method <<
":" << std::endl
43 throw std::invalid_argument(s.str());
48 const char* reason)
const {
50 s <<
"PPL::Grid_Generator::" << method <<
":" << std::endl
52 throw std::invalid_argument(s.str());
57 Coefficient_traits::const_reference d,
60 throw std::invalid_argument(
"PPL::parameter(e, d):\n"
68 ec.set(divisor_var, d);
87 Coefficient_traits::const_reference d,
90 throw std::invalid_argument(
"PPL::grid_point(e, d):\n"
127 throw std::invalid_argument(
"PPL::grid_line(e):\n"
128 "e == 0, but the origin cannot be a line.");
147 expr.swap_space_dimensions(v1, v2);
149 if (!is_parameter()) {
159 expr.remove_space_dimensions(vars);
168 if (cycle.size() < 2) {
173 expr.permute_space_dimensions(cycle);
179 if (!is_parameter()) {
208 if (!expr.ascii_load(s)) {
220 else if (str ==
"P" || str ==
"Q") {
221 set_is_parameter_or_point();
234 set_is_parameter_or_point();
236 else if (!is_line_or_parameter()) {
238 expr.set(
Variable(expr.space_dimension() - 1), expr.inhomogeneous_term());
246 expr.linear_combine(y.
expr, i);
255 if (x_is_line_or_equality != y_is_line_or_equality) {
257 return y_is_line_or_equality ? 2 : -2;
272 if (x_type != y.
type()) {
278 const Variable last_var(x_space_dim);
279 if (x_type == POINT || x_type == LINE) {
292 return expr.is_equal_to(y.
expr) && kind_ == y.
kind_;
298 return expr.all_zeroes(1, expr.space_dimension());
311 PPL_ASSERT(factor > 0);
314 expr.mul_assign(factor, 1, expr.space_dimension());
320 if (is_line_or_equality()) {
321 expr.sign_normalize();
329 return compare(*
this, tmp) == 0;
336 PPL_ASSERT(zero_dim_point_p == 0);
342 PPL_ASSERT(zero_dim_point_p != 0);
343 delete zero_dim_point_p;
344 zero_dim_point_p = 0;
349 bool need_divisor =
false;
350 bool extra_parentheses =
false;
359 if (expr.coefficient(
Variable(num_variables)) == 1) {
365 if (expr.inhomogeneous_term() > 1) {
368 if (!expr.all_zeroes(1, num_variables + 1)) {
369 extra_parentheses =
true;
380 i_end = expr.lower_bound(
Variable(num_variables)); i != i_end; ++i) {
406 if (extra_parentheses) {
410 s <<
"/" << divisor();
449 std::cerr <<
"Grid_Generator should be necessarily closed.\n";
456 std::cerr <<
"Grid_Generator has fewer coefficients than the minimum "
458 <<
", minimum is 1.\n";
467 std::cerr <<
"Inhomogeneous terms of lines must be zero!\n";
476 std::cerr <<
"Inhomogeneous terms of parameters must be zero!\n";
482 std::cerr <<
"Parameters must have positive divisors!\n";
491 std::cerr <<
"Points must have positive divisors!\n";
497 std::cerr <<
"Points must have a zero parameter divisor!\n";
dimension_type space_dimension() const
Returns the dimension of the smallest vector space enclosing all the variables whose indexes are in t...
bool is_equal_to(const Grid_Generator &y) const
Returns true if *this is identical to y.
size_t dimension_type
An unsigned integral type for representing space dimensions.
void permute_space_dimensions(const std::vector< Variable > &cycle)
Permutes the space dimensions of the grid generator.
An std::set of variables' indexes.
void set(dimension_type i, Coefficient_traits::const_reference n)
Sets the i-th coefficient to n.
Coefficient_traits::const_reference inhomogeneous_term() const
Returns the inhomogeneous term of *this.
bool remove_space_dimensions(const Variables_Set &vars)
Removes all the specified dimensions from the grid generator.
#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 check_strong_normalized() const
Returns true if and only if the coefficients are strongly normalized.
The standard C++ namespace.
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.
void exact_div_assign(Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, const Checked_Number< T, Policy > &z)
Coefficient_traits::const_reference coefficient(Variable v) const
Returns the coefficient of v in *this.
void ascii_dump() const
Writes to std::cerr an ASCII representation of *this.
A dimension of the vector space.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
static Grid_Generator parameter(const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
static void finalize()
Finalizes the class.
Coefficient_traits::const_reference divisor() const
Returns the divisor of *this.
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
void swap_space_dimensions(Variable v1, Variable v2)
Swaps the coefficients of the variables v1 and v2 .
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type ascii_load(std::istream &s, T &t)
Type type() const
Returns the generator type of *this.
static const Grid_Generator * zero_dim_point_p
Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional...
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 is_equivalent_to(const Grid_Generator &y) const
Returns true if and only if *this and y are equivalent generators.
void linear_combine(const Grid_Generator &y, dimension_type i)
Linearly combines *this with y so that i-th coefficient is 0.
void sign_normalize()
Normalizes the sign of the coefficients so that the first non-zero (homogeneous) coefficient of a lin...
void throw_dimension_incompatible(const char *method, const char *name_var, const Variable v) const
Throw a std::invalid_argument exception containing the appropriate error message. ...
bool is_line_or_equality() const
Returns true if and only if *this row represents a line or an equality.
void neg_assign(GMP_Integer &x)
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
static Grid_Generator grid_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.
#define PPL_OUTPUT_DEFINITIONS(class_name)
The entire library is confined to this namespace.
bool all_homogeneous_terms_are_zero() const
Returns true if and only if all the homogeneous terms of *this are .
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
static Grid_Generator grid_line(const Linear_Expression &e, Representation r=default_representation)
Returns the line of direction e.
void strong_normalize()
Strong normalization: ensures that different Grid_Generator objects represent different hyperplanes o...
void throw_invalid_argument(const char *method, const char *reason) const
Throw a std::invalid_argument exception containing the appropriate error message. ...
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.
void scale_to_divisor(Coefficient_traits::const_reference d)
Scales *this to be represented with a divisor of d (if \*this is a parameter or point). Does nothing at all on lines.
bool OK() const
Checks if all the invariants are satisfied.
static void initialize()
Initializes the class.
A grid line, parameter or grid point.
void set_is_parameter()
Converts the Grid_Generator into a parameter.