24 #ifndef PPL_Grid_templates_hh
25 #define PPL_Grid_templates_hh 1
35 template <
typename Interval>
42 "Grid(box, from_bounding_box)",
43 "the space dimension of box "
44 "exceeds the maximum allowed "
73 if (l_n * u_d == u_n * l_d) {
99 PPL_ASSERT(point.
OK());
117 template <
typename Partial_Function>
149 std::vector<Variable> cycle;
162 if (!pfunc.
maps(j, k)) {
164 " pfunc is inconsistent");
173 }
while (!visited[j]);
179 if (cycle.size() >= 2) {
207 Grid new_grid(new_space_dimension,
EMPTY);
217 if (pfunc.
maps(j, pfunc_j)) {
218 pfunc_maps[j] = pfunc_j;
228 for (i = old_gensys.
begin(); i != old_gensys_end; ++i) {
233 PPL_ASSERT(i != old_gensys_end);
235 for (i = old_gensys.
begin(); i != old_gensys_end; ++i) {
240 bool all_zeroes =
true;
242 j_end = old_g_e.
end(); j != j_end; ++j) {
249 switch (old_g.
type()) {
252 new_gensys.
insert(grid_line(expr));
257 new_gensys.
insert(parameter(expr, system_divisor));
266 Grid new_grid(new_gensys);
269 PPL_ASSERT(
OK(
true));
274 template <
typename M>
282 const bool generators) {
284 typedef typename M::row_type M_row_type;
286 const M_row_type& pivot = rows[pivot_index];
287 const Coefficient& pivot_dim = pivot.expr.get(dim);
289 if (pivot_dim == 0) {
294 pivot_dim_half = (pivot_dim + 1) / 2;
296 const bool row_is_line_or_equality
306 while (sys_dim_kinds[kinds_index] ==
GEN_VIRTUAL) {
313 while (sys_dim_kinds[kinds_index] ==
CON_VIRTUAL) {
319 if (row_is_line_or_equality
321 && sys_dim_kinds[kinds_index] ==
PARAMETER)) {
326 num_rows_to_subtract = row_dim / pivot_dim;
332 row_dim_remainder = row_dim % pivot_dim;
333 if (row_dim_remainder < 0) {
334 if (row_dim_remainder <= -pivot_dim_half) {
335 --num_rows_to_subtract;
338 else if (row_dim_remainder > 0 && row_dim_remainder > pivot_dim_half) {
339 ++num_rows_to_subtract;
346 if (num_rows_to_subtract != 0) {
347 row.expr.linear_combine(pivot.expr,
357 #endif // !defined(PPL_Grid_templates_hh)
Grid_Generator_System gen_sys
The system of generators.
The empty element, i.e., the empty set.
void clear_congruences_minimized()
Sets status to express that congruences are no longer minimized.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void set_space_dimension(dimension_type n)
Sets the dimension of the vector space enclosing *this to n .
void set_empty()
Sets status to express that the grid is empty, clearing all corresponding matrices.
Grid(dimension_type num_dimensions=0, Degenerate_Element kind=UNIVERSE)
Builds a grid having the specified properties.
size_t dimension_type
An unsigned integral type for representing space dimensions.
void insert(const Congruence &cg)
Inserts in *this a copy of the congruence cg, increasing the number of space dimensions if needed...
void permute_space_dimensions(const std::vector< Variable > &cycle)
Permutes the space dimensions of the matrix.
void set(dimension_type i, Coefficient_traits::const_reference n)
Sets the i-th coefficient to n.
Linear_System< Grid_Generator > sys
Congruence_System con_sys
The system of congruences.
void clear_generators_minimized()
Sets status to express that generators are no longer minimized.
const_iterator end() const
Returns the past-the-end const_iterator.
#define PPL_DIRTY_TEMP_COEFFICIENT(id)
Declare a local variable named id, of type Coefficient, and containing an unknown initial value...
dimension_type not_a_dimension()
Returns a value that does not designate a valid dimension.
bool set_space_dimension(dimension_type new_space_dim)
Sets the number of space dimensions to new_space_dim.
void add_mul_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
bool is_empty() const
Returns true if and only if *this is an empty box.
const_iterator begin() const
Returns the const_iterator pointing to the first generator, if this is not empty; otherwise...
bool has_empty_codomain() const
Returns true if and only if the represented partial function has an empty codomain (i...
void exact_div_assign(Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, const Checked_Number< T, Policy > &z)
void set_space_dimension(dimension_type space_dim)
Resizes the system to the specified space dimension.
bool congruences_are_up_to_date() const
Returns true if the system of congruences is up-to-date.
expr_type expression() const
Partial read access to the (adapted) internal expression.
A dimension of the vector space.
Complexity_Class
Complexity pseudo-classes.
bool OK(bool check_not_empty=false) const
Checks if all the invariants are satisfied.
Coefficient_traits::const_reference divisor() const
Returns the divisor of *this.
static void reduce_reduced(Swapping_Vector< typename M::row_type > &sys, dimension_type dim, dimension_type pivot_index, dimension_type start, dimension_type end, const Dimension_Kinds &sys_dim_kinds, bool generators=true)
Reduce column dim in rows preceding pivot_index in sys.
std::vector< Dimension_Kind > Dimension_Kinds
An iterator over a system of grid generators.
dimension_type check_space_dimension_overflow(const dimension_type dim, const dimension_type max, const char *domain, const char *method, const char *reason)
const_iterator end() const
Iterator pointing after the last nonzero variable coefficient.
bool has_upper_bound(Variable var, Coefficient &n, Coefficient &d, bool &closed) const
If the space dimension of var is unbounded above, return false. Otherwise return true and set n...
void set_generators_up_to_date()
Sets status to express that generators are up-to-date.
bool is_point() const
Returns true if and only if *this is a point.
A not necessarily closed, iso-oriented hyperrectangle.
Type type() const
Returns the generator type of *this.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
const Grid_Generator_System & grid_generators() const
Returns the system of generators.
void set_sorted(bool b)
Sets the sortedness flag of the system to b.
bool generators_are_up_to_date() const
Returns true if the system of generators is up-to-date.
void set_zero_dim_univ()
Sets status to express that the grid is the universe 0-dimension vector space, clearing all correspon...
dimension_type max_in_codomain() const
If the codomain is not empty, returns the maximum value in it.
bool has_lower_bound(Variable var, Coefficient &n, Coefficient &d, bool &closed) const
If the space dimension of var is unbounded below, return false. Otherwise return true and set n...
void permute_space_dimensions(const std::vector< Variable > &cycle)
Permutes the space dimensions of the system.
dimension_type space_dim
The number of dimensions of the enclosing vector space.
void neg_assign(GMP_Integer &x)
The entire library is confined to this namespace.
bool marked_empty() const
Returns true if the grid is known to be empty.
static void throw_invalid_argument(const char *method, const char *reason)
base_type::const_iterator const_iterator
The type of const iterators on coefficients.
void gcd_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
static dimension_type max_space_dimension()
Returns the maximum space dimension all kinds of Grid can handle.
void map_space_dimensions(const Partial_Function &pfunc)
Remaps the dimensions of the vector space according to a partial function.
bool maps(dimension_type i, dimension_type &j) const
If *this maps i to a value k, assigns k to j and returns true; otherwise, j is unchanged and false is...
void set_congruences_up_to_date()
Sets status to express that congruences are up-to-date.
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
void m_swap(Grid &y)
Swaps *this with grid y. (*this and y can be dimension-incompatible.)
const_iterator begin() const
Iterator pointing to the first nonzero variable coefficient.
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.
void insert(const Grid_Generator &g)
Inserts into *this a copy of the generator g, increasing the number of space dimensions if needed...
An adapter for Linear_Expression that maybe hides the last coefficient.
bool update_generators() const
Updates and minimizes the generators from the congruences.
A grid line, parameter or grid point.
A system of grid generators.