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

An adapter for Linear_Expression objects. More...

#include <Expression_Adapter_defs.hh>

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

Public Types

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

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
 

Protected Member Functions

 Expression_Adapter (const raw_type &expr)
 Constructor. More...
 

Protected Attributes

const raw_typeraw_
 The raw, completely unwrapped object subject to adaptation. More...
 

Detailed Description

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

An adapter for Linear_Expression objects.

The adapters are meant to provide read-only, customized access to the Linear_Expression members in Constraint, Generator, Congruence and Grid_Generator objects. They typically implement the user-level view of these expressions.

Note
A few methods implement low-level access routines and will take bare indexes as arguments (rather than Variable objects): when such a bare index i is zero, the inhomogeneous term is meant; when the bare index i is greater than zero, the coefficient of the variable having id i - 1 is meant.

Definition at line 56 of file Expression_Adapter_defs.hh.

Member Typedef Documentation

template<typename T>
typedef raw_type::const_iterator Parma_Polyhedra_Library::Expression_Adapter< T >::const_iterator

The type of const iterators on coefficients.

Definition at line 70 of file Expression_Adapter_defs.hh.

The type of this object.

Definition at line 60 of file Expression_Adapter_defs.hh.

template<typename T>
typedef T::const_reference Parma_Polyhedra_Library::Expression_Adapter< T >::inner_type

The type obtained by one-level unwrapping.

Definition at line 62 of file Expression_Adapter_defs.hh.

template<typename T>
typedef T::raw_type Parma_Polyhedra_Library::Expression_Adapter< T >::raw_type

The raw, completely unwrapped type.

Definition at line 64 of file Expression_Adapter_defs.hh.

Constructor & Destructor Documentation

template<typename T >
Parma_Polyhedra_Library::Expression_Adapter< T >::Expression_Adapter ( const raw_type expr)
inlineexplicitprotected

Constructor.

Definition at line 33 of file Expression_Adapter_inlines.hh.

34  : raw_(expr) {
35 }
const raw_type & raw_
The raw, completely unwrapped object subject to adaptation.

Member Function Documentation

template<typename T >
bool Parma_Polyhedra_Library::Expression_Adapter< T >::all_homogeneous_terms_are_zero ( ) const
inline

Returns true if and only if all the homogeneous terms of *this are zero.

Definition at line 93 of file Expression_Adapter_inlines.hh.

93  {
94  return inner().all_homogeneous_terms_are_zero();
95 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
bool Parma_Polyhedra_Library::Expression_Adapter< T >::all_zeroes ( const Variables_Set vars) const
inline

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

Definition at line 107 of file Expression_Adapter_inlines.hh.

Referenced by Parma_Polyhedra_Library::Box_Helpers::extract_interval_congruence().

107  {
108  return inner().all_zeroes(vars);
109 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
bool Parma_Polyhedra_Library::Expression_Adapter< 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 125 of file Expression_Adapter_inlines.hh.

126  {
127  return inner().all_zeroes(start, end);
128 }
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_Adapter< 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 167 of file Expression_Adapter_inlines.hh.

168  {
169  return inner().all_zeroes_except(vars, start, end);
170 }
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 >
Coefficient_traits::const_reference Parma_Polyhedra_Library::Expression_Adapter< T >::coefficient ( Variable  v) const
inline

Returns the coefficient of v in *this.

Definition at line 75 of file Expression_Adapter_inlines.hh.

75  {
76  return inner().coefficient(v);
77 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
Expression_Adapter< T >::const_iterator Parma_Polyhedra_Library::Expression_Adapter< T >::end ( ) const
inline

Iterator pointing after the last nonzero variable coefficient.

Definition at line 57 of file Expression_Adapter_inlines.hh.

Referenced by Parma_Polyhedra_Library::Box< ITV >::relation_with().

57  {
58  return inner().end();
59 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
dimension_type Parma_Polyhedra_Library::Expression_Adapter< 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 159 of file Expression_Adapter_inlines.hh.

Referenced by Parma_Polyhedra_Library::Box_Helpers::extract_interval_congruence().

160  {
161  return inner().first_nonzero(first, last);
162 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
Coefficient Parma_Polyhedra_Library::Expression_Adapter< T >::gcd ( dimension_type  start,
dimension_type  end 
) const
inline

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

Definition at line 139 of file Expression_Adapter_inlines.hh.

140  {
141  return inner().gcd(start, end);
142 }
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 >
Coefficient_traits::const_reference Parma_Polyhedra_Library::Expression_Adapter< T >::get ( dimension_type  i) const
inline

Returns the i -th coefficient.

Definition at line 113 of file Expression_Adapter_inlines.hh.

Referenced by Parma_Polyhedra_Library::Grid::conversion().

113  {
114  return inner().get(i);
115 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
Coefficient_traits::const_reference Parma_Polyhedra_Library::Expression_Adapter< T >::get ( Variable  v) const
inline

Returns the coefficient of variable v.

Definition at line 119 of file Expression_Adapter_inlines.hh.

119  {
120  return inner().get(v);
121 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
void Parma_Polyhedra_Library::Expression_Adapter< T >::get_row ( Dense_Row r) const
inline

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

Definition at line 201 of file Expression_Adapter_inlines.hh.

201  {
202  inner().get_row(r);
203 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
void Parma_Polyhedra_Library::Expression_Adapter< T >::get_row ( Sparse_Row r) const
inline

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

Definition at line 207 of file Expression_Adapter_inlines.hh.

207  {
208  inner().get_row(r);
209 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
void Parma_Polyhedra_Library::Expression_Adapter< 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 175 of file Expression_Adapter_inlines.hh.

175  {
176  inner().has_a_free_dimension_helper(x);
177 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
template<typename Expression >
bool Parma_Polyhedra_Library::Expression_Adapter< T >::have_a_common_variable ( const Expression &  y,
Variable  first,
Variable  last 
) const
inline

Returns true if there is a variable in [first,last) whose coefficient is nonzero in both *this and y.

Definition at line 215 of file Expression_Adapter_inlines.hh.

216  {
217  return inner().have_a_common_variable(y, first, last);
218 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
Coefficient_traits::const_reference Parma_Polyhedra_Library::Expression_Adapter< T >::inhomogeneous_term ( ) const
inline
template<typename T >
Expression_Adapter< T >::inner_type Parma_Polyhedra_Library::Expression_Adapter< T >::inner ( ) const
inline

Returns an adapter after one-level unwrapping.

Definition at line 39 of file Expression_Adapter_inlines.hh.

39  {
40  return inner_type(raw_);
41 }
T::const_reference inner_type
The type obtained by one-level unwrapping.
const raw_type & raw_
The raw, completely unwrapped object subject to adaptation.
template<typename T >
template<typename Expression >
bool Parma_Polyhedra_Library::Expression_Adapter< 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 100 of file Expression_Adapter_inlines.hh.

100  {
101  return inner().is_equal_to(y);
102 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
template<typename Expression >
bool Parma_Polyhedra_Library::Expression_Adapter< 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 183 of file Expression_Adapter_inlines.hh.

184  {
185  return inner().is_equal_to(y, start, end);
186 }
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_Adapter< 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 192 of file Expression_Adapter_inlines.hh.

195  {
196  return inner().is_equal_to(y, c1, c2, start, end);
197 }
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_Adapter< T >::is_zero ( ) const
inline

Returns true if and only if *this is zero.

Definition at line 87 of file Expression_Adapter_inlines.hh.

87  {
88  return inner().is_zero();
89 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
dimension_type Parma_Polyhedra_Library::Expression_Adapter< T >::last_nonzero ( ) const
inline

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

Definition at line 146 of file Expression_Adapter_inlines.hh.

146  {
147  return inner().last_nonzero();
148 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
dimension_type Parma_Polyhedra_Library::Expression_Adapter< 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 152 of file Expression_Adapter_inlines.hh.

153  {
154  return inner().last_nonzero(first, last);
155 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
Expression_Adapter< T >::const_iterator Parma_Polyhedra_Library::Expression_Adapter< T >::lower_bound ( Variable  v) const
inline

Iterator pointing to the first nonzero variable coefficient of a variable bigger than or equal to v.

Definition at line 63 of file Expression_Adapter_inlines.hh.

Referenced by Parma_Polyhedra_Library::Congruence::operator<<().

63  {
64  return inner().lower_bound(v);
65 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
dimension_type Parma_Polyhedra_Library::Expression_Adapter< T >::num_zeroes ( dimension_type  start,
dimension_type  end 
) const
inline

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

Definition at line 132 of file Expression_Adapter_inlines.hh.

133  {
134  return inner().num_zeroes(start, end);
135 }
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 >
Representation Parma_Polyhedra_Library::Expression_Adapter< T >::representation ( ) const
inline

Returns the current representation of *this.

Definition at line 45 of file Expression_Adapter_inlines.hh.

45  {
46  return inner().representation();
47 }
inner_type inner() const
Returns an adapter after one-level unwrapping.
template<typename T >
dimension_type Parma_Polyhedra_Library::Expression_Adapter< T >::space_dimension ( ) const
inline

Returns the dimension of the vector space enclosing *this.

Definition at line 69 of file Expression_Adapter_inlines.hh.

69  {
70  return inner().space_dimension();
71 }
inner_type inner() const
Returns an adapter after one-level unwrapping.

Member Data Documentation

template<typename T>
const raw_type& Parma_Polyhedra_Library::Expression_Adapter< T >::raw_
protected

The raw, completely unwrapped object subject to adaptation.

Definition at line 189 of file Expression_Adapter_defs.hh.


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