PPL  1.2
Parma_Polyhedra_Library::Float< T > Class Template Reference

#include <Float_defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::Float< T >:
Collaboration diagram for Parma_Polyhedra_Library::Float< T >:

Related Functions

(Note that these are not member functions.)

bool is_less_precise_than (Floating_Point_Format f1, Floating_Point_Format f2)
 
template<typename FP_Interval_Type >
const FP_Interval_Type & compute_absolute_error (Floating_Point_Format analyzed_format)
 

Additional Inherited Members

- Public Types inherited from Parma_Polyhedra_Library::Bool< false >
enum  const_bool_value
 

Detailed Description

template<typename T>
class Parma_Polyhedra_Library::Float< T >

Definition at line 285 of file Float_defs.hh.

Friends And Related Function Documentation

template<typename FP_Interval_Type >
const FP_Interval_Type & compute_absolute_error ( Floating_Point_Format  analyzed_format)
related

Computes the absolute error of floating point computations.

Template type parameters
  • The class template parameter FP_Interval_Type represents the type of the intervals used in the abstract domain. The interval bounds should have a floating point type.
Parameters
analyzed_formatThe floating point format used by the analyzed program.
Returns
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 35 of file Float_templates.hh.

36  {
37  typedef typename FP_Interval_Type::boundary_type analyzer_format;
38 
39  // FIXME: check if initializing caches with EMPTY is better.
40  static const FP_Interval_Type ZERO_INTERVAL = FP_Interval_Type(0);
41  // Cached results for each different analyzed format.
42  static FP_Interval_Type ieee754_half_result = ZERO_INTERVAL;
43  static FP_Interval_Type ieee754_single_result = ZERO_INTERVAL;
44  static FP_Interval_Type ieee754_double_result = ZERO_INTERVAL;
45  static FP_Interval_Type ibm_single_result = ZERO_INTERVAL;
46  static FP_Interval_Type ieee754_quad_result = ZERO_INTERVAL;
47  static FP_Interval_Type intel_double_extended_result = ZERO_INTERVAL;
48 
49  FP_Interval_Type* to_compute = NULL;
50  // Get the necessary information on the analyzed's format.
51  unsigned int f_base;
52  int f_exponent_bias;
53  unsigned int f_mantissa_bits;
54  switch (analyzed_format) {
55  case IEEE754_HALF:
56  if (ieee754_half_result != ZERO_INTERVAL) {
57  return ieee754_half_result;
58  }
59  to_compute = &ieee754_half_result;
60  f_base = float_ieee754_half::BASE;
61  f_exponent_bias = float_ieee754_half::EXPONENT_BIAS;
62  f_mantissa_bits = float_ieee754_half::MANTISSA_BITS;
63  break;
64  case IEEE754_SINGLE:
65  if (ieee754_single_result != ZERO_INTERVAL) {
66  return ieee754_single_result;
67  }
68 
69  to_compute = &ieee754_single_result;
71  f_exponent_bias = float_ieee754_single::EXPONENT_BIAS;
72  f_mantissa_bits = float_ieee754_single::MANTISSA_BITS;
73  break;
74  case IEEE754_DOUBLE:
75  if (ieee754_double_result != ZERO_INTERVAL) {
76  return ieee754_double_result;
77  }
78 
79  to_compute = &ieee754_double_result;
81  f_exponent_bias = float_ieee754_double::EXPONENT_BIAS;
82  f_mantissa_bits = float_ieee754_double::MANTISSA_BITS;
83  break;
84  case IBM_SINGLE:
85  if (ibm_single_result != ZERO_INTERVAL) {
86  return ibm_single_result;
87  }
88 
89  to_compute = &ibm_single_result;
90  f_base = float_ibm_single::BASE;
91  f_exponent_bias = float_ibm_single::EXPONENT_BIAS;
92  f_mantissa_bits = float_ibm_single::MANTISSA_BITS;
93  break;
94  case IEEE754_QUAD:
95  if (ieee754_quad_result != ZERO_INTERVAL) {
96  return ieee754_quad_result;
97  }
98 
99  to_compute = &ieee754_quad_result;
100  f_base = float_ieee754_quad::BASE;
101  f_exponent_bias = float_ieee754_quad::EXPONENT_BIAS;
102  f_mantissa_bits = float_ieee754_quad::MANTISSA_BITS;
103  break;
105  if (intel_double_extended_result != ZERO_INTERVAL) {
106  return intel_double_extended_result;
107  }
108 
109  to_compute = &intel_double_extended_result;
113  break;
114  default:
115  PPL_UNREACHABLE;
116  break;
117  }
118 
119  PPL_ASSERT(to_compute != NULL);
120 
121  // We assume that f_base is a power of 2.
122  analyzer_format omega;
123  int power = static_cast<int>(msb_position(f_base))
124  * ((1 - f_exponent_bias) - static_cast<int>(f_mantissa_bits));
125  omega = std::max(static_cast<analyzer_format>(ldexp(1.0, power)),
126  std::numeric_limits<analyzer_format>::denorm_min());
127 
128  to_compute->build(i_constraint(GREATER_OR_EQUAL, -omega),
129  i_constraint(LESS_OR_EQUAL, omega));
130  return *to_compute;
131 }
I_Constraint< T > i_constraint(I_Constraint_Rel rel, const T &v)
static const unsigned int MANTISSA_BITS
Definition: Float_defs.hh:93
static const unsigned int MANTISSA_BITS
Definition: Float_defs.hh:171
IEEE 754 half precision, 16 bits (5 exponent, 10 mantissa).
IEEE 754 quad precision, 128 bits (15 exponent, 112 mantissa).
IBM single precision, 32 bits (7 exponent, 24 mantissa).
unsigned int msb_position(unsigned long long v)
If v is nonzero, returns the position of the most significant bit in a.
Intel double extended precision, 80 bits (15 exponent, 64 mantissa)
static const unsigned int MANTISSA_BITS
Definition: Float_defs.hh:263
IEEE 754 double precision, 64 bits (11 exponent, 52 mantissa).
IEEE 754 single precision, 32 bits (8 exponent, 23 mantissa).
static const unsigned int MANTISSA_BITS
Definition: Float_defs.hh:60
template<typename T>
bool is_less_precise_than ( Floating_Point_Format  f1,
Floating_Point_Format  f2 
)
related

Returns true if and only if there is some floating point number that is representable by f2 but not by f1.

Definition at line 513 of file Float_inlines.hh.

513  {
514  return f1 < f2;
515 }

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