|
PPL
0.12.1
|
A linear form with interval coefficients. More...
#include <Linear_Form.defs.hh>
Public Member Functions | |
| Linear_Form () | |
| Default constructor: returns a copy of Linear_Form::zero(). | |
| Linear_Form (const Linear_Form &f) | |
| Ordinary copy constructor. | |
| ~Linear_Form () | |
| Destructor. | |
| Linear_Form (const C &n) | |
Builds the linear form corresponding to the inhomogeneous term n. | |
| Linear_Form (Variable v) | |
Builds the linear form corresponding to the variable v. | |
| Linear_Form (const Linear_Expression &e) | |
Builds a linear form approximating the linear expression e. | |
| dimension_type | space_dimension () const |
Returns the dimension of the vector space enclosing *this. | |
| const C & | coefficient (Variable v) const |
Returns the coefficient of v in *this. | |
| const C & | inhomogeneous_term () const |
Returns the inhomogeneous term of *this. | |
| void | negate () |
Negates all the coefficients 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. | |
| memory_size_type | external_memory_in_bytes () const |
Returns the size in bytes of the memory managed by *this. | |
| void | ascii_dump () const |
Writes to std::cerr an ASCII representation of *this. | |
| void | ascii_dump (std::ostream &s) const |
Writes to s an ASCII representation of *this. | |
| void | print () const |
Prints *this to std::cerr using operator<<. | |
| bool | ascii_load (std::istream &s) |
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise. | |
| bool | OK () const |
| Checks if all the invariants are satisfied. | |
| void | m_swap (Linear_Form &y) |
Swaps *this with y. | |
| bool | overflows () const |
| Verifies if the linear form overflows. | |
| 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 is overapproximated by *this. | |
| template<typename Target > | |
| bool | intervalize (const FP_Oracle< Target, C > &oracle, C &result) const |
Makes result become an interval that overapproximates all the possible values of *this. | |
Static Public Member Functions | |
| static dimension_type | max_space_dimension () |
| Returns the maximum space dimension a Linear_Form can handle. | |
Private Types | |
| typedef std::vector< C > | vec_type |
| Type of the container vector. | |
Private Member Functions | |
| Linear_Form (dimension_type sz, bool) | |
| Implementation sizing constructor. | |
| Linear_Form (Variable v, Variable w) | |
Builds the linear form corresponding to the difference of v and w. | |
| dimension_type | size () const |
| Gives the number of generic coefficients currently in use. | |
| void | extend (dimension_type sz) |
Extends the vector of *this to size sz. | |
| C & | operator[] (dimension_type i) |
Returns a reference to vec[i]. | |
| const C & | operator[] (dimension_type i) const |
Returns a const reference to vec[i]. | |
Private Attributes | |
| vec_type | vec |
| The container vector. | |
Static Private Attributes | |
| static C | zero |
| The generic coefficient equal to the singleton zero. | |
Friends | |
| Linear_Form< C > | operator+ (const Linear_Form< C > &f1, const Linear_Form< C > &f2) |
| Linear_Form< C > | operator+ (const C &n, const Linear_Form< C > &f) |
| Linear_Form< C > | operator+ (const Linear_Form< C > &f, const C &n) |
| Linear_Form< C > | operator+ (Variable v, const Linear_Form< C > &f) |
| Linear_Form< C > | operator- (const Linear_Form< C > &f) |
| Linear_Form< C > | operator- (const Linear_Form< C > &f1, const Linear_Form< C > &f2) |
| Linear_Form< C > | operator- (const C &n, const Linear_Form< C > &f) |
| Linear_Form< C > | operator- (const Linear_Form< C > &f, const C &n) |
| Linear_Form< C > | operator- (Variable v, const Linear_Form< C > &f) |
| Linear_Form< C > | operator- (const Linear_Form< C > &f, Variable v) |
| Linear_Form< C > | operator* (const C &n, const Linear_Form< C > &f) |
| Linear_Form< C > | operator* (const Linear_Form< C > &f, const C &n) |
| Linear_Form< C > & | operator+= (Linear_Form< C > &f1, const Linear_Form< C > &f2) |
| Linear_Form< C > & | operator+= (Linear_Form< C > &f, Variable v) |
| Linear_Form< C > & | operator+= (Linear_Form< C > &f, const C &n) |
| Linear_Form< C > & | operator-= (Linear_Form< C > &f1, const Linear_Form< C > &f2) |
| Linear_Form< C > & | operator-= (Linear_Form< C > &f, Variable v) |
| Linear_Form< C > & | operator-= (Linear_Form< C > &f, const C &n) |
| Linear_Form< C > & | operator*= (Linear_Form< C > &f, const C &n) |
| Linear_Form< C > & | operator/= (Linear_Form< C > &f, const C &n) |
| bool | operator== (const Linear_Form< C > &x, const Linear_Form< C > &y) |
| std::ostream & | Parma_Polyhedra_Library::IO_Operators::operator (std::ostream &s, const Linear_Form< C > &f) |
Related Functions | |
(Note that these are not member functions.) | |
| template<typename FP_Interval_Type > | |
| void | discard_occurrences (std::map< dimension_type, Linear_Form< FP_Interval_Type > > &lf_store, Variable var) |
| template<typename FP_Interval_Type > | |
| void | affine_form_image (std::map< dimension_type, Linear_Form< FP_Interval_Type > > &lf_store, Variable var, const Linear_Form< FP_Interval_Type > &lf) |
| template<typename FP_Interval_Type > | |
| void | upper_bound_assign (std::map< dimension_type, Linear_Form< FP_Interval_Type > > &ls1, const std::map< dimension_type, Linear_Form< FP_Interval_Type > > &ls2) |
| template<typename C > | |
| void | swap (Linear_Form< C > &x, Linear_Form< C > &y) |
Swaps x with y. | |
| template<typename C > | |
| Linear_Form< C > | operator+ (const Linear_Form< C > &f1, const Linear_Form< C > &f2) |
Returns the linear form f1 + f2. | |
| template<typename C > | |
| Linear_Form< C > | operator+ (Variable v, const Linear_Form< C > &f) |
Returns the linear form v + f. | |
| template<typename C > | |
| Linear_Form< C > | operator+ (const Linear_Form< C > &f, Variable v) |
Returns the linear form f + v. | |
| template<typename C > | |
| Linear_Form< C > | operator+ (const C &n, const Linear_Form< C > &f) |
Returns the linear form n + f. | |
| template<typename C > | |
| Linear_Form< C > | operator+ (const Linear_Form< C > &f, const C &n) |
Returns the linear form f + n. | |
| template<typename C > | |
| Linear_Form< C > | operator+ (const Linear_Form< C > &f) |
Returns the linear form f. | |
| template<typename C > | |
| Linear_Form< C > | operator- (const Linear_Form< C > &f) |
Returns the linear form - f. | |
| template<typename C > | |
| Linear_Form< C > | operator- (const Linear_Form< C > &f1, const Linear_Form< C > &f2) |
Returns the linear form f1 - f2. | |
| template<typename C > | |
| Linear_Form< C > | operator- (Variable v, const Linear_Form< C > &f) |
Returns the linear form v - f. | |
| template<typename C > | |
| Linear_Form< C > | operator- (const Linear_Form< C > &f, Variable v) |
Returns the linear form f - v. | |
| template<typename C > | |
| Linear_Form< C > | operator- (const C &n, const Linear_Form< C > &f) |
Returns the linear form n - f. | |
| template<typename C > | |
| Linear_Form< C > | operator- (const Linear_Form< C > &f, const C &n) |
Returns the linear form f - n. | |
| template<typename C > | |
| Linear_Form< C > | operator* (const C &n, const Linear_Form< C > &f) |
Returns the linear form n * f. | |
| template<typename C > | |
| Linear_Form< C > | operator* (const Linear_Form< C > &f, const C &n) |
Returns the linear form f * n. | |
| template<typename C > | |
| Linear_Form< C > & | operator+= (Linear_Form< C > &f1, const Linear_Form< C > &f2) |
Returns the linear form f1 + f2 and assigns it to e1. | |
| template<typename C > | |
| Linear_Form< C > & | operator+= (Linear_Form< C > &f, Variable v) |
Returns the linear form f + v and assigns it to f. | |
| template<typename C > | |
| Linear_Form< C > & | operator+= (Linear_Form< C > &f, const C &n) |
Returns the linear form f + n and assigns it to f. | |
| template<typename C > | |
| Linear_Form< C > & | operator-= (Linear_Form< C > &f1, const Linear_Form< C > &f2) |
Returns the linear form f1 - f2 and assigns it to f1. | |
| template<typename C > | |
| Linear_Form< C > & | operator-= (Linear_Form< C > &f, Variable v) |
Returns the linear form f - v and assigns it to f. | |
| template<typename C > | |
| Linear_Form< C > & | operator-= (Linear_Form< C > &f, const C &n) |
Returns the linear form f - n and assigns it to f. | |
| template<typename C > | |
| Linear_Form< C > & | operator*= (Linear_Form< C > &f, const C &n) |
Returns the linear form n * f and assigns it to f. | |
| template<typename C > | |
| Linear_Form< C > & | operator/= (Linear_Form< C > &f, const C &n) |
Returns the linear form f / n and assigns it to f. | |
| template<typename C > | |
| bool | operator== (const Linear_Form< C > &x, const Linear_Form< C > &y) |
Returns true if and only if x and y are equal. | |
| template<typename C > | |
| bool | operator!= (const Linear_Form< C > &x, const Linear_Form< C > &y) |
Returns true if and only if x and y are different. | |
| template<typename C > | |
| std::ostream & | operator<< (std::ostream &s, const Linear_Form< C > &f) |
| Output operator. | |
| template<typename C > | |
| Linear_Form< C > | operator+ (const Linear_Form< C > &f) |
| template<typename C > | |
| Linear_Form< C > | operator+ (const Linear_Form< C > &f, const C &n) |
| template<typename C > | |
| Linear_Form< C > | operator+ (const Linear_Form< C > &f, const Variable v) |
| template<typename C > | |
| Linear_Form< C > | operator- (const Linear_Form< C > &f, const C &n) |
| template<typename C > | |
| Linear_Form< C > | operator- (const Variable v, const Variable w) |
| template<typename C > | |
| Linear_Form< C > | operator* (const Linear_Form< C > &f, const C &n) |
| template<typename C > | |
| Linear_Form< C > & | operator+= (Linear_Form< C > &f, const C &n) |
| template<typename C > | |
| Linear_Form< C > & | operator-= (Linear_Form< C > &f, const C &n) |
| template<typename C > | |
| bool | operator!= (const Linear_Form< C > &x, const Linear_Form< C > &y) |
| template<typename C > | |
| void | swap (Linear_Form< C > &x, Linear_Form< C > &y) |
| template<typename C > | |
| Linear_Form< C > | operator+ (const Linear_Form< C > &f1, const Linear_Form< C > &f2) |
| template<typename C > | |
| Linear_Form< C > | operator+ (const Variable v, const Linear_Form< C > &f) |
| template<typename C > | |
| Linear_Form< C > | operator+ (const C &n, const Linear_Form< C > &f) |
| template<typename C > | |
| Linear_Form< C > | operator- (const Linear_Form< C > &f) |
| template<typename C > | |
| Linear_Form< C > | operator- (const Linear_Form< C > &f1, const Linear_Form< C > &f2) |
| template<typename C > | |
| Linear_Form< C > | operator- (const Variable v, const Linear_Form< C > &f) |
| template<typename C > | |
| Linear_Form< C > | operator- (const Linear_Form< C > &f, const Variable v) |
| template<typename C > | |
| Linear_Form< C > | operator- (const C &n, const Linear_Form< C > &f) |
| template<typename C > | |
| Linear_Form< C > | operator* (const C &n, const Linear_Form< C > &f) |
| template<typename C > | |
| Linear_Form< C > & | operator+= (Linear_Form< C > &f1, const Linear_Form< C > &f2) |
| template<typename C > | |
| Linear_Form< C > & | operator+= (Linear_Form< C > &f, const Variable v) |
| template<typename C > | |
| Linear_Form< C > & | operator-= (Linear_Form< C > &f1, const Linear_Form< C > &f2) |
| template<typename C > | |
| Linear_Form< C > & | operator-= (Linear_Form< C > &f, const Variable v) |
| template<typename C > | |
| Linear_Form< C > & | operator*= (Linear_Form< C > &f, const C &n) |
| template<typename C > | |
| Linear_Form< C > & | operator/= (Linear_Form< C > &f, const C &n) |
| template<typename C > | |
| std::ostream & | operator<< (std::ostream &s, const Linear_Form< C > &f) |
A linear form with interval coefficients.
An object of the class Linear_Form represents the interval linear form
where
is the dimension of the vector space, each
is the coefficient of the
-th variable
and
is the inhomogeneous term. The coefficients and the inhomogeneous term of the linear form have the template parameter C as their type. C must be the type of an Interval.
C. Available operators include binary addition and subtraction, as well as multiplication and division by a coefficient. The space dimension of a linear form is defined as the highest variable dimension among variables that have a nonzero coefficient in the linear form, or zero if no such variable exists. The space dimension for each variable
is given by
.T of an Interval with floating point coefficients (though any integral type may also be used), the following code builds the interval linear form
with space dimension 6: Variable x5(5); Variable x2(2); T x5_coefficient; x5_coefficient.lower() = 2.0; x5_coefficient.upper() = 3.0; T inhomogeneous_term; inhomogeneous_term.lower() = 4.0; inhomogeneous_term.upper() = 8.0; Linear_Form<T> lf(x2); lf = -lf; lf += Linear_Form<T>(x2); Linear_Form<T> lf_x5(x5); lf_x5 *= x5_coefficient; lf += lf_x5;
lf_x5 is created with space dimension 6, while lf is created with space dimension 0 and then extended first to space dimension 2 when x2 is subtracted and finally to space dimension 6 when lf_x5 is added. Definition at line 261 of file Linear_Form.defs.hh.
|
private |
Type of the container vector.
Definition at line 406 of file Linear_Form.defs.hh.
|
inline |
Default constructor: returns a copy of Linear_Form::zero().
Definition at line 41 of file Linear_Form.inlines.hh.
References Parma_Polyhedra_Library::compute_capacity(), and Parma_Polyhedra_Library::Linear_Form< C >::vec.
: vec(1, zero) { vec.reserve(compute_capacity(1, vec_type().max_size())); }
|
inline |
|
inline |
|
inlineexplicit |
Builds the linear form corresponding to the inhomogeneous term n.
Definition at line 80 of file Linear_Form.inlines.hh.
References Parma_Polyhedra_Library::compute_capacity(), and Parma_Polyhedra_Library::Linear_Form< C >::vec.
: vec(1, n) { vec.reserve(compute_capacity(1, vec_type().max_size())); }
| Parma_Polyhedra_Library::Linear_Form< C >::Linear_Form | ( | Variable | v | ) |
Builds the linear form corresponding to the variable v.
| std::length_error | Thrown if the space dimension of v exceeds Linear_Form::max_space_dimension(). |
Definition at line 37 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::compute_capacity(), Parma_Polyhedra_Library::Linear_Form< C >::max_space_dimension(), Parma_Polyhedra_Library::Variable::space_dimension(), Parma_Polyhedra_Library::Linear_Form< C >::vec, and Parma_Polyhedra_Library::Linear_Form< C >::zero.
: vec() { const dimension_type space_dim = v.space_dimension(); if (space_dim > max_space_dimension()) throw std::length_error("Linear_Form<C>::" "Linear_Form(v):\n" "v exceeds the maximum allowed " "space dimension."); vec.reserve(compute_capacity(space_dim+1, vec_type().max_size())); vec.resize(space_dim+1, zero); vec[v.space_dimension()] = C(typename C::boundary_type(1)); }
| Parma_Polyhedra_Library::Linear_Form< C >::Linear_Form | ( | const Linear_Expression & | e | ) |
Builds a linear form approximating the linear expression e.
Definition at line 70 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::Linear_Expression::coefficient(), Parma_Polyhedra_Library::compute_capacity(), Parma_Polyhedra_Library::Linear_Expression::inhomogeneous_term(), Parma_Polyhedra_Library::Linear_Form< C >::max_space_dimension(), Parma_Polyhedra_Library::Linear_Expression::space_dimension(), and Parma_Polyhedra_Library::Linear_Form< C >::vec.
: vec() { const dimension_type space_dim = e.space_dimension(); if (space_dim > max_space_dimension()) throw std::length_error("Linear_Form<C>::" "Linear_Form(e):\n" "e exceeds the maximum allowed " "space dimension."); vec.reserve(compute_capacity(space_dim+1, vec_type().max_size())); vec.resize(space_dim+1); for (dimension_type i = space_dim; i-- > 0; ) vec[i+1] = e.coefficient(Variable(i)); vec[0] = e.inhomogeneous_term(); }
|
inlineprivate |
Implementation sizing constructor.
The bool parameter is just to avoid problems with the constructor Linear_Form(const C& n).
Definition at line 48 of file Linear_Form.inlines.hh.
References Parma_Polyhedra_Library::compute_capacity(), and Parma_Polyhedra_Library::Linear_Form< C >::vec.
: vec(sz, zero) { vec.reserve(compute_capacity(sz, vec_type().max_size())); }
|
private |
Builds the linear form corresponding to the difference of v and w.
| std::length_error | Thrown if the space dimension of v or the one of w exceed Linear_Form::max_space_dimension(). |
Definition at line 51 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::compute_capacity(), Parma_Polyhedra_Library::Linear_Form< C >::max_space_dimension(), Parma_Polyhedra_Library::Variable::space_dimension(), Parma_Polyhedra_Library::Linear_Form< C >::vec, and Parma_Polyhedra_Library::Linear_Form< C >::zero.
: vec() { const dimension_type v_space_dim = v.space_dimension(); const dimension_type w_space_dim = w.space_dimension(); const dimension_type space_dim = std::max(v_space_dim, w_space_dim); if (space_dim > max_space_dimension()) throw std::length_error("Linear_Form<C>::" "Linear_Form(v, w):\n" "v or w exceed the maximum allowed " "space dimension."); vec.reserve(compute_capacity(space_dim+1, vec_type().max_size())); vec.resize(space_dim+1, zero); if (v_space_dim != w_space_dim) { vec[v_space_dim] = C(typename C::boundary_type(1)); vec[w_space_dim] = C(typename C::boundary_type(-1)); } }
| void Parma_Polyhedra_Library::Linear_Form< C >::ascii_dump | ( | ) | const |
Writes to std::cerr an ASCII representation of *this.
|
inline |
Writes to s an ASCII representation of *this.
Definition at line 199 of file Linear_Form.inlines.hh.
References Parma_Polyhedra_Library::Implementation::BD_Shapes::separator.
{
using namespace IO_Operators;
dimension_type space_dim = space_dimension();
s << space_dim << "\n";
for (dimension_type i = 0; i <= space_dim; ++i) {
const char separator = ' ';
s << vec[i] << separator;
}
s << "\n";
}
|
inline |
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise.
Definition at line 212 of file Linear_Form.inlines.hh.
References PPL_ASSERT.
{
using namespace IO_Operators;
dimension_type new_dim;
if (!(s >> new_dim))
return false;
vec.resize(new_dim + 1, zero);
for (dimension_type i = 0; i <= new_dim; ++i) {
if (!(s >> vec[i]))
return false;
}
PPL_ASSERT(OK());
return true;
}
|
inline |
Returns the coefficient of v in *this.
Definition at line 93 of file Linear_Form.inlines.hh.
References Parma_Polyhedra_Library::Variable::id(), and Parma_Polyhedra_Library::Variable::space_dimension().
Referenced by Parma_Polyhedra_Library::Box< ITV >::affine_form_image(), Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::intervalize(), Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::overflows(), and Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::relative_error().
{
if (v.space_dimension() > space_dimension())
return zero;
return vec[v.id()+1];
}
|
inlineprivate |
Extends the vector of *this to size sz.
Definition at line 72 of file Linear_Form.inlines.hh.
References Parma_Polyhedra_Library::compute_capacity().
Referenced by Parma_Polyhedra_Library::Linear_Form< C >::operator+(), Parma_Polyhedra_Library::Linear_Form< C >::operator+=(), Parma_Polyhedra_Library::Linear_Form< C >::operator-(), and Parma_Polyhedra_Library::Linear_Form< C >::operator-=().
|
inline |
Returns the size in bytes of the memory managed by *this.
Definition at line 365 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::external_memory_in_bytes().
{
memory_size_type n = 0;
for (dimension_type i = size(); i-- > 0; )
n += vec[i].external_memory_in_bytes();
n += vec.capacity()*sizeof(C);
return n;
}
|
inline |
Returns the inhomogeneous term of *this.
Definition at line 115 of file Linear_Form.inlines.hh.
Referenced by Parma_Polyhedra_Library::Box< ITV >::affine_form_image(), Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::intervalize(), Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::overflows(), and Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::relative_error().
{
return vec[0];
}
| bool Parma_Polyhedra_Library::Linear_Form< C >::intervalize | ( | const FP_Oracle< Target, C > & | oracle, |
| C & | result | ||
| ) | const |
Makes result become an interval that overapproximates all the possible values of *this.
| oracle | The FP_Oracle to be queried. |
| result | The linear form that will store the result. |
true if the operation was successful, false otherwise (the possibility of failure depends on the oracle's implementation).Target specifies the implementation of Concrete_Expression to be used.This method makes result become
, that is an interval defined as:
where
is an interval (provided by the oracle) that correctly approximates the value of
.
The result is undefined if C is not the type of an interval with floating point boundaries.
Definition at line 461 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::FP_Oracle< Target, FP_Interval_Type >::get_interval().
{
result = C(inhomogeneous_term());
dimension_type dimension = space_dimension();
for (dimension_type i = 0; i < dimension; ++i) {
C current_addend = coefficient(Variable(i));
C curr_int;
if (!oracle.get_interval(i, curr_int))
return false;
current_addend *= curr_int;
result += current_addend;
}
return true;
}
|
inline |
Swaps *this with y.
Definition at line 192 of file Linear_Form.inlines.hh.
References Parma_Polyhedra_Library::swap(), and Parma_Polyhedra_Library::Linear_Form< C >::vec.
Referenced by Parma_Polyhedra_Library::Linear_Form< C >::swap().
|
inlinestatic |
Returns the maximum space dimension a Linear_Form can handle.
Definition at line 35 of file Linear_Form.inlines.hh.
Referenced by Parma_Polyhedra_Library::Linear_Form< C >::Linear_Form().
{
return vec_type().max_size() - 1;
}
| void Parma_Polyhedra_Library::Linear_Form< C >::negate | ( | ) |
Negates all the coefficients of *this.
Definition at line 357 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::neg_assign().
Referenced by Parma_Polyhedra_Library::Octagonal_Shape< T >::affine_form_image(), Parma_Polyhedra_Library::Opposite_Floating_Point_Expression< FP_Interval_Type, FP_Format >::linearize(), Parma_Polyhedra_Library::Concrete_Expression::linearize(), and Parma_Polyhedra_Library::BD_Shape< T >::two_variables_affine_form_image().
{
for (dimension_type i = vec.size(); i-- > 0; )
vec[i].neg_assign(vec[i]);
return;
}
| bool Parma_Polyhedra_Library::Linear_Form< C >::OK | ( | ) | const |
Checks if all the invariants are satisfied.
Definition at line 375 of file Linear_Form.templates.hh.
{
for (dimension_type i = size(); i-- > 0; )
if (!vec[i].OK())
return false;
return true;
}
|
inlineprivate |
Returns a reference to vec[i].
Definition at line 101 of file Linear_Form.inlines.hh.
|
inlineprivate |
Returns a const reference to vec[i].
Definition at line 108 of file Linear_Form.inlines.hh.
|
inline |
Verifies if the linear form overflows.
false if all coefficients in lf are bounded, true otherwise.T must be the type of possibly unbounded quantities.
Definition at line 231 of file Linear_Form.inlines.hh.
Referenced by Parma_Polyhedra_Library::Concrete_Expression::add_linearize(), Parma_Polyhedra_Library::Concrete_Expression::cast_linearize(), Parma_Polyhedra_Library::Concrete_Expression::div_linearize(), Parma_Polyhedra_Library::Concrete_Expression::linearize(), Parma_Polyhedra_Library::Concrete_Expression::mul_linearize(), and Parma_Polyhedra_Library::Concrete_Expression::sub_linearize().
{
if (!inhomogeneous_term().is_bounded())
return true;
for (dimension_type i = space_dimension(); i-- > 0; ) {
if (!coefficient(Variable(i)).is_bounded())
return true;
}
return false;
}
| void Parma_Polyhedra_Library::Linear_Form< C >::print | ( | ) | const |
Prints *this to std::cerr using operator<<.
| void Parma_Polyhedra_Library::Linear_Form< C >::relative_error | ( | Floating_Point_Format | analyzed_format, |
| Linear_Form< C > & | result | ||
| ) | const |
Computes the relative error associated to floating point computations that operate on a quantity that is overapproximated by *this.
| analyzed_format | The floating point format used by the analyzed program. |
| result | Becomes the linear form corresponding to the relative error committed. |
This method makes result become a linear form obtained by evaluating the function
on the linear form. This function is defined as:
where p is the fraction size in bits for the format
and
the base.
The result is undefined if T is not the type of an interval with floating point boundaries.
Definition at line 385 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::float_ieee754_half::BASE, Parma_Polyhedra_Library::float_ieee754_single::BASE, Parma_Polyhedra_Library::float_ieee754_double::BASE, Parma_Polyhedra_Library::float_ibm_single::BASE, Parma_Polyhedra_Library::float_intel_double_extended::BASE, Parma_Polyhedra_Library::float_ieee754_quad::BASE, Parma_Polyhedra_Library::GREATER_OR_EQUAL, Parma_Polyhedra_Library::i_constraint(), Parma_Polyhedra_Library::IBM_SINGLE, Parma_Polyhedra_Library::IEEE754_DOUBLE, Parma_Polyhedra_Library::IEEE754_HALF, Parma_Polyhedra_Library::IEEE754_QUAD, Parma_Polyhedra_Library::IEEE754_SINGLE, Parma_Polyhedra_Library::INTEL_DOUBLE_EXTENDED, Parma_Polyhedra_Library::LESS_OR_EQUAL, Parma_Polyhedra_Library::float_ieee754_half::MANTISSA_BITS, Parma_Polyhedra_Library::float_ieee754_single::MANTISSA_BITS, Parma_Polyhedra_Library::float_ieee754_double::MANTISSA_BITS, Parma_Polyhedra_Library::float_ibm_single::MANTISSA_BITS, Parma_Polyhedra_Library::float_intel_double_extended::MANTISSA_BITS, Parma_Polyhedra_Library::float_ieee754_quad::MANTISSA_BITS, Parma_Polyhedra_Library::msb_position(), and PPL_UNREACHABLE.
Referenced by Parma_Polyhedra_Library::Concrete_Expression::add_linearize(), Parma_Polyhedra_Library::Concrete_Expression::cast_linearize(), Parma_Polyhedra_Library::Concrete_Expression::div_linearize(), Parma_Polyhedra_Library::Concrete_Expression::mul_linearize(), and Parma_Polyhedra_Library::Concrete_Expression::sub_linearize().
{
typedef typename C::boundary_type analyzer_format;
// Get the necessary information on the analyzed's format.
unsigned int f_base;
unsigned int f_mantissa_bits;
switch (analyzed_format) {
case IEEE754_HALF:
f_base = float_ieee754_half::BASE;
f_mantissa_bits = float_ieee754_half::MANTISSA_BITS;
break;
case IEEE754_SINGLE:
f_base = float_ieee754_single::BASE;
f_mantissa_bits = float_ieee754_single::MANTISSA_BITS;
break;
case IEEE754_DOUBLE:
f_base = float_ieee754_double::BASE;
f_mantissa_bits = float_ieee754_double::MANTISSA_BITS;
break;
case IBM_SINGLE:
f_base = float_ibm_single::BASE;
f_mantissa_bits = float_ibm_single::MANTISSA_BITS;
break;
case IEEE754_QUAD:
f_base = float_ieee754_quad::BASE;
f_mantissa_bits = float_ieee754_quad::MANTISSA_BITS;
break;
case INTEL_DOUBLE_EXTENDED:
f_base = float_intel_double_extended::BASE;
f_mantissa_bits = float_intel_double_extended::MANTISSA_BITS;
break;
default:
PPL_UNREACHABLE;
break;
}
C error_propagator;
// We assume that f_base is a power of 2.
unsigned int u_power = msb_position(f_base) * f_mantissa_bits;
int neg_power = -static_cast<int>(u_power);
analyzer_format lb = static_cast<analyzer_format>(ldexp(1.0, neg_power));
error_propagator.build(i_constraint(GREATER_OR_EQUAL, -lb),
i_constraint(LESS_OR_EQUAL, lb));
// Handle the inhomogeneous term.
const C* current_term = &inhomogeneous_term();
assert(current_term->is_bounded());
C current_multiplier(std::max(std::abs(current_term->lower()),
std::abs(current_term->upper())));
Linear_Form current_result_term(current_multiplier);
current_result_term *= error_propagator;
result = Linear_Form(current_result_term);
// Handle the other terms.
dimension_type dimension = space_dimension();
for (dimension_type i = 0; i < dimension; ++i) {
current_term = &coefficient(Variable(i));
assert(current_term->is_bounded());
current_multiplier = C(std::max(std::abs(current_term->lower()),
std::abs(current_term->upper())));
current_result_term = Linear_Form(Variable(i));
current_result_term *= current_multiplier;
current_result_term *= error_propagator;
result += current_result_term;
}
return;
}
|
inlineprivate |
Gives the number of generic coefficients currently in use.
Definition at line 66 of file Linear_Form.inlines.hh.
Referenced by Parma_Polyhedra_Library::Linear_Form< C >::operator*(), Parma_Polyhedra_Library::Linear_Form< C >::operator*=(), Parma_Polyhedra_Library::Linear_Form< C >::operator+(), Parma_Polyhedra_Library::Linear_Form< C >::operator+=(), Parma_Polyhedra_Library::Linear_Form< C >::operator-(), Parma_Polyhedra_Library::Linear_Form< C >::operator-=(), Parma_Polyhedra_Library::Linear_Form< C >::operator/=(), and Parma_Polyhedra_Library::Linear_Row::operator==().
{
return vec.size();
}
|
inline |
Returns the dimension of the vector space enclosing *this.
Definition at line 87 of file Linear_Form.inlines.hh.
Referenced by Parma_Polyhedra_Library::Box< ITV >::affine_form_image(), Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::intervalize(), Parma_Polyhedra_Library::Linear_Form< C >::operator+(), Parma_Polyhedra_Library::Linear_Form< C >::operator+=(), Parma_Polyhedra_Library::Linear_Form< C >::operator-(), Parma_Polyhedra_Library::Linear_Form< C >::operator-=(), Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::overflows(), Parma_Polyhedra_Library::Floating_Point_Expression< FP_Interval_Type, FP_Format >::relative_error(), Parma_Polyhedra_Library::Box< ITV >::throw_dimension_incompatible(), Parma_Polyhedra_Library::Octagonal_Shape< T >::throw_dimension_incompatible(), and Parma_Polyhedra_Library::Polyhedron::throw_dimension_incompatible().
{
return size() - 1;
}
|
inline |
Returns a lower bound to the total size in bytes of the memory occupied by *this.
Definition at line 121 of file Linear_Form.inlines.hh.
References Parma_Polyhedra_Library::external_memory_in_bytes().
{
return sizeof(*this) + external_memory_in_bytes();
}
|
related |
Assigns the linear form lf to var in the linear form abstract store lf_store, then discards all occurrences of var from it.
Definition at line 476 of file Float.inlines.hh.
{
// Assign the new linear form for var.
lf_store[var.id()] = lf;
// Now invalidate all linear forms in which var occurs.
discard_occurrences(lf_store, var);
}
|
related |
Discards all linear forms containing variable var from the linear form abstract store lf_store.
Definition at line 129 of file Float.templates.hh.
{
typedef typename FP_Interval_Type::boundary_type analyzer_format;
typedef Linear_Form<FP_Interval_Type> FP_Linear_Form;
typedef Box<FP_Interval_Type> FP_Interval_Abstract_Store;
typedef std::map<dimension_type, FP_Linear_Form> FP_Linear_Form_Abstract_Store;
typename FP_Linear_Form_Abstract_Store::iterator i = lf_store.begin();
typename FP_Linear_Form_Abstract_Store::iterator ls_end = lf_store.end();
while (i != ls_end) {
if((i->second).coefficient(var) != 0)
lf_store.erase(i++);
else
++i;
}
}
|
related |
Definition at line 186 of file Linear_Form.inlines.hh.
{
return !(x == y);
}
|
related |
Returns true if and only if x and y are different.
|
related |
Returns the linear form n * f.
|
related |
Returns the linear form f * n.
|
related |
Definition at line 163 of file Linear_Form.inlines.hh.
{
return n * f;
}
|
related |
Definition at line 241 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::Linear_Form< C >::size().
{
Linear_Form<C> r(f);
for (dimension_type i = f.size(); i-- > 0; )
r[i] *= n;
return r;
}
|
friend |
|
friend |
|
related |
Returns the linear form n * f and assigns it to f.
|
related |
Definition at line 308 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::Linear_Form< C >::size().
{
dimension_type f_size = f.size();
for (dimension_type i = f_size; i-- > 0; )
f[i] *= n;
return f;
}
|
friend |
|
related |
Returns the linear form f1 + f2.
|
related |
Returns the linear form v + f.
|
related |
Returns the linear form f + v.
|
related |
Returns the linear form n + f.
|
related |
Returns the linear form f + n.
|
related |
Returns the linear form f.
|
related |
Definition at line 88 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::Linear_Form< C >::size(), and Parma_Polyhedra_Library::Linear_Form< C >::vec.
{
dimension_type f1_size = f1.size();
dimension_type f2_size = f2.size();
dimension_type min_size;
dimension_type max_size;
const Linear_Form<C>* p_e_max;
if (f1_size > f2_size) {
min_size = f2_size;
max_size = f1_size;
p_e_max = &f1;
}
else {
min_size = f1_size;
max_size = f2_size;
p_e_max = &f2;
}
Linear_Form<C> r(max_size, false);
dimension_type i = max_size;
while (i > min_size) {
--i;
r[i] = p_e_max->vec[i];
}
while (i > 0) {
--i;
r[i] = f1[i];
r[i] += f2[i];
}
return r;
}
|
related |
Definition at line 122 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::Linear_Form< C >::extend(), Parma_Polyhedra_Library::Variable::space_dimension(), and Parma_Polyhedra_Library::Linear_Form< C >::space_dimension().
{
const dimension_type v_space_dim = v.space_dimension();
if (v_space_dim > Linear_Form<C>::max_space_dimension())
throw std::length_error("Linear_Form "
"operator+(v, f):\n"
"v exceeds the maximum allowed "
"space dimension.");
Linear_Form<C> r(f);
if (v_space_dim > f.space_dimension())
r.extend(v_space_dim+1);
r[v_space_dim] += C(typename C::boundary_type(1));
return r;
}
|
related |
Definition at line 128 of file Linear_Form.inlines.hh.
{
return f;
}
|
related |
Definition at line 135 of file Linear_Form.inlines.hh.
{
return n + f;
}
|
related |
Definition at line 139 of file Linear_Form.templates.hh.
{
Linear_Form<C> r(f);
r[0] += n;
return r;
}
|
related |
Definition at line 142 of file Linear_Form.inlines.hh.
{
return v + f;
}
|
friend |
|
friend |
|
friend |
|
friend |
|
related |
Returns the linear form f1 + f2 and assigns it to e1.
|
related |
Returns the linear form f + v and assigns it to f.
| std::length_error | Thrown if the space dimension of v exceeds Linear_Form::max_space_dimension(). |
|
related |
Returns the linear form f + n and assigns it to f.
|
related |
Definition at line 170 of file Linear_Form.inlines.hh.
{
f[0] += n;
return f;
}
|
related |
Definition at line 252 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::Linear_Form< C >::extend(), and Parma_Polyhedra_Library::Linear_Form< C >::size().
{
dimension_type f1_size = f1.size();
dimension_type f2_size = f2.size();
if (f1_size < f2_size)
f1.extend(f2_size);
for (dimension_type i = f2_size; i-- > 0; )
f1[i] += f2[i];
return f1;
}
|
related |
Definition at line 265 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::Linear_Form< C >::extend(), Parma_Polyhedra_Library::Variable::space_dimension(), and Parma_Polyhedra_Library::Linear_Form< C >::space_dimension().
{
const dimension_type v_space_dim = v.space_dimension();
if (v_space_dim > Linear_Form<C>::max_space_dimension())
throw std::length_error("Linear_Form<C>& "
"operator+=(e, v):\n"
"v exceeds the maximum allowed space dimension.");
if (v_space_dim > f.space_dimension())
f.extend(v_space_dim+1);
f[v_space_dim] += C(typename C::boundary_type(1));
return f;
}
|
friend |
|
friend |
|
friend |
|
related |
Returns the linear form - f.
|
related |
Returns the linear form f1 - f2.
|
related |
Returns the linear form v - f.
|
related |
Returns the linear form f - v.
|
related |
Returns the linear form n - f.
|
related |
Returns the linear form f - n.
|
related |
Definition at line 148 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::neg_assign(), and Parma_Polyhedra_Library::Linear_Form< C >::size().
{
Linear_Form<C> r(f);
for (dimension_type i = f.size(); i-- > 0; )
r[i].neg_assign(r[i]);
return r;
}
|
related |
Definition at line 149 of file Linear_Form.inlines.hh.
{
return -n + f;
}
|
related |
Definition at line 156 of file Linear_Form.inlines.hh.
{
return Linear_Form<C>(v, w);
}
|
related |
Definition at line 158 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::Linear_Form< C >::size().
{
dimension_type f1_size = f1.size();
dimension_type f2_size = f2.size();
if (f1_size > f2_size) {
Linear_Form<C> r(f1_size, false);
dimension_type i = f1_size;
while (i > f2_size) {
--i;
r[i] = f1[i];
}
while (i > 0) {
--i;
r[i] = f1[i];
r[i] -= f2[i];
}
return r;
}
else {
Linear_Form<C> r(f2_size, false);
dimension_type i = f2_size;
while (i > f1_size) {
--i;
r[i].neg_assign(f2[i]);
}
while (i > 0) {
--i;
r[i] = f1[i];
r[i] -= f2[i];
}
return r;
}
}
|
related |
Definition at line 194 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::Linear_Form< C >::extend(), Parma_Polyhedra_Library::neg_assign(), Parma_Polyhedra_Library::Linear_Form< C >::size(), Parma_Polyhedra_Library::Variable::space_dimension(), and Parma_Polyhedra_Library::Linear_Form< C >::space_dimension().
{
const dimension_type v_space_dim = v.space_dimension();
if (v_space_dim > Linear_Form<C>::max_space_dimension())
throw std::length_error("Linear_Form "
"operator-(v, e):\n"
"v exceeds the maximum allowed "
"space dimension.");
Linear_Form<C> r(f);
if (v_space_dim > f.space_dimension())
r.extend(v_space_dim+1);
for (dimension_type i = f.size(); i-- > 0; )
r[i].neg_assign(r[i]);
r[v_space_dim] += C(typename C::boundary_type(1));
return r;
}
|
related |
Definition at line 213 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::Linear_Form< C >::extend(), Parma_Polyhedra_Library::Variable::space_dimension(), and Parma_Polyhedra_Library::Linear_Form< C >::space_dimension().
{
const dimension_type v_space_dim = v.space_dimension();
if (v_space_dim > Linear_Form<C>::max_space_dimension())
throw std::length_error("Linear_Form "
"operator-(e, v):\n"
"v exceeds the maximum allowed "
"space dimension.");
Linear_Form<C> r(f);
if (v_space_dim > f.space_dimension())
r.extend(v_space_dim+1);
r[v_space_dim] -= C(typename C::boundary_type(1));
return r;
}
|
related |
Definition at line 230 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::neg_assign(), and Parma_Polyhedra_Library::Linear_Form< C >::size().
{
Linear_Form<C> r(f);
for (dimension_type i = f.size(); i-- > 0; )
r[i].neg_assign(r[i]);
r[0] += n;
return r;
}
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
related |
Returns the linear form f1 - f2 and assigns it to f1.
|
related |
Returns the linear form f - v and assigns it to f.
| std::length_error | Thrown if the space dimension of v exceeds Linear_Form::max_space_dimension(). |
|
related |
Returns the linear form f - n and assigns it to f.
|
related |
Definition at line 178 of file Linear_Form.inlines.hh.
{
f[0] -= n;
return f;
}
|
related |
Definition at line 280 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::Linear_Form< C >::extend(), and Parma_Polyhedra_Library::Linear_Form< C >::size().
{
dimension_type f1_size = f1.size();
dimension_type f2_size = f2.size();
if (f1_size < f2_size)
f1.extend(f2_size);
for (dimension_type i = f2_size; i-- > 0; )
f1[i] -= f2[i];
return f1;
}
|
related |
Definition at line 293 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::Linear_Form< C >::extend(), Parma_Polyhedra_Library::Variable::space_dimension(), and Parma_Polyhedra_Library::Linear_Form< C >::space_dimension().
{
const dimension_type v_space_dim = v.space_dimension();
if (v_space_dim > Linear_Form<C>::max_space_dimension())
throw std::length_error("Linear_Form<C>& "
"operator-=(e, v):\n"
"v exceeds the maximum allowed space dimension.");
if (v_space_dim > f.space_dimension())
f.extend(v_space_dim+1);
f[v_space_dim] -= C(typename C::boundary_type(1));
return f;
}
|
friend |
|
friend |
|
friend |
|
related |
Returns the linear form f / n and assigns it to f.
Performs the division of a linear form by a scalar. It is up to the user to ensure that division by 0 is not performed.
|
related |
Definition at line 318 of file Linear_Form.templates.hh.
References Parma_Polyhedra_Library::Linear_Form< C >::size().
{
dimension_type f_size = f.size();
for (dimension_type i = f_size; i-- > 0; )
f[i] /= n;
return f;
}
|
friend |
|
related |
Output operator.
|
related |
Definition at line 480 of file Linear_Form.templates.hh.
{
const dimension_type num_variables = f.space_dimension();
bool first = true;
for (dimension_type v = 0; v < num_variables; ++v) {
const C& fv = f[v+1];
if (fv != typename C::boundary_type(0)) {
if (first) {
if (fv == typename C::boundary_type(-1))
s << "-";
else if (fv != typename C::boundary_type(1))
s << fv << "*";
first = false;
}
else {
if (fv == typename C::boundary_type(-1))
s << " - ";
else {
s << " + ";
if (fv != typename C::boundary_type(1))
s << fv << "*";
}
}
s << Variable(v);
}
}
// Inhomogeneous term.
const C& it = f[0];
if (it != 0) {
if (!first)
s << " + ";
else
first = false;
s << it;
}
if (first)
// The null linear form.
s << Linear_Form<C>::zero;
return s;
}
|
related |
Returns true if and only if x and y are equal.
|
friend |
|
friend |
|
related |
Swaps x with y.
|
related |
Definition at line 246 of file Linear_Form.inlines.hh.
References Parma_Polyhedra_Library::Linear_Form< C >::m_swap().
{
x.m_swap(y);
}
|
related |
Discards from ls1 all linear forms but those that are associated to the same variable in ls2.
Definition at line 150 of file Float.templates.hh.
{
typedef typename FP_Interval_Type::boundary_type analyzer_format;
typedef Linear_Form<FP_Interval_Type> FP_Linear_Form;
typedef Box<FP_Interval_Type> FP_Interval_Abstract_Store;
typedef std::map<dimension_type, FP_Linear_Form> FP_Linear_Form_Abstract_Store;
typename FP_Linear_Form_Abstract_Store::iterator i1 = ls1.begin();
typename FP_Linear_Form_Abstract_Store::iterator i1_end = ls1.end();
typename FP_Linear_Form_Abstract_Store::const_iterator i2_end = ls2.end();
while (i1 != i1_end) {
typename FP_Linear_Form_Abstract_Store::const_iterator
i2 = ls2.find(i1->first);
if ((i2 == i2_end) || (i1->second != i2->second))
ls1.erase(i1++);
else
++i1;
}
}
|
private |
The container vector.
Definition at line 409 of file Linear_Form.defs.hh.
Referenced by Parma_Polyhedra_Library::Linear_Form< C >::Linear_Form(), Parma_Polyhedra_Library::Linear_Form< C >::m_swap(), and Parma_Polyhedra_Library::Linear_Form< C >::operator+().
|
staticprivate |
The generic coefficient equal to the singleton zero.
Definition at line 403 of file Linear_Form.defs.hh.
Referenced by Parma_Polyhedra_Library::Linear_Form< C >::Linear_Form(), and Parma_Polyhedra_Library::Linear_Row::operator==().