PPL  1.2
Variable_Floating_Point_Expression_inlines.hh
Go to the documentation of this file.
1 /* Variable_Floating_Point_Expression class implementation: inline functions.
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_Variable_Floating_Point_Expression_inlines_hh
25 #define PPL_Variable_Floating_Point_Expression_inlines_hh 1
26 
27 #include "globals_defs.hh"
28 
29 namespace Parma_Polyhedra_Library {
30 
31 template <typename FP_Interval_Type, typename FP_Format>
32 inline
35  : variable_index(v_index) {}
36 
37 template <typename FP_Interval_Type, typename FP_Format>
38 inline
41 
42 template <typename FP_Interval_Type, typename FP_Format>
43 inline void
46  using std::swap;
47  swap(variable_index, y.variable_index);
48 }
49 
50 template <typename FP_Interval_Type, typename FP_Format>
51 inline bool
54  const FP_Linear_Form_Abstract_Store& lf_store,
55  FP_Linear_Form& result) const {
56  typename FP_Linear_Form_Abstract_Store::const_iterator
57  variable_value = lf_store.find(variable_index);
58 
59  if (variable_value == lf_store.end()) {
60  result = FP_Linear_Form(Variable(variable_index));
61  return true;
62  }
63 
64  result = FP_Linear_Form(variable_value->second);
65  return !this->overflows(result);
66 }
67 
68 template <typename FP_Interval_Type, typename FP_Format>
69 inline void
72  FP_Linear_Form_Abstract_Store& lf_store) const {
73  for (typename FP_Linear_Form_Abstract_Store::iterator
74  i = lf_store.begin(); i != lf_store.end(); ) {
75  if ((i->second).coefficient(Variable(variable_index)) != 0) {
76  i = lf_store.erase(i);
77  }
78  else {
79  ++i;
80  }
81  }
82  lf_store[variable_index] = lf;
83  return;
84 }
85 
87 template <typename FP_Interval_Type, typename FP_Format>
88 inline void
91  x.m_swap(y);
92 }
93 
94 } // namespace Parma_Polyhedra_Library
95 
96 #endif // !defined(PPL_Variable_Floating_Point_Expression_inlines_hh)
void swap(CO_Tree &x, CO_Tree &y)
size_t dimension_type
An unsigned integral type for representing space dimensions.
void linear_form_assign(const FP_Linear_Form &lf, FP_Linear_Form_Abstract_Store &lf_store) const
Assigns a linear form to the variable with the same index of *this in a given linear form abstract st...
A dimension of the vector space.
A linear form with interval coefficients.
Variable_Floating_Point_Expression(const dimension_type v_index)
Constructor with a parameter: builds the variable floating point expression corresponding to the vari...
A not necessarily closed, iso-oriented hyperrectangle.
Definition: Box_defs.hh:299
The entire library is confined to this namespace.
Definition: version.hh:61
void swap(Variable_Floating_Point_Expression< FP_Interval_Type, FP_Format > &x, Variable_Floating_Point_Expression< FP_Interval_Type, FP_Format > &y)
void m_swap(Variable_Floating_Point_Expression &y)
Swaps *this with y.
std::map< dimension_type, FP_Linear_Form > FP_Linear_Form_Abstract_Store
Alias for a map that associates a variable index to a linear form.
bool linearize(const FP_Interval_Abstract_Store &int_store, const FP_Linear_Form_Abstract_Store &lf_store, FP_Linear_Form &result) const
Linearizes the expression in a given abstract store.