24 #include "ppl-config.h"
25 #include "assertions.hh"
33 Coefficient_traits::const_reference pivot_column = pivot.
expr.
get(column);
34 Coefficient_traits::const_reference row_column = row.
expr.
get(column);
35 PPL_ASSERT(pivot_column != 0);
36 PPL_ASSERT(row_column != 0);
40 gcd_assign(reduced_row_col, pivot_column, row_column);
51 reduced_pivot_col, reduced_row_col,
54 PPL_ASSERT(row.
expr.
get(column) == 0);
64 Coefficient_traits::const_reference pivot_column = pivot.
expr.
get(column);
65 Coefficient_traits::const_reference row_column = row.
expr.
get(column);
66 PPL_ASSERT(pivot_column != 0);
67 PPL_ASSERT(row_column != 0);
71 gcd_assign(reduced_row_col, pivot_column, row_column);
80 reduced_pivot_col, reduced_row_col,
83 PPL_ASSERT(row.
expr.
get(column) == 0);
92 PPL_ASSERT(start <= end);
93 PPL_ASSERT(start <= column);
94 PPL_ASSERT(column < end);
99 Coefficient_traits::const_reference pivot_column = pivot_e.
get(column);
100 Coefficient_traits::const_reference row_column = row_e.
get(column);
101 PPL_ASSERT(pivot_column != 0);
102 PPL_ASSERT(row_column != 0);
109 PPL_ASSERT(pivot_e.
get(column) * s + row_e.
get(column) * t == gcd);
123 PPL_ASSERT(pivot_e.
get(column) == gcd);
124 row_e.
linear_combine(old_pivot_e, reduced_pivot_col, -reduced_row_col, start, end);
125 PPL_ASSERT(row_e.
get(column) == 0);
137 Coefficient_traits::const_reference pivot_column = pivot.
expr.
get(column);
138 Coefficient_traits::const_reference row_column = row.
expr.
get(column);
139 PPL_ASSERT(pivot_column != 0);
140 PPL_ASSERT(row_column != 0);
147 if (row_column == pivot_column) {
154 gcd_assign(reduced_row_col, pivot_column, row_column);
165 if (reduced_pivot_col < 0) {
185 column, num_columns);
186 PPL_ASSERT(row.
expr.
get(column) == 0);
198 Coefficient_traits::const_reference pivot_column = pivot.
expr.
get(column);
199 Coefficient_traits::const_reference row_column = row.
expr.
get(column);
203 if (row_column == pivot_column) {
210 gcd_assign(reduced_row_col, pivot_column, row_column);
217 if (reduced_pivot_col < 0) {
227 cg.
scale(reduced_pivot_col);
233 PPL_ASSERT(row.
expr.
get(column) == 0);
237 template <
typename M,
typename R>
241 while (first <= last) {
242 const R& row = system[first++];
243 if (!row.expr.all_zeroes(0, row_size)) {
259 if (dim_kinds.size() != num_columns) {
260 dim_kinds.resize(num_columns);
275 while (row_index < num_rows
276 && ggs.
sys.rows[row_index].expr.get(dim) == 0) {
280 if (row_index == num_rows) {
285 if (row_index != pivot_index) {
287 swap(ggs.
sys.rows[row_index], ggs.
sys.rows[pivot_index]);
290 bool pivot_is_line = pivot.
is_line();
294 while (row_index < num_rows - 1) {
310 pivot_is_line =
true;
329 dim_kinds[dim] =
LINE;
343 reduce_reduced<Grid_Generator_System>
344 (ggs.
sys.rows, dim, pivot_index, dim, num_columns - 1,
dim_kinds);
351 if (num_rows > pivot_index) {
353 const bool ret = rows_are_zero<Grid_Generator_System, Grid_Generator>
360 ggs.space_dimension() + 1);
361 PPL_ASSERT(ret ==
true);
363 ggs.sys.rows.resize(pivot_index);
368 const Coefficient& system_divisor = ggs.
sys.rows[0].expr.inhomogeneous_term();
370 dim = num_columns - 1; dim > 0; --dim) {
371 switch (dim_kinds[dim]) {
373 ggs.
sys.rows[i].set_divisor(system_divisor);
376 PPL_ASSERT(ggs.
sys.rows[i].OK());
385 PPL_ASSERT(ggs.
sys.OK());
400 if (dim_kinds.size() != num_columns) {
401 dim_kinds.resize(num_columns);
416 while (row_index < num_rows && cgs.
rows[row_index].expr.get(dim) == 0) {
420 if (row_index == num_rows) {
427 if (row_index != pivot_index) {
437 while (row_index < num_rows - 1) {
445 if (pivot_is_equality) {
452 pivot_is_equality =
true;
458 if (pivot_is_equality) {
468 if (pivot_is_equality) {
483 reduce_reduced<Congruence_System>
486 PPL_ASSERT(cgs.
OK());
492 if (pivot_index > 0) {
498 const bool ret = rows_are_zero<Congruence_System, Congruence>
506 PPL_ASSERT(ret ==
true);
513 switch (dim_kinds[0]) {
533 PPL_ASSERT(cgs.
OK());
546 const bool ret = rows_are_zero<Congruence_System, Congruence>
554 PPL_ASSERT(ret ==
true);
557 cgs.remove_trailing_rows(num_rows - 1);
569 PPL_ASSERT(cgs.
OK());
586 while (row_index-- > 0) {
597 cgs.
rows.back().expr.set_inhomogeneous_term(cgs.
rows.back().modulus());
602 reduce_reduced<Congruence_System>
605 PPL_ASSERT(cgs.
OK());
bool is_parameter_or_point() const
Returns true if and only if *this row represents a parameter or a point.
void remove_trailing_rows(dimension_type n)
static void reduce_pc_with_pc(R &row, R &pivot, dimension_type column, dimension_type start, dimension_type end)
Reduces row using pivot.
Coefficient_traits::const_reference modulus() const
Returns a const reference to the modulus of *this.
void swap(CO_Tree &x, CO_Tree &y)
size_t dimension_type
An unsigned integral type for representing space dimensions.
Linear_System< Grid_Generator > sys
bool is_line() const
Returns true if and only if *this is a line.
Coefficient_traits::const_reference get(dimension_type i) const
Returns the i-th coefficient.
#define PPL_DIRTY_TEMP_COEFFICIENT(id)
Declare a local variable named id, of type Coefficient, and containing an unknown initial value...
void insert_verbatim(Congruence &cg, Recycle_Input)
Inserts in *this the congruence cg, stealing its contents and increasing the number of space dimensio...
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void set_inhomogeneous_term(Coefficient_traits::const_reference n)
Sets the inhomogeneous term of *this to n.
Coefficient_traits::const_reference inhomogeneous_term() const
Returns the inhomogeneous term of *this.
void exact_div_assign(Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, const Checked_Number< T, Policy > &z)
static bool simplify(Congruence_System &cgs, Dimension_Kinds &dim_kinds)
Converts cgs to upper triangular (i.e. minimized) form.
void normalize_moduli()
Adjusts all expressions to have the same moduli.
bool is_proper_congruence() const
Returns true if the modulus is greater than zero.
void negate(dimension_type first, dimension_type last)
Negates the elements from index first (included) to index last (excluded).
bool OK() const
Checks if all the invariants are satisfied.
Swapping_Vector< Congruence > rows
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void set_modulus(Coefficient_traits::const_reference m)
bool is_equality() const
Returns true if *this is an equality.
std::vector< Dimension_Kind > Dimension_Kinds
void gcdext_assign(GMP_Integer &x, GMP_Integer &s, GMP_Integer &t, const GMP_Integer &y, const GMP_Integer &z)
bool OK() const
Checks if all the invariants are satisfied.
void swap(Grid &x, Grid &y)
Swaps x with y.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
void linear_combine_lax(const Linear_Expression &y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2)
void unset_pending_rows()
Sets the index to indicate that the system has no pending rows.
void neg_assign(GMP_Integer &x)
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
The entire library is confined to this namespace.
dimension_type num_rows() const
Returns the number of rows in the system.
static bool rows_are_zero(M &system, dimension_type first, dimension_type last, dimension_type row_size)
Checks that trailing rows contain only zero terms.
dimension_type num_rows() const
Returns the number of rows (generators) in the system.
Dimension_Kinds dim_kinds
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void gcd_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
static void reduce_equality_with_equality(Congruence &row, const Congruence &pivot, dimension_type column)
Reduces the equality row using the equality pivot.
void sub_mul_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
static void reduce_congruence_with_equality(Congruence &row, const Congruence &pivot, dimension_type column, Swapping_Vector< Congruence > &sys)
Reduce row using pivot.
void mul_assign(Coefficient_traits::const_reference n, dimension_type start, dimension_type end)
Equivalent to (*this)[i] *= n, for each i in [start, end).
void linear_combine(const Linear_Expression &y, Variable v)
static void reduce_parameter_with_line(Grid_Generator &row, const Grid_Generator &pivot, dimension_type column, Swapping_Vector< Grid_Generator > &sys, dimension_type num_columns)
Reduce row using pivot.
dimension_type size() const
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
void scale(Coefficient_traits::const_reference factor)
Multiplies all the coefficients, including the modulus, by factor .
void set_space_dimension(dimension_type n)
bool OK() const
Checks if all the invariants are satisfied.
A grid line, parameter or grid point.
A system of grid generators.
static void reduce_line_with_line(Grid_Generator &row, Grid_Generator &pivot, dimension_type column)
Reduces the line row using the line pivot.