PPL  1.2
Linear_Expression_Interface_defs.hh
Go to the documentation of this file.
1 /* Linear_Expression_Interface 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_Linear_Expression_Interface_defs_hh
25 #define PPL_Linear_Expression_Interface_defs_hh 1
26 
28 #include "Coefficient_defs.hh"
29 #include "Variable_types.hh"
30 #include "Variables_Set_types.hh"
31 #include "Dense_Row_types.hh"
32 #include "Sparse_Row_types.hh"
33 #include <vector>
34 #include <set>
35 #include <cstddef>
36 
37 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
38 
50 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
52 public:
54 
55  virtual bool OK() const = 0;
56 
58  virtual Representation representation() const = 0;
59 
62 
66  public:
67  typedef std::bidirectional_iterator_tag iterator_category;
68  typedef const Coefficient value_type;
69  typedef std::ptrdiff_t difference_type;
70  typedef value_type* pointer;
71  typedef Coefficient_traits::const_reference reference;
72 
76  virtual const_iterator_interface* clone() const = 0;
77 
78  virtual ~const_iterator_interface();
79 
83  virtual void operator++() = 0;
84 
88  virtual void operator--() = 0;
89 
91  virtual reference operator*() const = 0;
92 
94 
97  virtual Variable variable() const = 0;
98 
100 
104  virtual bool operator==(const const_iterator_interface& x) const = 0;
105  };
106 
109  virtual const_iterator_interface* begin() const = 0;
110 
113  virtual const_iterator_interface* end() const = 0;
114 
120  virtual const_iterator_interface* lower_bound(Variable v) const = 0;
121 
123  virtual dimension_type space_dimension() const = 0;
124 
126  virtual void set_space_dimension(dimension_type n) = 0;
127 
129  virtual Coefficient_traits::const_reference
130  coefficient(Variable v) const = 0;
131 
133  virtual void
134  set_coefficient(Variable v, Coefficient_traits::const_reference n) = 0;
135 
137  virtual Coefficient_traits::const_reference inhomogeneous_term() const = 0;
138 
140  virtual void
141  set_inhomogeneous_term(Coefficient_traits::const_reference n) = 0;
142 
145 
158  virtual void
160 
163  virtual void linear_combine(const Linear_Expression_Interface& y,
164  Coefficient_traits::const_reference c1,
165  Coefficient_traits::const_reference c2) = 0;
166 
169  virtual void linear_combine_lax(const Linear_Expression_Interface& y,
170  Coefficient_traits::const_reference c1,
171  Coefficient_traits::const_reference c2) = 0;
172 
174  virtual void swap_space_dimensions(Variable v1, Variable v2) = 0;
175 
177 
182  virtual void remove_space_dimensions(const Variables_Set& vars) = 0;
183 
186  virtual void shift_space_dimensions(Variable v, dimension_type n) = 0;
187 
189 
200  virtual void
201  permute_space_dimensions(const std::vector<Variable>& cycle) = 0;
202 
204  virtual bool is_zero() const = 0;
205 
210  virtual bool all_homogeneous_terms_are_zero() const = 0;
211 
216  virtual memory_size_type total_memory_in_bytes() const = 0;
217 
219  virtual memory_size_type external_memory_in_bytes() const = 0;
220 
222  virtual void ascii_dump(std::ostream& s) const = 0;
223 
229  virtual bool ascii_load(std::istream& s) = 0;
230 
233  virtual bool is_equal_to(const Linear_Expression_Interface& x) const = 0;
234 
237 
241  virtual void normalize() = 0;
242 
245  virtual void sign_normalize() = 0;
246 
251  virtual void negate(dimension_type first, dimension_type last) = 0;
252 
254  operator+=(Coefficient_traits::const_reference n) = 0;
256  operator-=(Coefficient_traits::const_reference n) = 0;
257 
259 
269  virtual int compare(const Linear_Expression_Interface& y) const = 0;
270 
274  operator+=(const Variable v) = 0;
278  operator-=(const Variable v) = 0;
280  operator*=(Coefficient_traits::const_reference n) = 0;
282  operator/=(Coefficient_traits::const_reference n) = 0;
283 
284  virtual void negate() = 0;
285 
287  add_mul_assign(Coefficient_traits::const_reference n, const Variable v) = 0;
288 
290  sub_mul_assign(Coefficient_traits::const_reference n, const Variable v) = 0;
291 
292  virtual void add_mul_assign(Coefficient_traits::const_reference factor,
293  const Linear_Expression_Interface& e2) = 0;
294 
295  virtual void sub_mul_assign(Coefficient_traits::const_reference factor,
296  const Linear_Expression_Interface& e2) = 0;
297 
298  virtual void print(std::ostream& s) const = 0;
299 
304  virtual bool all_zeroes(const Variables_Set& vars) const = 0;
305 
309  Variable first, Variable last) const = 0;
310 
311  // NOTE: This method is public, but it's not exposed in Linear_Expression,
312  // so that it can be used internally in the PPL, by friends of
313  // Linear_Expression.
315  virtual Coefficient_traits::const_reference get(dimension_type i) const = 0;
316 
317  // NOTE: This method is public, but it's not exposed in Linear_Expression,
318  // so that it can be used internally in the PPL, by friends of
319  // Linear_Expression.
321  virtual void set(dimension_type i, Coefficient_traits::const_reference n) = 0;
322 
323  // NOTE: This method is public, but it's not exposed in Linear_Expression,
324  // so that it can be used internally in the PPL, by friends of
325  // Linear_Expression.
330  virtual bool all_zeroes(dimension_type start, dimension_type end) const = 0;
331 
332  // NOTE: This method is public, but it's not exposed in Linear_Expression,
333  // so that it can be used internally in the PPL, by friends of
334  // Linear_Expression.
338  virtual dimension_type
339  num_zeroes(dimension_type start, dimension_type end) const = 0;
340 
341  // NOTE: This method is public, but it's not exposed in Linear_Expression,
342  // so that it can be used internally in the PPL, by friends of
343  // Linear_Expression.
348  virtual Coefficient gcd(dimension_type start, dimension_type end) const = 0;
349 
350  // NOTE: This method is public, but it's not exposed in Linear_Expression,
351  // so that it can be used internally in the PPL, by friends of
352  // Linear_Expression.
353  virtual void exact_div_assign(Coefficient_traits::const_reference c,
354  dimension_type start, dimension_type end) = 0;
355 
356  // NOTE: This method is public, but it's not exposed in Linear_Expression,
357  // so that it can be used internally in the PPL, by friends of
358  // Linear_Expression.
360  virtual void mul_assign(Coefficient_traits::const_reference n,
361  dimension_type start, dimension_type end) = 0;
362 
363  // NOTE: This method is public, but it's not exposed in Linear_Expression,
364  // so that it can be used internally in the PPL, by friends of
365  // Linear_Expression.
368 
381  virtual void
383 
384  // NOTE: This method is public, but it's not exposed in Linear_Expression,
385  // so that it can be used internally in the PPL, by friends of
386  // Linear_Expression.
389  virtual void linear_combine(const Linear_Expression_Interface& y,
390  Coefficient_traits::const_reference c1,
391  Coefficient_traits::const_reference c2,
392  dimension_type start, dimension_type end) = 0;
393 
394  // NOTE: This method is public, but it's not exposed in Linear_Expression,
395  // so that it can be used internally in the PPL, by friends of
396  // Linear_Expression.
399  virtual void linear_combine_lax(const Linear_Expression_Interface& y,
400  Coefficient_traits::const_reference c1,
401  Coefficient_traits::const_reference c2,
402  dimension_type start, dimension_type end) = 0;
403 
404  // NOTE: This method is public, but it's not exposed in Linear_Expression,
405  // so that it can be used internally in the PPL, by friends of
406  // Linear_Expression.
409  virtual dimension_type last_nonzero() const = 0;
410 
411  // NOTE: This method is public, but it's not exposed in Linear_Expression,
412  // so that it can be used internally in the PPL, by friends of
413  // Linear_Expression.
416  virtual dimension_type
417  last_nonzero(dimension_type first, dimension_type last) const = 0;
418 
421  virtual dimension_type
422  first_nonzero(dimension_type first, dimension_type last) const = 0;
423 
424  // NOTE: This method is public, but it's not exposed in Linear_Expression,
425  // so that it can be used internally in the PPL, by friends of
426  // Linear_Expression.
431  virtual bool
432  all_zeroes_except(const Variables_Set& vars,
433  dimension_type start, dimension_type end) const = 0;
434 
435  // NOTE: This method is public, but it's not exposed in Linear_Expression,
436  // so that it can be used internally in the PPL, by friends of
437  // Linear_Expression.
439  virtual void
442  dimension_type start, dimension_type end) const = 0;
443 
444  // NOTE: This method is public, but it's not exposed in Linear_Expression,
445  // so that it can be used internally in the PPL, by friends of
446  // Linear_Expression.
449  virtual int
451  dimension_type start, dimension_type end) const = 0;
452 
453  // NOTE: This method is public, but it's not exposed in Linear_Expression,
454  // so that it can be used internally in the PPL, by friends of
455  // Linear_Expression.
457  virtual void
458  has_a_free_dimension_helper(std::set<dimension_type>& x) const = 0;
459 
460  // NOTE: This method is public, but it's not exposed in Linear_Expression,
461  // so that it can be used internally in the PPL, by friends of
462  // Linear_Expression.
464  virtual bool is_equal_to(const Linear_Expression_Interface& x,
465  dimension_type start, dimension_type end) const = 0;
466 
467  // NOTE: This method is public, but it's not exposed in Linear_Expression,
468  // so that it can be used internally in the PPL, by friends of
469  // Linear_Expression.
472  virtual bool is_equal_to(const Linear_Expression_Interface& x,
473  Coefficient_traits::const_reference c1,
474  Coefficient_traits::const_reference c2,
475  dimension_type start, dimension_type end) const = 0;
476 
477  // NOTE: This method is public, but it is not exposed in
478  // Linear_Expression, so that it can be used internally in the PPL,
479  // by friends of Linear_Expression.
481  virtual void get_row(Dense_Row& r) const = 0;
482 
483  // NOTE: This method is public, but it is not exposed in
484  // Linear_Expression, so that it can be used internally in the PPL,
485  // by friends of Linear_Expression.
487  virtual void get_row(Sparse_Row& r) const = 0;
488 };
489 
490 #endif // !defined(PPL_Linear_Expression_Interface_defs_hh)
virtual Representation representation() const =0
Returns the current representation of this linear expression.
virtual void mul_assign(Coefficient_traits::const_reference n, dimension_type start, dimension_type end)=0
Equivalent to (*this)[i] *= n, for each i in [start, end).
virtual Linear_Expression_Interface & operator*=(Coefficient_traits::const_reference n)=0
virtual bool have_a_common_variable(const Linear_Expression_Interface &x, Variable first, Variable last) const =0
virtual bool all_homogeneous_terms_are_zero() const =0
Returns true if and only if all the homogeneous terms of *this are .
A finite sequence of coefficients.
size_t dimension_type
An unsigned integral type for representing space dimensions.
virtual void ascii_dump(std::ostream &s) const =0
Writes to s an ASCII representation of *this.
An std::set of variables' indexes.
virtual reference operator*() const =0
Returns the current element.
virtual void linear_combine(const Linear_Expression_Interface &y, Variable v)=0
virtual void set_space_dimension(dimension_type n)=0
Sets the dimension of the vector space enclosing *this to n .
A finite sparse sequence of coefficients.
virtual void get_row(Dense_Row &r) const =0
Sets r to a copy of the row that implements *this.
virtual void remove_space_dimensions(const Variables_Set &vars)=0
Removes all the specified dimensions from the expression.
virtual bool is_zero() const =0
Returns true if and only if *this is .
virtual void set_coefficient(Variable v, Coefficient_traits::const_reference n)=0
Sets the coefficient of v in *this to n.
virtual bool is_equal_to(const Linear_Expression_Interface &x) const =0
A dimension of the vector space.
virtual const_iterator_interface * end() const =0
virtual dimension_type space_dimension() const =0
Returns the dimension of the vector space enclosing *this.
virtual bool operator==(const const_iterator_interface &x) const =0
Compares *this with x .
virtual int scalar_product_sign(const Linear_Expression_Interface &y, dimension_type start, dimension_type end) const =0
virtual void shift_space_dimensions(Variable v, dimension_type n)=0
virtual void linear_combine_lax(const Linear_Expression_Interface &y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2)=0
virtual void set(dimension_type i, Coefficient_traits::const_reference n)=0
Sets the i-th coefficient to n.
virtual void has_a_free_dimension_helper(std::set< dimension_type > &x) const =0
Removes from the set x all the indexes of nonzero elements of *this.
virtual const_iterator_interface * lower_bound(Variable v) const =0
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
virtual bool ascii_load(std::istream &s)=0
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
virtual Linear_Expression_Interface & sub_mul_assign(Coefficient_traits::const_reference n, const Variable v)=0
virtual bool all_zeroes_except(const Variables_Set &vars, dimension_type start, dimension_type end) const =0
Returns true if each coefficient in [start,end) is *not* in , disregarding coefficients of variables ...
virtual Variable variable() const =0
Returns the variable of the coefficient pointed to by *this.
virtual void set_inhomogeneous_term(Coefficient_traits::const_reference n)=0
Sets the inhomogeneous term of *this to n.
virtual Coefficient gcd(dimension_type start, dimension_type end) const =0
Returns the gcd of the nonzero coefficients in [start,end). If all the coefficients in this range are...
virtual const_iterator_interface * begin() const =0
virtual void exact_div_assign(Coefficient_traits::const_reference c, dimension_type start, dimension_type end)=0
virtual Linear_Expression_Interface & add_mul_assign(Coefficient_traits::const_reference n, const Variable v)=0
virtual void permute_space_dimensions(const std::vector< Variable > &cycle)=0
Permutes the space dimensions of the expression.
virtual Linear_Expression_Interface & operator/=(Coefficient_traits::const_reference n)=0
virtual dimension_type first_nonzero(dimension_type first, dimension_type last) const =0
virtual Linear_Expression_Interface & operator+=(Coefficient_traits::const_reference n)=0
virtual memory_size_type total_memory_in_bytes() const =0
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
virtual memory_size_type external_memory_in_bytes() const =0
Returns the size in bytes of the memory managed by *this.
virtual dimension_type num_zeroes(dimension_type start, dimension_type end) const =0
Returns the number of zero coefficient in [start, end).
virtual Linear_Expression_Interface & operator-=(Coefficient_traits::const_reference n)=0
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
virtual void swap_space_dimensions(Variable v1, Variable v2)=0
Swaps the coefficients of the variables v1 and v2 .
Coefficient c
Definition: PIP_Tree.cc:64
virtual void scalar_product_assign(Coefficient &result, const Linear_Expression_Interface &y, dimension_type start, dimension_type end) const =0
Sets results to the sum of (*this)[i]*y[i], for each i in [start,end).
virtual int compare(const Linear_Expression_Interface &y) const =0
The basic comparison function.
virtual Coefficient_traits::const_reference coefficient(Variable v) const =0
Returns the coefficient of v in *this.
virtual void print(std::ostream &s) const =0
virtual bool all_zeroes(const Variables_Set &vars) const =0
Returns true if the coefficient of each variable in vars[i] is .
virtual Coefficient_traits::const_reference inhomogeneous_term() const =0
Returns the inhomogeneous term of *this.
virtual dimension_type last_nonzero() const =0