PPL  1.2
Expression_Adapter_defs.hh
Go to the documentation of this file.
1 /* Expression_Adapter class declaration.
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_Expression_Adapter_defs_hh
25 #define PPL_Expression_Adapter_defs_hh 1
26 
28 #include "Variable_types.hh"
29 #include "Variables_Set_types.hh"
30 #include "Dense_Row_defs.hh"
31 #include "Sparse_Row_defs.hh"
32 
33 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
34 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
37 };
38 
39 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
40 
54 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
55 template <typename T>
57  : public Expression_Adapter_Base {
58 public:
62  typedef typename T::const_reference inner_type;
64  typedef typename T::raw_type raw_type;
65 
67  inner_type inner() const;
68 
70  typedef typename raw_type::const_iterator const_iterator;
71 
74 
76  const_iterator begin() const;
77 
79  const_iterator end() const;
80 
83  const_iterator lower_bound(Variable v) const;
84 
87 
89  Coefficient_traits::const_reference coefficient(Variable v) const;
90 
92  Coefficient_traits::const_reference inhomogeneous_term() const;
93 
95  bool is_zero() const;
96 
101  bool all_homogeneous_terms_are_zero() const;
102 
107  template <typename Expression>
108  bool is_equal_to(const Expression& y) const;
109 
114  bool all_zeroes(const Variables_Set& vars) const;
115 
117  Coefficient_traits::const_reference get(dimension_type i) const;
118 
120  Coefficient_traits::const_reference get(Variable v) const;
121 
126  bool all_zeroes(dimension_type start, dimension_type end) const;
127 
130 
136 
140 
144 
148 
153  bool all_zeroes_except(const Variables_Set& vars,
154  dimension_type start, dimension_type end) const;
155 
157  void has_a_free_dimension_helper(std::set<dimension_type>& x) const;
158 
161  template <typename Expression>
162  bool is_equal_to(const Expression& y,
163  dimension_type start, dimension_type end) const;
164 
167  template <typename Expression>
168  bool is_equal_to(const Expression& y,
169  Coefficient_traits::const_reference c1,
170  Coefficient_traits::const_reference c2,
171  dimension_type start, dimension_type end) const;
172 
174  void get_row(Dense_Row& r) const;
175 
177  void get_row(Sparse_Row& r) const;
178 
181  template <typename Expression>
182  bool have_a_common_variable(const Expression& y,
183  Variable first, Variable last) const;
184 
185 protected:
187  explicit Expression_Adapter(const raw_type& expr);
189  const raw_type& raw_;
190 };
191 
192 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
193 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
195 template <typename T>
197  : public Expression_Adapter<T> {
199 public:
205  typedef typename base_type::raw_type raw_type;
206 
209 
211  explicit Expression_Adapter_Transparent(const raw_type& expr);
212 };
213 
215 
216 #endif // !defined(PPL_Expression_Adapter_defs_hh)
A transparent adapter for Linear_Expression objects.
Expression_Adapter_Transparent< T > const_reference
The type of this object.
T::raw_type raw_type
The raw, completely unwrapped type.
A finite sequence of coefficients.
size_t dimension_type
An unsigned integral type for representing space dimensions.
An std::set of variables' indexes.
An adapter for Linear_Expression objects.
T::const_reference inner_type
The type obtained by one-level unwrapping.
Expression_Adapter(const raw_type &expr)
Constructor.
bool all_zeroes(const Variables_Set &vars) const
Returns true if the coefficient of each variable in vars is zero.
bool is_equal_to(const Expression &y) const
Returns true if *this is equal to y.
A finite sparse sequence of coefficients.
void has_a_free_dimension_helper(std::set< dimension_type > &x) const
Removes from set x all the indexes of nonzero elements in *this.
A dimension of the vector space.
raw_type::const_iterator const_iterator
The type of const iterators on coefficients.
dimension_type num_zeroes(dimension_type start, dimension_type end) const
Returns the number of zero coefficient in [start, end).
dimension_type first_nonzero(dimension_type first, dimension_type last) const
inner_type inner() const
Returns an adapter after one-level unwrapping.
Representation representation() const
Returns the current representation of *this.
base_type::inner_type inner_type
The type obtained by one-level unwrapping.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
Coefficient_traits::const_reference coefficient(Variable v) const
Returns the coefficient of v in *this.
bool have_a_common_variable(const Expression &y, Variable first, Variable last) const
bool is_zero() const
Returns true if and only if *this is zero.
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...
void get_row(Dense_Row &r) const
Sets r to a copy of the row as adapted by *this.
base_type::raw_type raw_type
The raw, completely unwrapped type.
const raw_type & raw_
The raw, completely unwrapped object subject to adaptation.
Adapters' base type (for template meta-programming).
bool all_homogeneous_terms_are_zero() const
Returns true if and only if all the homogeneous terms of *this are zero.
base_type::const_iterator const_iterator
The type of const iterators on coefficients.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
const_iterator begin() const
Iterator pointing to the first nonzero variable coefficient.
Expression_Adapter< T > const_reference
The type of this object.
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 t...
Coefficient_traits::const_reference inhomogeneous_term() const
Returns the inhomogeneous term of *this.
const_iterator end() const
Iterator pointing after the last nonzero variable coefficient.