PPL  1.2
Linear_Form_defs.hh
Go to the documentation of this file.
1 /* Linear_Form 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_Form_defs_hh
25 #define PPL_Linear_Form_defs_hh 1
26 
27 #include "Linear_Form_types.hh"
29 #include "Variable_defs.hh"
30 #include "Box_types.hh"
31 #include "Float_defs.hh"
32 #include <vector>
33 
34 namespace Parma_Polyhedra_Library {
35 
37 
38 template <typename C>
39 void swap(Linear_Form<C>& x, Linear_Form<C>& y);
40 
41 // Put them in the namespace here to declare them friend later.
42 
44 
45 template <typename C>
46 Linear_Form<C>
47 operator+(const Linear_Form<C>& f1, const Linear_Form<C>& f2);
48 
50 
51 template <typename C>
52 Linear_Form<C>
53 operator+(Variable v, const Linear_Form<C>& f);
54 
56 
57 template <typename C>
58 Linear_Form<C>
59 operator+(const Linear_Form<C>& f, Variable v);
60 
62 
63 template <typename C>
64 Linear_Form<C>
65 operator+(const C& n, const Linear_Form<C>& f);
66 
68 
69 template <typename C>
70 Linear_Form<C>
71 operator+(const Linear_Form<C>& f, const C& n);
72 
74 
75 template <typename C>
76 Linear_Form<C>
77 operator+(const Linear_Form<C>& f);
78 
80 
81 template <typename C>
82 Linear_Form<C>
83 operator-(const Linear_Form<C>& f);
84 
86 
87 template <typename C>
88 Linear_Form<C>
89 operator-(const Linear_Form<C>& f1, const Linear_Form<C>& f2);
90 
92 
93 template <typename C>
94 Linear_Form<C>
95 operator-(Variable v, const Linear_Form<C>& f);
96 
98 
99 template <typename C>
100 Linear_Form<C>
101 operator-(const Linear_Form<C>& f, Variable v);
102 
104 
105 template <typename C>
106 Linear_Form<C>
107 operator-(const C& n, const Linear_Form<C>& f);
108 
110 
111 template <typename C>
112 Linear_Form<C>
113 operator-(const Linear_Form<C>& f, const C& n);
114 
116 
117 template <typename C>
118 Linear_Form<C>
119 operator*(const C& n, const Linear_Form<C>& f);
120 
122 
123 template <typename C>
124 Linear_Form<C>
125 operator*(const Linear_Form<C>& f, const C& n);
126 
128 
129 template <typename C>
130 Linear_Form<C>&
131 operator+=(Linear_Form<C>& f1, const Linear_Form<C>& f2);
132 
134 
139 template <typename C>
140 Linear_Form<C>&
141 operator+=(Linear_Form<C>& f, Variable v);
142 
144 
145 template <typename C>
146 Linear_Form<C>&
147 operator+=(Linear_Form<C>& f, const C& n);
148 
150 
151 template <typename C>
152 Linear_Form<C>&
153 operator-=(Linear_Form<C>& f1, const Linear_Form<C>& f2);
154 
156 
161 template <typename C>
162 Linear_Form<C>&
163 operator-=(Linear_Form<C>& f, Variable v);
164 
166 
167 template <typename C>
168 Linear_Form<C>&
169 operator-=(Linear_Form<C>& f, const C& n);
170 
172 
173 template <typename C>
174 Linear_Form<C>&
175 operator*=(Linear_Form<C>& f, const C& n);
176 
178 
183 template <typename C>
184 Linear_Form<C>&
185 operator/=(Linear_Form<C>& f, const C& n);
186 
188 
189 template <typename C>
190 bool
191 operator==(const Linear_Form<C>& x, const Linear_Form<C>& y);
192 
194 
195 template <typename C>
196 bool
197 operator!=(const Linear_Form<C>& x, const Linear_Form<C>& y);
198 
199 namespace IO_Operators {
200 
202 
203 template <typename C>
204 std::ostream& operator<<(std::ostream& s, const Linear_Form<C>& f);
205 
206 } // namespace IO_Operators
207 
208 } // namespace Parma_Polyhedra_Library
209 
211 
260 template <typename C>
262 public:
264  Linear_Form();
265 
267  Linear_Form(const Linear_Form& f);
268 
270  ~Linear_Form();
271 
273  explicit Linear_Form(const C& n);
274 
276 
282 
284  Linear_Form(const Linear_Expression& e);
285 
288 
291 
293  const C& coefficient(Variable v) const;
294 
296  const C& inhomogeneous_term() const;
297 
299  void negate();
300 
306 
309 
311 
317  bool ascii_load(std::istream& s);
318 
320  bool OK() const;
321 
323  void m_swap(Linear_Form& y);
324 
325  // Floating point analysis related methods.
326 
336  bool overflows() const;
337 
365  void relative_error(Floating_Point_Format analyzed_format,
366  Linear_Form& result) const;
367 
398  template <typename Target>
399  bool intervalize(const FP_Oracle<Target,C>& oracle, C& result) const;
400 
401 private:
403  static C zero;
404 
406  typedef std::vector<C> vec_type;
407 
409  vec_type vec;
410 
412 
416  Linear_Form(dimension_type sz, bool);
417 
427 
429  dimension_type size() const;
430 
432  void extend(dimension_type sz);
433 
436 
438  const C& operator[](dimension_type i) const;
439 
440  friend Linear_Form<C>
441  operator+<C>(const Linear_Form<C>& f1, const Linear_Form<C>& f2);
442  friend Linear_Form<C>
443  operator+<C>(const C& n, const Linear_Form<C>& f);
444  friend Linear_Form<C>
445  operator+<C>(const Linear_Form<C>& f, const C& n);
446  friend Linear_Form<C>
447  operator+<C>(Variable v, const Linear_Form<C>& f);
448 
449  friend Linear_Form<C>
450  operator-<C>(const Linear_Form<C>& f);
451 
452  friend Linear_Form<C>
453  operator-<C>(const Linear_Form<C>& f1, const Linear_Form<C>& f2);
454  friend Linear_Form<C>
455  operator-<C>(const C& n, const Linear_Form<C>& f);
456  friend Linear_Form<C>
457  operator-<C>(const Linear_Form<C>& f, const C& n);
458  friend Linear_Form<C>
459  operator-<C>(Variable v, const Linear_Form<C>& f);
460  friend Linear_Form<C>
461  operator-<C>(const Linear_Form<C>& f, Variable v);
462 
463  friend Linear_Form<C>
464  operator*<C>(const C& n, const Linear_Form<C>& f);
465  friend Linear_Form<C>
466  operator*<C>(const Linear_Form<C>& f, const C& n);
467 
468  friend Linear_Form<C>&
469  operator+=<C>(Linear_Form<C>& f1, const Linear_Form<C>& f2);
470  friend Linear_Form<C>&
471  operator+=<C>(Linear_Form<C>& f, Variable v);
472  friend Linear_Form<C>&
473  operator+=<C>(Linear_Form<C>& f, const C& n);
474 
475  friend Linear_Form<C>&
476  operator-=<C>(Linear_Form<C>& f1, const Linear_Form<C>& f2);
477  friend Linear_Form<C>&
478  operator-=<C>(Linear_Form<C>& f, Variable v);
479  friend Linear_Form<C>&
480  operator-=<C>(Linear_Form<C>& f, const C& n);
481 
482  friend Linear_Form<C>&
483  operator*=<C>(Linear_Form<C>& f, const C& n);
484 
485  friend Linear_Form<C>&
486  operator/=<C>(Linear_Form<C>& f, const C& n);
487 
488  friend bool
489  operator==<C>(const Linear_Form<C>& x, const Linear_Form<C>& y);
490 
491  friend std::ostream&
492  Parma_Polyhedra_Library::IO_Operators
493  ::operator<<<C>(std::ostream& s, const Linear_Form<C>& f);
494 };
495 
496 #include "Linear_Form_inlines.hh"
497 // Linear_Form_templates.hh is not included here on purpose.
498 
499 #endif // !defined(PPL_Linear_Form_defs_hh)
Enable_If< Is_Singleton< T >::value, Interval< B, Info > >::type operator*(const Interval< B, Info > &x, const T &y)
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
Definition: Box_inlines.hh:264
bool intervalize(const FP_Oracle< Target, C > &oracle, C &result) const
Makes result become an interval that overapproximates all the possible values of *this.
void swap(CO_Tree &x, CO_Tree &y)
An abstract class to be implemented by an external analyzer such as ECLAIR in order to provide to the...
Definition: Float_defs.hh:399
C & operator[](dimension_type i)
Returns a reference to vec[i].
std::vector< C > vec_type
Type of the container vector.
size_t dimension_type
An unsigned integral type for representing space dimensions.
const C & coefficient(Variable v) const
Returns the coefficient of v in *this.
void negate()
Negates all the coefficients of *this.
bool overflows() const
Verifies if the linear form overflows.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
bool OK() const
Checks if all the invariants are satisfied.
A dimension of the vector space.
void relative_error(Floating_Point_Format analyzed_format, Linear_Form &result) const
Computes the relative error associated to floating point computations that operate on a quantity that...
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
#define PPL_OUTPUT_DECLARATIONS
void extend(dimension_type sz)
Extends the vector of *this to size sz.
static C zero
The generic coefficient equal to the singleton zero.
A linear form with interval coefficients.
vec_type vec
The container vector.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
The entire library is confined to this namespace.
Definition: version.hh:61
Enable_If< Is_Singleton< T >::value, Interval< B, Info > >::type operator+(const Interval< B, Info > &x, const T &y)
const C & inhomogeneous_term() const
Returns the inhomogeneous term of *this.
memory_size_type total_memory_in_bytes() const
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
Linear_Form()
Default constructor: returns a copy of Linear_Form::zero().
dimension_type size() const
Gives the number of generic coefficients currently in use.
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
Enable_If< Is_Singleton< T >::value, Interval< B, Info > >::type operator-(const Interval< B, Info > &x, const T &y)
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void m_swap(Linear_Form &y)
Swaps *this with y.
static dimension_type max_space_dimension()
Returns the maximum space dimension a Linear_Form can handle.