PPL 0.12
|
A linear form with interval coefficients. More...
#include <ppl.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. | |
Friends | |
Linear_Form< C > | operator+ (const Linear_Form< C > &f1, const Linear_Form< C > &f2) |
Returns the linear form f1 + f2 . | |
Linear_Form< C > | operator+ (const C &n, const Linear_Form< C > &f) |
Returns the linear form n + f . | |
Linear_Form< C > | operator+ (const Linear_Form< C > &f, const C &n) |
Returns the linear form f + n . | |
Linear_Form< C > | operator+ (Variable v, const Linear_Form< C > &f) |
Returns the linear form v + f . | |
Linear_Form< C > | operator- (const Linear_Form< C > &f) |
Returns the linear form - f . | |
Linear_Form< C > | operator- (const Linear_Form< C > &f1, const Linear_Form< C > &f2) |
Returns the linear form f1 - f2 . | |
Linear_Form< C > | operator- (const C &n, const Linear_Form< C > &f) |
Returns the linear form n - f . | |
Linear_Form< C > | operator- (const Linear_Form< C > &f, const C &n) |
Returns the linear form f - n . | |
Linear_Form< C > | operator- (Variable v, const Linear_Form< C > &f) |
Returns the linear form v - f . | |
Linear_Form< C > | operator- (const Linear_Form< C > &f, Variable v) |
Returns the linear form f - v . | |
Linear_Form< C > | operator* (const C &n, const Linear_Form< C > &f) |
Returns the linear form n * f . | |
Linear_Form< C > | operator* (const Linear_Form< C > &f, const C &n) |
Returns the linear form f * n . | |
Linear_Form< C > & | operator+= (Linear_Form< C > &f1, const Linear_Form< C > &f2) |
Returns the linear form f1 + f2 and assigns it to e1 . | |
Linear_Form< C > & | operator+= (Linear_Form< C > &f, Variable v) |
Returns the linear form f + v and assigns it to f . | |
Linear_Form< C > & | operator+= (Linear_Form< C > &f, const C &n) |
Returns the linear form f + n and assigns it to f . | |
Linear_Form< C > & | operator-= (Linear_Form< C > &f1, const Linear_Form< C > &f2) |
Returns the linear form f1 - f2 and assigns it to f1 . | |
Linear_Form< C > & | operator-= (Linear_Form< C > &f, Variable v) |
Returns the linear form f - v and assigns it to f . | |
Linear_Form< C > & | operator-= (Linear_Form< C > &f, const C &n) |
Returns the linear form f - n and assigns it to f . | |
Linear_Form< C > & | operator*= (Linear_Form< C > &f, const C &n) |
Returns the linear form n * f and assigns it to f . | |
Linear_Form< C > & | operator/= (Linear_Form< C > &f, const C &n) |
Returns the linear form f / n and assigns it to f . | |
bool | operator== (const Linear_Form< C > &x, const Linear_Form< C > &y) |
Returns true if and only if x and y are equal. | |
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 > &f, Variable v) |
Returns the linear form f + v . | |
template<typename C > | |
Linear_Form< C > | operator+ (const Linear_Form< C > &f) |
Returns the linear form 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 different. | |
template<typename C > | |
std::ostream & | operator<< (std::ostream &s, const Linear_Form< C > &f) |
Output operator. |
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 T
of an Interval with floating point coefficients (though any integral type may also be used), the following code builds the interval linear form 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. 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() . |
bool Parma_Polyhedra_Library::Linear_Form< C >::overflows | ( | ) | const [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.
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.
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.
Linear_Form< C > operator+ | ( | const Linear_Form< C > & | f1, |
const Linear_Form< C > & | f2 | ||
) | [friend] |
Returns the linear form f1
+ f2
.
Linear_Form< C > operator+ | ( | const C & | n, |
const Linear_Form< C > & | f | ||
) | [friend] |
Returns the linear form n
+ f
.
Linear_Form< C > operator+ | ( | const Linear_Form< C > & | f, |
const C & | n | ||
) | [friend] |
Returns the linear form f
+ n
.
Linear_Form< C > operator+ | ( | Variable | v, |
const Linear_Form< C > & | f | ||
) | [friend] |
Returns the linear form v
+ f
.
Linear_Form< C > operator- | ( | const Linear_Form< C > & | f | ) | [friend] |
Returns the linear form - f
.
Linear_Form< C > operator- | ( | const Linear_Form< C > & | f1, |
const Linear_Form< C > & | f2 | ||
) | [friend] |
Returns the linear form f1
- f2
.
Linear_Form< C > operator- | ( | const C & | n, |
const Linear_Form< C > & | f | ||
) | [friend] |
Returns the linear form n
- f
.
Linear_Form< C > operator- | ( | const Linear_Form< C > & | f, |
const C & | n | ||
) | [friend] |
Returns the linear form f
- n
.
Linear_Form< C > operator- | ( | Variable | v, |
const Linear_Form< C > & | f | ||
) | [friend] |
Returns the linear form v
- f
.
Linear_Form< C > operator- | ( | const Linear_Form< C > & | f, |
Variable | v | ||
) | [friend] |
Returns the linear form f
- v
.
Linear_Form< C > operator* | ( | const C & | n, |
const Linear_Form< C > & | f | ||
) | [friend] |
Returns the linear form n
* f
.
Linear_Form< C > operator* | ( | const Linear_Form< C > & | f, |
const C & | n | ||
) | [friend] |
Returns the linear form f
* n
.
Linear_Form< C > & operator+= | ( | Linear_Form< C > & | f1, |
const Linear_Form< C > & | f2 | ||
) | [friend] |
Returns the linear form f1
+ f2
and assigns it to e1
.
Linear_Form< C > & operator+= | ( | Linear_Form< C > & | f, |
Variable | v | ||
) | [friend] |
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() . |
Linear_Form< C > & operator+= | ( | Linear_Form< C > & | f, |
const C & | n | ||
) | [friend] |
Returns the linear form f
+ n
and assigns it to f
.
Linear_Form< C > & operator-= | ( | Linear_Form< C > & | f1, |
const Linear_Form< C > & | f2 | ||
) | [friend] |
Returns the linear form f1
- f2
and assigns it to f1
.
Linear_Form< C > & operator-= | ( | Linear_Form< C > & | f, |
Variable | v | ||
) | [friend] |
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() . |
Linear_Form< C > & operator-= | ( | Linear_Form< C > & | f, |
const C & | n | ||
) | [friend] |
Returns the linear form f
- n
and assigns it to f
.
Linear_Form< C > & operator*= | ( | Linear_Form< C > & | f, |
const C & | n | ||
) | [friend] |
Returns the linear form n
* f
and assigns it to f
.
Linear_Form< C > & operator/= | ( | Linear_Form< C > & | f, |
const C & | n | ||
) | [friend] |
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.
bool operator== | ( | const Linear_Form< C > & | x, |
const Linear_Form< C > & | y | ||
) | [friend] |
Returns true
if and only if x
and y
are equal.
void discard_occurrences | ( | std::map< dimension_type, Linear_Form< FP_Interval_Type > > & | lf_store, |
Variable | var | ||
) | [related] |
Discards all linear forms containing variable var
from the linear form abstract store lf_store
.
void affine_form_image | ( | std::map< dimension_type, Linear_Form< FP_Interval_Type > > & | lf_store, |
Variable | var, | ||
const Linear_Form< FP_Interval_Type > & | lf | ||
) | [related] |
Assigns the linear form lf
to var
in the linear form abstract store lf_store
, then discards all occurrences of var
from it.
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 | ||
) | [related] |
Discards from ls1
all linear forms but those that are associated to the same variable in ls2
.
void swap | ( | Linear_Form< C > & | x, |
Linear_Form< C > & | y | ||
) | [related] |
Swaps x
with y
.
Linear_Form< C > operator+ | ( | const Linear_Form< C > & | f, |
Variable | v | ||
) | [related] |
Returns the linear form f
+ v
.
Linear_Form< C > operator+ | ( | const Linear_Form< C > & | f | ) | [related] |
Returns the linear form f
.
bool operator!= | ( | const Linear_Form< C > & | x, |
const Linear_Form< C > & | y | ||
) | [related] |
Returns true
if and only if x
and y
are different.
std::ostream & operator<< | ( | std::ostream & | s, |
const Linear_Form< C > & | f | ||
) | [related] |
Output operator.