24 #include "ppl-config.h"
28 #include "assertions.hh"
36 return (row.size() != 0);
42 if (row.size() == 0) {
46 i_end = row.end(); i != i_end; ++i) {
48 std::cerr <<
"Linear_Expression_Impl<Sparse_Row>::OK() failed."
50 row.ascii_dump(std::cerr);
69 Variables_Set::const_iterator vsi = vars.begin();
70 Variables_Set::const_iterator vsi_end = vars.end();
73 for (++vsi; vsi != vsi_end; ++vsi) {
76 while (src_col < vsi_col) {
77 row.swap_coefficients(dst_col++, src_col++);
83 while (src_col < sz) {
84 row.swap_coefficients(dst_col++, src_col++);
103 Variables_Set::const_iterator vsi = vars.begin();
104 Variables_Set::const_iterator vsi_end = vars.end();
108 while (vsi != vsi_end) {
110 if (src != row_end && src.
index() == *vsi + 1) {
111 src = row.reset(src);
115 if (vsi != vsi_end) {
118 while (src != row_end && src.
index() < *vsi + 1) {
119 row.fast_swap(src.
index() - num_removed, src);
126 while (src != row_end) {
127 row.fast_swap(src.
index() - num_removed, src);
133 PPL_ASSERT(num_removed == vars.size());
135 row.resize(row.size() - num_removed);
177 PPL_ASSERT(start <= end);
193 for (i = start; i < end; ++i) {
203 PPL_ASSERT(row[i] != 0);
212 for ( ; i < end; ++i) {
245 for ( ; i != i_end; ++i) {
259 Variables_Set::const_iterator j = vars.begin();
260 Variables_Set::const_iterator j_end = vars.end();
262 for ( ; j != j_end; ++j) {
263 if (row[*j + 1] != 0) {
277 Variables_Set::const_iterator j = vars.begin();
278 Variables_Set::const_iterator j_end = vars.end();
280 for ( ; j != j_end; ++j) {
281 i = row.lower_bound(i, *j + 1);
285 if (i.
index() == *j + 1) {
305 if (row[i] != 0 && vars.count(i - 1) == 0) {
317 PPL_ASSERT(start <= end);
322 if (row.find(0) != row.end()) {
329 PPL_ASSERT(start != 0);
330 PPL_ASSERT(start <= end);
332 i_end = row.lower_bound(end); i != i_end; ++i) {
333 if (vars.count(i.index() - 1) == 0) {
356 PPL_ASSERT(first <= last);
357 PPL_ASSERT(last <= row.size());
371 PPL_ASSERT(first <= last);
372 PPL_ASSERT(last <= row.size());
386 typedef std::set<dimension_type> set_t;
388 for (set_t::const_iterator i = x.begin(), i_end = x.end(); i != i_end; ++i) {
401 typedef std::set<dimension_type> set_t;
405 set_t::const_iterator i = x.begin();
406 set_t::const_iterator i_end = x.end();
407 for ( ; i != i_end; ++i) {
408 itr = row.lower_bound(itr, *i);
409 if (itr == itr_end) {
412 if (itr.
index() != *i) {
416 for ( ; i != i_end; ++i) {
431 PPL_ASSERT(start <= end);
432 PPL_ASSERT(end <= row.size());
433 PPL_ASSERT(end <= y.
row.
size());
435 if (row[i] != 0 && y.
row[i] != 0) {
450 PPL_ASSERT(start <= end);
451 PPL_ASSERT(end <= row.size());
452 PPL_ASSERT(end <= y.
row.
size());
454 i_end = row.lower_bound(end); i != i_end; ++i) {
455 if (y.
row[i.index()] != 0) {
479 PPL_ASSERT(start <= end);
480 PPL_ASSERT(end <= row.size());
481 PPL_ASSERT(end <= y.
row.
size());
486 while (i != i_end && j != j_end) {
487 if (i.index() == j.
index()) {
490 if (i.index() < j.
index()) {
504 while (itr != row->end() && *itr == 0) {
513 PPL_ASSERT(itr.index() > 0);
515 PPL_ASSERT(itr.index() > 1);
dimension_type index() const
Returns the index of the element pointed to by *this.
dimension_type space_dimension() const
Returns the dimension of the smallest vector space enclosing all the variables whose indexes are in t...
virtual void has_a_free_dimension_helper(std::set< dimension_type > &x) const
Removes from the set x all the indexes of nonzero elements of *this.
void swap(CO_Tree &x, CO_Tree &y)
virtual dimension_type first_nonzero(dimension_type first, dimension_type last) const
size_t dimension_type
An unsigned integral type for representing space dimensions.
An std::set of variables' indexes.
dimension_type size() const
Returns the size of the row.
virtual bool have_a_common_variable(const Linear_Expression_Interface &x, Variable first, Variable last) const
virtual bool OK() const
Checks if all the invariants are satisfied.
An iterator on the tree elements, ordered by key.
virtual void remove_space_dimensions(const Variables_Set &vars)
Removes all the specified dimensions from the expression.
virtual dimension_type num_zeroes(dimension_type start, dimension_type end) const
Returns the number of zero coefficient in [start, end).
void skip_zeroes_backward()
A dimension of the vector space.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
dimension_type size() const
Gives the number of coefficients currently in use.
virtual bool all_zeroes_except(const Variables_Set &vars, dimension_type start, dimension_type end) const
Returns true if each coefficient in [start,end) is *not* in , disregarding coefficients of variables ...
virtual bool is_zero() const
Returns true if and only if *this is .
void skip_zeroes_forward()
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
void neg_assign(GMP_Integer &x)
The entire library is confined to this namespace.
A const iterator on the tree elements, ordered by key.
iterator lower_bound(dimension_type i)
Lower bound of index i.
void gcd_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
virtual Coefficient gcd(dimension_type start, dimension_type end) const
Returns the gcd of the nonzero coefficients in [start,end). If all the coefficients in this range are...
virtual bool all_zeroes(const Variables_Set &vars) const
Returns true if the coefficient of each variable in vars[i] is .
dimension_type index() const
Returns the index of the element pointed to by *this.
virtual bool all_homogeneous_terms_are_zero() const
Returns true if and only if all the homogeneous terms of *this are .
virtual dimension_type last_nonzero() const