PPL  1.2
Parma_Polyhedra_Library::Expression_Hide_Inhomo< T > Class Template Reference

An adapter for Linear_Expression that hides the inhomogeneous term. More...

#include <Expression_Hide_Inhomo_defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >:
Collaboration diagram for Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >:

Public Types

typedef Expression_Hide_Inhomo< T > const_reference
 The type of this object. More...
 
typedef base_type::inner_type inner_type
 The type obtained by one-level unwrapping. More...
 
typedef base_type::raw_type raw_type
 The raw, completely unwrapped type. More...
 
typedef base_type::const_iterator const_iterator
 The type of const iterators on coefficients. More...
 
- Public Types inherited from Parma_Polyhedra_Library::Expression_Adapter< T >
typedef Expression_Adapter< T > const_reference
 The type of this object. More...
 
typedef T::const_reference inner_type
 The type obtained by one-level unwrapping. More...
 
typedef T::raw_type raw_type
 The raw, completely unwrapped type. More...
 
typedef raw_type::const_iterator const_iterator
 The type of const iterators on coefficients. More...
 

Public Member Functions

 Expression_Hide_Inhomo (const raw_type &expr)
 Constructor. More...
 
Coefficient_traits::const_reference inhomogeneous_term () const
 Returns the constant zero. More...
 
bool is_zero () const
 Returns true if and only if *this is zero. More...
 
template<typename Expression >
bool is_equal_to (const Expression &y) const
 Returns true if *this is equal to y. More...
 
Coefficient_traits::const_reference get (dimension_type i) const
 Returns the i-th coefficient. More...
 
Coefficient_traits::const_reference get (Variable v) const
 Returns the coefficient of v. More...
 
bool all_zeroes (const Variables_Set &vars) const
 Returns true if the coefficient of each variable in vars is zero. More...
 
bool all_zeroes (dimension_type start, dimension_type end) const
 Returns true if (*this)[i] is zero, for each i in [start, end). More...
 
dimension_type num_zeroes (dimension_type start, dimension_type end) const
 Returns the number of zero coefficient in [start, end). More...
 
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 zero, returns zero. More...
 
dimension_type last_nonzero () const
 
dimension_type last_nonzero (dimension_type first, dimension_type last) const
 
dimension_type first_nonzero (dimension_type first, dimension_type last) const
 
bool all_zeroes_except (const Variables_Set &vars, dimension_type start, dimension_type end) const
 Returns true if all coefficients in [start,end), except those corresponding to variables in vars, are zero. More...
 
void has_a_free_dimension_helper (std::set< dimension_type > &x) const
 Removes from set x all the indexes of nonzero elements in *this. More...
 
template<typename Expression >
bool is_equal_to (const Expression &y, dimension_type start, dimension_type end) const
 
template<typename Expression >
bool is_equal_to (const Expression &y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2, dimension_type start, dimension_type end) const
 
void get_row (Dense_Row &r) const
 Sets r to a copy of the row as adapted by *this. More...
 
void get_row (Sparse_Row &r) const
 Sets r to a copy of the row as adapted by *this. More...
 
- Public Member Functions inherited from Parma_Polyhedra_Library::Expression_Adapter< T >
inner_type inner () const
 Returns an adapter after one-level unwrapping. More...
 
Representation representation () const
 Returns the current representation of *this. More...
 
const_iterator begin () const
 Iterator pointing to the first nonzero variable coefficient. More...
 
const_iterator end () const
 Iterator pointing after the last nonzero variable coefficient. More...
 
const_iterator lower_bound (Variable v) const
 
dimension_type space_dimension () const
 Returns the dimension of the vector space enclosing *this. More...
 
Coefficient_traits::const_reference coefficient (Variable v) const
 Returns the coefficient of v in *this. More...
 
Coefficient_traits::const_reference inhomogeneous_term () const
 Returns the inhomogeneous term of *this. More...
 
bool is_zero () const
 Returns true if and only if *this is zero. More...
 
bool all_homogeneous_terms_are_zero () const
 Returns true if and only if all the homogeneous terms of *this are zero. More...
 
template<typename Expression >
bool is_equal_to (const Expression &y) const
 Returns true if *this is equal to y. More...
 
bool all_zeroes (const Variables_Set &vars) const
 Returns true if the coefficient of each variable in vars is zero. More...
 
Coefficient_traits::const_reference get (dimension_type i) const
 Returns the i -th coefficient. More...
 
Coefficient_traits::const_reference get (Variable v) const
 Returns the coefficient of variable v. More...
 
bool all_zeroes (dimension_type start, dimension_type end) const
 Returns true if (*this)[i] is zero, for each i in [start, end). More...
 
dimension_type num_zeroes (dimension_type start, dimension_type end) const
 Returns the number of zero coefficient in [start, end). More...
 
Coefficient gcd (dimension_type start, dimension_type end) const
 Returns the gcd of the nonzero coefficients in [start,end). Returns zero if all the coefficients in the range are zero. More...
 
dimension_type last_nonzero () const
 
dimension_type last_nonzero (dimension_type first, dimension_type last) const
 
dimension_type first_nonzero (dimension_type first, dimension_type last) const
 
bool all_zeroes_except (const Variables_Set &vars, dimension_type start, dimension_type end) const
 Returns true if all coefficients in [start,end), except those corresponding to variables in vars, are zero. More...
 
void has_a_free_dimension_helper (std::set< dimension_type > &x) const
 Removes from set x all the indexes of nonzero elements in *this. More...
 
template<typename Expression >
bool is_equal_to (const Expression &y, dimension_type start, dimension_type end) const
 
template<typename Expression >
bool is_equal_to (const Expression &y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2, dimension_type start, dimension_type end) const
 
void get_row (Dense_Row &r) const
 Sets r to a copy of the row as adapted by *this. More...
 
void get_row (Sparse_Row &r) const
 Sets r to a copy of the row as adapted by *this. More...
 
template<typename Expression >
bool have_a_common_variable (const Expression &y, Variable first, Variable last) const
 

Private Types

typedef Expression_Adapter< T > base_type
 

Additional Inherited Members

- Protected Member Functions inherited from Parma_Polyhedra_Library::Expression_Adapter< T >
 Expression_Adapter (const raw_type &expr)
 Constructor. More...
 
- Protected Attributes inherited from Parma_Polyhedra_Library::Expression_Adapter< T >
const raw_typeraw_
 The raw, completely unwrapped object subject to adaptation. More...
 

Detailed Description

template<typename T>
class Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >

An adapter for Linear_Expression that hides the inhomogeneous term.

The methods of this class always pretend that the value of the inhomogeneous term is zero.

Definition at line 42 of file Expression_Hide_Inhomo_defs.hh.

Member Typedef Documentation

template<typename T >
typedef Expression_Adapter<T> Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::base_type
private

Definition at line 44 of file Expression_Hide_Inhomo_defs.hh.

The type of const iterators on coefficients.

Definition at line 58 of file Expression_Hide_Inhomo_defs.hh.

The type of this object.

Definition at line 47 of file Expression_Hide_Inhomo_defs.hh.

The type obtained by one-level unwrapping.

Definition at line 49 of file Expression_Hide_Inhomo_defs.hh.

The raw, completely unwrapped type.

Definition at line 51 of file Expression_Hide_Inhomo_defs.hh.

Constructor & Destructor Documentation

template<typename T >
Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::Expression_Hide_Inhomo ( const raw_type expr)
explicit

Constructor.

Definition at line 32 of file Expression_Hide_Inhomo_inlines.hh.

33  : base_type(expr) {
34 }

Member Function Documentation

template<typename T >
bool Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::all_zeroes ( const Variables_Set vars) const
inline

Returns true if the coefficient of each variable in vars is zero.

Definition at line 87 of file Expression_Hide_Inhomo_inlines.hh.

87  {
88  return this->inner().all_zeroes(vars);
89 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
bool Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::all_zeroes ( dimension_type  start,
dimension_type  end 
) const
inline

Returns true if (*this)[i] is zero, for each i in [start, end).

Definition at line 93 of file Expression_Hide_Inhomo_inlines.hh.

94  {
95  if (start == end) {
96  return true;
97  }
98  if (start == 0) {
99  ++start;
100  }
101  return this->inner().all_zeroes(start, end);
102 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
const_iterator end() const
Iterator pointing after the last nonzero variable coefficient.
template<typename T >
bool Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::all_zeroes_except ( const Variables_Set vars,
dimension_type  start,
dimension_type  end 
) const
inline

Returns true if all coefficients in [start,end), except those corresponding to variables in vars, are zero.

Definition at line 168 of file Expression_Hide_Inhomo_inlines.hh.

169  {
170  if (start == end) {
171  return true;
172  }
173  if (start == 0) {
174  ++start;
175  }
176  return this->inner().all_zeroes_except(vars, start, end);
177 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
const_iterator end() const
Iterator pointing after the last nonzero variable coefficient.
template<typename T >
dimension_type Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::first_nonzero ( dimension_type  first,
dimension_type  last 
) const
inline

Returns the index of the first nonzero element, or last if there are no nonzero elements, considering only elements in [first,last).

Definition at line 154 of file Expression_Hide_Inhomo_inlines.hh.

155  {
156  if (first == last) {
157  return last;
158  }
159  if (first == 0) {
160  ++first;
161  }
162  return this->inner().first_nonzero(first, last);
163 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
Coefficient Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::gcd ( dimension_type  start,
dimension_type  end 
) const
inline

Returns the gcd of the nonzero coefficients in [start,end). If all the coefficients in this range are zero, returns zero.

Definition at line 122 of file Expression_Hide_Inhomo_inlines.hh.

References Parma_Polyhedra_Library::Coefficient_zero().

123  {
124  if (start == end) {
125  return Coefficient_zero();
126  }
127  if (start == 0) {
128  ++start;
129  }
130  return this->inner().gcd(start, end);
131 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
const_iterator end() const
Iterator pointing after the last nonzero variable coefficient.
template<typename T >
Coefficient_traits::const_reference Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::get ( dimension_type  i) const
inline

Returns the i-th coefficient.

Definition at line 69 of file Expression_Hide_Inhomo_inlines.hh.

References Parma_Polyhedra_Library::Coefficient_zero().

69  {
70  if (i == 0) {
71  return Coefficient_zero();
72  }
73  else {
74  return this->inner().get(i);
75  }
76 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
template<typename T >
Coefficient_traits::const_reference Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::get ( Variable  v) const
inline

Returns the coefficient of v.

Definition at line 80 of file Expression_Hide_Inhomo_inlines.hh.

80  {
81  return this->inner().get(v);
82 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
void Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::get_row ( Dense_Row r) const
inline

Sets r to a copy of the row as adapted by *this.

Definition at line 224 of file Expression_Hide_Inhomo_inlines.hh.

References Parma_Polyhedra_Library::Dense_Row::reset().

224  {
225  this->inner().get_row(r);
226  r.reset(0);
227 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
void Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::get_row ( Sparse_Row r) const
inline

Sets r to a copy of the row as adapted by *this.

Definition at line 231 of file Expression_Hide_Inhomo_inlines.hh.

References Parma_Polyhedra_Library::Sparse_Row::reset().

231  {
232  this->inner().get_row(r);
233  r.reset(0);
234 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
void Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::has_a_free_dimension_helper ( std::set< dimension_type > &  x) const
inline

Removes from set x all the indexes of nonzero elements in *this.

Definition at line 182 of file Expression_Hide_Inhomo_inlines.hh.

182  {
183  bool had_0 = (y.count(0) == 1);
184  this->inner().has_a_free_dimension_helper(y);
185  if (had_0) {
186  y.insert(0);
187  }
188 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
Coefficient_traits::const_reference Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::inhomogeneous_term ( ) const
inline

Returns the constant zero.

Definition at line 38 of file Expression_Hide_Inhomo_inlines.hh.

References Parma_Polyhedra_Library::Coefficient_zero().

38  {
39  // Pretend it is zero.
40  return Coefficient_zero();
41 }
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
template<typename T >
template<typename Expression >
bool Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::is_equal_to ( const Expression &  y) const
inline

Returns true if *this is equal to y.

Note that (*this == y) has a completely different meaning.

Definition at line 54 of file Expression_Hide_Inhomo_inlines.hh.

54  {
55  const dimension_type x_dim = this->space_dimension();
56  const dimension_type y_dim = y.space_dimension();
57  if (x_dim != y_dim) {
58  return false;
59  }
60  if (y.inhomogeneous_term() != 0) {
61  return false;
62  }
63  // Note that the inhomogeneous term is not compared.
64  return this->inner().is_equal_to(y, 1, x_dim + 1);
65 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
inner_type inner() const
Returns an adapter after one-level unwrapping.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
template<typename T >
template<typename Expression >
bool Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::is_equal_to ( const Expression &  y,
dimension_type  start,
dimension_type  end 
) const
inline

Returns true if (*this)[i] is equal to y[i], for each i in [start,end).

Definition at line 194 of file Expression_Hide_Inhomo_inlines.hh.

195  {
196  if (start == end) {
197  return true;
198  }
199  if (start == 0) {
200  ++start;
201  }
202  return this->inner().is_equal_to(y, start, end);
203 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
const_iterator end() const
Iterator pointing after the last nonzero variable coefficient.
template<typename T >
template<typename Expression >
bool Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::is_equal_to ( const Expression &  y,
Coefficient_traits::const_reference  c1,
Coefficient_traits::const_reference  c2,
dimension_type  start,
dimension_type  end 
) const
inline

Returns true if (*this)[i]*c1 is equal to y[i]*c2, for each i in [start,end).

Definition at line 209 of file Expression_Hide_Inhomo_inlines.hh.

212  {
213  if (start == end) {
214  return true;
215  }
216  if (start == 0) {
217  ++start;
218  }
219  return this->inner().is_equal_to(y, c1, c2, start, end);
220 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
const_iterator end() const
Iterator pointing after the last nonzero variable coefficient.
template<typename T >
bool Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::is_zero ( ) const
inline

Returns true if and only if *this is zero.

Definition at line 45 of file Expression_Hide_Inhomo_inlines.hh.

45  {
46  // Don't check the inhomogeneous_term (i.e., pretend it is zero).
47  return this->inner().all_homogeneous_terms_are_zero();
48 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
dimension_type Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::last_nonzero ( ) const
inline

Returns the index of the last nonzero element, or zero if there are no nonzero elements.

Definition at line 135 of file Expression_Hide_Inhomo_inlines.hh.

135  {
136  return this->inner().last_nonzero();
137 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
dimension_type Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::last_nonzero ( dimension_type  first,
dimension_type  last 
) const
inline

Returns the index of the last nonzero element in [first,last), or last if there are no nonzero elements.

Definition at line 141 of file Expression_Hide_Inhomo_inlines.hh.

142  {
143  if (first == last) {
144  return last;
145  }
146  if (first == 0) {
147  ++first;
148  }
149  return this->inner().last_nonzero(first, last);
150 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
dimension_type Parma_Polyhedra_Library::Expression_Hide_Inhomo< T >::num_zeroes ( dimension_type  start,
dimension_type  end 
) const
inline

Returns the number of zero coefficient in [start, end).

Definition at line 106 of file Expression_Hide_Inhomo_inlines.hh.

107  {
108  if (start == end) {
109  return 0;
110  }
111  dimension_type nz = 0;
112  if (start == 0) {
113  ++start;
114  ++nz;
115  }
116  nz += this->inner().num_zeroes(start, end);
117  return nz;
118 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
inner_type inner() const
Returns an adapter after one-level unwrapping.
const_iterator end() const
Iterator pointing after the last nonzero variable coefficient.

The documentation for this class was generated from the following files: