PPL  1.2
Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format > Class Template Referenceabstract

#include <Floating_Point_Expression_defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >:

Public Types

typedef Linear_Form< FP_Interval_Type > FP_Linear_Form
 Alias for a linear form with template argument FP_Interval_Type. More...
 
typedef Box< FP_Interval_Type > FP_Interval_Abstract_Store
 Alias for a map that associates a variable index to an interval. More...
 
typedef std::map< dimension_type, FP_Linear_FormFP_Linear_Form_Abstract_Store
 Alias for a map that associates a variable index to a linear form. More...
 
typedef FP_Interval_Type::boundary_type boundary_type
 The floating point format used by the analyzer. More...
 
typedef FP_Interval_Type::info_type info_type
 The interval policy used by FP_Interval_Type. More...
 

Public Member Functions

virtual ~Floating_Point_Expression ()
 Destructor. More...
 
virtual bool linearize (const FP_Interval_Abstract_Store &int_store, const FP_Linear_Form_Abstract_Store &lf_store, FP_Linear_Form &result) const =0
 Linearizes a floating point expression. More...
 

Static Public Member Functions

static bool overflows (const FP_Linear_Form &lf)
 Verifies if a given linear form overflows. More...
 
static void relative_error (const FP_Linear_Form &lf, FP_Linear_Form &result)
 Computes the relative error of a given linear form. More...
 
static void intervalize (const FP_Linear_Form &lf, const FP_Interval_Abstract_Store &store, FP_Interval_Type &result)
 Makes result become an interval that overapproximates all the possible values of lf in the interval abstract store store. More...
 

Static Public Attributes

static FP_Interval_Type absolute_error = compute_absolute_error()
 Absolute error. More...
 

Static Private Member Functions

static FP_Interval_Type compute_absolute_error ()
 Computes the absolute error. More...
 

Detailed Description

template<typename FP_Interval_Type, typename FP_Format>
class Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >

\ A floating point expression on a given format.

This class represents a concrete floating point expression. This includes constants, floating point variables, binary and unary arithmetic operators.

Template type parameters
  • The class template type parameter FP_Interval_Type represents the type of the intervals used in the abstract domain. The interval bounds should have a floating point type.
  • The class template type parameter FP_Format represents the floating point format used in the concrete domain. This parameter must be a struct similar to the ones defined in file Float_defs.hh, even though it is sufficient to define the three fields BASE, MANTISSA_BITS and EXPONENT_BIAS.

Definition at line 55 of file Floating_Point_Expression_defs.hh.

Member Typedef Documentation

template<typename FP_Interval_Type, typename FP_Format>
typedef FP_Interval_Type::boundary_type Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::boundary_type

The floating point format used by the analyzer.

Definition at line 81 of file Floating_Point_Expression_defs.hh.

template<typename FP_Interval_Type, typename FP_Format>
typedef Box<FP_Interval_Type> Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::FP_Interval_Abstract_Store

Alias for a map that associates a variable index to an interval.

Alias for a Box storing lower and upper bounds for floating point variables.

The type a linear form abstract store associating each variable with an interval that correctly approximates its value.

Definition at line 70 of file Floating_Point_Expression_defs.hh.

template<typename FP_Interval_Type, typename FP_Format>
typedef Linear_Form<FP_Interval_Type> Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::FP_Linear_Form

Alias for a linear form with template argument FP_Interval_Type.

Definition at line 60 of file Floating_Point_Expression_defs.hh.

template<typename FP_Interval_Type, typename FP_Format>
typedef std::map<dimension_type, FP_Linear_Form> Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::FP_Linear_Form_Abstract_Store

Alias for a map that associates a variable index to a linear form.

The type a linear form abstract store associating each variable with a linear form that correctly approximates its value.

Definition at line 78 of file Floating_Point_Expression_defs.hh.

template<typename FP_Interval_Type, typename FP_Format>
typedef FP_Interval_Type::info_type Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::info_type

The interval policy used by FP_Interval_Type.

Definition at line 84 of file Floating_Point_Expression_defs.hh.

Constructor & Destructor Documentation

template<typename FP_Interval_Type , typename FP_Format >
Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::~Floating_Point_Expression ( )
inlinevirtual

Destructor.

Definition at line 35 of file Floating_Point_Expression_inlines.hh.

35 {}

Member Function Documentation

template<typename FP_Interval_Type , typename FP_Format >
FP_Interval_Type Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::compute_absolute_error ( )
staticprivate

Computes the absolute error.

Static helper method that is used to compute the value of the public static field absolute_error.

Returns
The interval $[-\omega, \omega]$ corresponding to the value of absolute_error

Definition at line 95 of file Floating_Point_Expression_templates.hh.

References Parma_Polyhedra_Library::GREATER_OR_EQUAL, Parma_Polyhedra_Library::i_constraint(), and Parma_Polyhedra_Library::LESS_OR_EQUAL.

95  {
96  typedef typename Floating_Point_Expression<FP_Interval_Type, FP_Format>
97  ::boundary_type Boundary;
98  boundary_type omega;
99  omega = std::max(pow(static_cast<Boundary>(FP_Format::BASE),
100  static_cast<Boundary>(1 - FP_Format::EXPONENT_BIAS
101  - FP_Format::MANTISSA_BITS)),
102  std::numeric_limits<Boundary>::denorm_min());
103  FP_Interval_Type result;
104  result.build(i_constraint(GREATER_OR_EQUAL, -omega),
105  i_constraint(LESS_OR_EQUAL, omega));
106  return result;
107 }
FP_Interval_Type::boundary_type boundary_type
The floating point format used by the analyzer.
I_Constraint< T > i_constraint(I_Constraint_Rel rel, const T &v)
template<typename FP_Interval_Type, typename FP_Format >
void Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::intervalize ( const FP_Linear_Form lf,
const FP_Interval_Abstract_Store store,
FP_Interval_Type &  result 
)
static

Makes result become an interval that overapproximates all the possible values of lf in the interval abstract store store.

Parameters
lfThe linear form to aproximate.
storeThe abstract store.
resultThe linear form that will be modified.

This method makes result become $\iota(lf)\rho^{\#}$, that is an interval defined as:

\[ \iota\left(i + \sum_{v \in \cV}i_{v}v\right)\rho^{\#} \defeq i \asifp \left(\bigoplus_{v \in \cV}{}^{\#}i_{v} \amifp \rho^{\#}(v)\right) \]

Definition at line 76 of file Floating_Point_Expression_templates.hh.

References Parma_Polyhedra_Library::Linear_Form< C >::coefficient(), Parma_Polyhedra_Library::Box< ITV >::get_interval(), Parma_Polyhedra_Library::Linear_Form< C >::inhomogeneous_term(), Parma_Polyhedra_Library::Linear_Form< C >::space_dimension(), and Parma_Polyhedra_Library::Box< ITV >::space_dimension().

78  {
79  result = FP_Interval_Type(lf.inhomogeneous_term());
80  dimension_type dimension = lf.space_dimension();
81  assert(dimension <= store.space_dimension());
82  for (dimension_type i = 0; i < dimension; ++i) {
83  FP_Interval_Type current_addend = lf.coefficient(Variable(i));
84  const FP_Interval_Type& curr_int = store.get_interval(Variable(i));
85  current_addend *= curr_int;
86  result += current_addend;
87  }
88 
89  return;
90 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
template<typename FP_Interval_Type, typename FP_Format>
virtual bool Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::linearize ( const FP_Interval_Abstract_Store int_store,
const FP_Linear_Form_Abstract_Store lf_store,
FP_Linear_Form result 
) const
pure virtual

Linearizes a floating point expression.

Makes result become a linear form that correctly approximates the value of the floating point expression in the given composite abstract store.

Parameters
int_storeThe interval abstract store.
lf_storeThe linear form abstract store.
resultBecomes the linearized expression.
Returns
true if the linearization succeeded, false otherwise.

Formally, if *this represents the expression $e$, int_store represents the interval abstract store $\rho^{\#}$ and lf_store represents the linear form abstract store $\rho^{\#}_l$, then result will become $\linexprenv{e}{\rho^{\#}}{\rho^{\#}_l}$ if the linearization succeeds.

All variables occurring in the floating point expression MUST have an associated interval in int_store. If this precondition is not met, calling the method causes an undefined behavior.

Implemented in Parma_Polyhedra_Library::Multiplication_Floating_Point_Expression< FP_Interval_Type, FP_Format >, Parma_Polyhedra_Library::Division_Floating_Point_Expression< FP_Interval_Type, FP_Format >, Parma_Polyhedra_Library::Difference_Floating_Point_Expression< FP_Interval_Type, FP_Format >, Parma_Polyhedra_Library::Sum_Floating_Point_Expression< FP_Interval_Type, FP_Format >, Parma_Polyhedra_Library::Opposite_Floating_Point_Expression< FP_Interval_Type, FP_Format >, Parma_Polyhedra_Library::Cast_Floating_Point_Expression< FP_Interval_Type, FP_Format >, Parma_Polyhedra_Library::Constant_Floating_Point_Expression< FP_Interval_Type, FP_Format >, and Parma_Polyhedra_Library::Variable_Floating_Point_Expression< FP_Interval_Type, FP_Format >.

template<typename FP_Interval_Type , typename FP_Format >
bool Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::overflows ( const FP_Linear_Form lf)
inlinestatic

Verifies if a given linear form overflows.

Parameters
lfThe linear form to verify.
Returns
Returns false if all coefficients in lf are bounded, true otherwise.

Definition at line 40 of file Floating_Point_Expression_inlines.hh.

References Parma_Polyhedra_Library::Linear_Form< C >::coefficient(), Parma_Polyhedra_Library::Linear_Form< C >::inhomogeneous_term(), and Parma_Polyhedra_Library::Linear_Form< C >::space_dimension().

40  {
41  if (!lf.inhomogeneous_term().is_bounded()) {
42  return true;
43  }
44 
45  dimension_type dimension = lf.space_dimension();
46  for (dimension_type i = 0; i < dimension; ++i) {
47  if (!lf.coefficient(Variable(i)).is_bounded()) {
48  return true;
49  }
50  }
51 
52  return false;
53 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
template<typename FP_Interval_Type , typename FP_Format >
void Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::relative_error ( const FP_Linear_Form lf,
FP_Linear_Form result 
)
static

Computes the relative error of a given linear form.

Static helper method that is used by linearize to account for the relative errors on lf.

Parameters
lfThe linear form used to compute the relative error.
resultBecomes the linear form corresponding to a relative error committed on lf.

This method makes result become a linear form obtained by evaluating the function $\varepsilon_{\mathbf{f}}(l)$ on the linear form lf. This function is defined such as:

\[ \varepsilon_{\mathbf{f}}\left([a, b]+\sum_{v \in \cV}[a_{v}, b_{v}]v\right) \defeq (\textrm{max}(|a|, |b|) \amifp [-\beta^{-\textrm{p}}, \beta^{-\textrm{p}}]) + \sum_{v \in \cV}(\textrm{max}(|a_{v}|,|b_{v}|) \amifp [-\beta^{-\textrm{p}}, \beta^{-\textrm{p}}])v \]

where p is the fraction size in bits for the format $\mathbf{f}$ and $\beta$ the base.

Definition at line 36 of file Floating_Point_Expression_templates.hh.

References Parma_Polyhedra_Library::Linear_Form< C >::coefficient(), Parma_Polyhedra_Library::GREATER_OR_EQUAL, Parma_Polyhedra_Library::i_constraint(), Parma_Polyhedra_Library::Linear_Form< C >::inhomogeneous_term(), Parma_Polyhedra_Library::LESS_OR_EQUAL, and Parma_Polyhedra_Library::Linear_Form< C >::space_dimension().

36  {
37 
38  FP_Interval_Type error_propagator;
39  boundary_type lb = -pow(FP_Format::BASE,
40  -static_cast<typename Floating_Point_Expression<FP_Interval_Type, FP_Format>
41  ::boundary_type>(FP_Format::MANTISSA_BITS));
42  error_propagator.build(i_constraint(GREATER_OR_EQUAL, lb),
44 
45  // Handle the inhomogeneous term.
46  const FP_Interval_Type* current_term = &lf.inhomogeneous_term();
47  assert(current_term->is_bounded());
48 
49  FP_Interval_Type
50  current_multiplier(std::max(std::abs(current_term->lower()),
51  std::abs(current_term->upper())));
52  FP_Linear_Form current_result_term(current_multiplier);
53  current_result_term *= error_propagator;
54  result = FP_Linear_Form(current_result_term);
55 
56  // Handle the other terms.
57  dimension_type dimension = lf.space_dimension();
58  for (dimension_type i = 0; i < dimension; ++i) {
59  current_term = &lf.coefficient(Variable(i));
60  assert(current_term->is_bounded());
61  current_multiplier
62  = FP_Interval_Type(std::max(std::abs(current_term->lower()),
63  std::abs(current_term->upper())));
64  current_result_term = FP_Linear_Form(Variable(i));
65  current_result_term *= current_multiplier;
66  current_result_term *= error_propagator;
67  result += current_result_term;
68  }
69 
70  return;
71 }
FP_Interval_Type::boundary_type boundary_type
The floating point format used by the analyzer.
I_Constraint< T > i_constraint(I_Constraint_Rel rel, const T &v)
size_t dimension_type
An unsigned integral type for representing space dimensions.
Linear_Form< FP_Interval_Type > FP_Linear_Form
Alias for a linear form with template argument FP_Interval_Type.

Member Data Documentation

template<typename FP_Interval_Type, typename FP_Format>
FP_Interval_Type Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::absolute_error = compute_absolute_error()
static

Absolute error.

Represents the interval $[-\omega, \omega]$ where $\omega$ is the smallest non-zero positive number in the less precise floating point format between the analyzer format and the analyzed format.

Definition at line 126 of file Floating_Point_Expression_defs.hh.


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