PPL  0.12.1
Parma_Polyhedra_Library::Linear_Form< C > Class Template Reference

A linear form with interval coefficients. More...

#include <Linear_Form.defs.hh>

List of all members.

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)

Detailed Description

template<typename C>
class Parma_Polyhedra_Library::Linear_Form< C >

A linear form with interval coefficients.

An object of the class Linear_Form represents the interval linear form

\[ \sum_{i=0}^{n-1} a_i x_i + b \]

where $n$ is the dimension of the vector space, each $a_i$ is the coefficient of the $i$-th variable $x_i$ and $b$ 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.

How to build a linear form.
A full set of functions is defined in order to provide a convenient interface for building complex linear forms starting from simpler ones and from objects of the classes Variable and 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 $x_i$ is given by $i + 1$.
Example
Given the type T of an Interval with floating point coefficients (though any integral type may also be used), the following code builds the interval linear form $lf = x_5 - x_2 + 1$ 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;
Note that 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.


Member Typedef Documentation

template<typename C>
typedef std::vector<C> Parma_Polyhedra_Library::Linear_Form< C >::vec_type
private

Type of the container vector.

Definition at line 406 of file Linear_Form.defs.hh.


Constructor & Destructor Documentation

template<typename C >
Parma_Polyhedra_Library::Linear_Form< C >::Linear_Form ( )
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()));
}
template<typename C >
Parma_Polyhedra_Library::Linear_Form< C >::Linear_Form ( const Linear_Form< C > &  f)
inline

Ordinary copy constructor.

Definition at line 55 of file Linear_Form.inlines.hh.

  : vec(f.vec) {
}
template<typename C >
Parma_Polyhedra_Library::Linear_Form< C >::~Linear_Form ( )
inline

Destructor.

Definition at line 61 of file Linear_Form.inlines.hh.

                             {
}
template<typename C >
Parma_Polyhedra_Library::Linear_Form< C >::Linear_Form ( const C &  n)
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()));
}
template<typename C >
Parma_Polyhedra_Library::Linear_Form< C >::Linear_Form ( Variable  v)

Builds the linear form corresponding to the variable v.

Exceptions:
std::length_errorThrown 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));
}
template<typename C >
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();
}
template<typename C >
Parma_Polyhedra_Library::Linear_Form< C >::Linear_Form ( dimension_type  sz,
bool   
)
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()));
}
template<typename C >
Parma_Polyhedra_Library::Linear_Form< C >::Linear_Form ( Variable  v,
Variable  w 
)
private

Builds the linear form corresponding to the difference of v and w.

Exceptions:
std::length_errorThrown 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));
  }
}

Member Function Documentation

template<typename C>
void Parma_Polyhedra_Library::Linear_Form< C >::ascii_dump ( ) const

Writes to std::cerr an ASCII representation of *this.

template<typename C >
void Parma_Polyhedra_Library::Linear_Form< C >::ascii_dump ( std::ostream &  s) const
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";
}
template<typename C >
bool Parma_Polyhedra_Library::Linear_Form< C >::ascii_load ( std::istream &  s)
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;
}

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;
}
template<typename C >
template<typename Target >
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.

Parameters:
oracleThe FP_Oracle to be queried.
resultThe linear form that will store the result.
Returns:
true if the operation was successful, false otherwise (the possibility of failure depends on the oracle's implementation).
Template type parameters
  • The class template parameter Target specifies the implementation of Concrete_Expression to be used.

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) \]

where $\rho^{\#}(v)$ is an interval (provided by the oracle) that correctly approximates the value of $v$.

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;
}
template<typename C >
void Parma_Polyhedra_Library::Linear_Form< C >::m_swap ( Linear_Form< C > &  y)
inline
template<typename C >
dimension_type Parma_Polyhedra_Library::Linear_Form< C >::max_space_dimension ( )
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;
}
template<typename C >
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;
}
template<typename C >
C & Parma_Polyhedra_Library::Linear_Form< C >::operator[] ( dimension_type  i)
inlineprivate

Returns a reference to vec[i].

Definition at line 101 of file Linear_Form.inlines.hh.

                                           {
  assert(i < size());
  return vec[i];
}
template<typename C >
const C & Parma_Polyhedra_Library::Linear_Form< C >::operator[] ( dimension_type  i) const
inlineprivate

Returns a const reference to vec[i].

Definition at line 108 of file Linear_Form.inlines.hh.

                                                 {
  assert(i < size());
  return vec[i];
}
template<typename C >
bool Parma_Polyhedra_Library::Linear_Form< C >::overflows ( ) const
inline

Verifies if the linear form overflows.

Returns:
Returns 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;
}
template<typename C>
void Parma_Polyhedra_Library::Linear_Form< C >::print ( ) const

Prints *this to std::cerr using operator<<.

template<typename C >
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.

Parameters:
analyzed_formatThe floating point format used by the analyzed program.
resultBecomes the linear form corresponding to the relative error committed.

This method makes result become a linear form obtained by evaluating the function $\varepsilon_{\mathbf{f}}(l)$ on the linear form. This function is defined 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.

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;
}
template<typename C >
memory_size_type Parma_Polyhedra_Library::Linear_Form< C >::total_memory_in_bytes ( ) const
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();
}

Friends And Related Function Documentation

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 
)
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);
}
template<typename FP_Interval_Type >
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.

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;
  }
}
template<typename C >
bool operator!= ( const Linear_Form< C > &  x,
const Linear_Form< C > &  y 
)
related

Definition at line 186 of file Linear_Form.inlines.hh.

                                                             {
  return !(x == y);
}
template<typename C >
bool operator!= ( const Linear_Form< C > &  x,
const Linear_Form< C > &  y 
)
related

Returns true if and only if x and y are different.

template<typename C >
Linear_Form< C > operator* ( const C &  n,
const Linear_Form< C > &  f 
)
related

Returns the linear form n * f.

template<typename C >
Linear_Form< C > operator* ( const Linear_Form< C > &  f,
const C &  n 
)
related

Returns the linear form f * n.

template<typename C >
Linear_Form< C > operator* ( const Linear_Form< C > &  f,
const C &  n 
)
related

Definition at line 163 of file Linear_Form.inlines.hh.

                                               {
  return n * f;
}
template<typename C >
Linear_Form< C > operator* ( const C &  n,
const Linear_Form< C > &  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;
}
template<typename C>
Linear_Form<C> operator* ( const C &  n,
const Linear_Form< C > &  f 
)
friend
template<typename C>
Linear_Form<C> operator* ( const Linear_Form< C > &  f,
const C &  n 
)
friend
template<typename C >
Linear_Form< C > & operator*= ( Linear_Form< C > &  f,
const C &  n 
)
related

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 
)
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;
}
template<typename C>
Linear_Form<C>& operator*= ( Linear_Form< C > &  f,
const C &  n 
)
friend
template<typename C >
Linear_Form< C > operator+ ( const Linear_Form< C > &  f1,
const Linear_Form< C > &  f2 
)
related

Returns the linear form f1 + f2.

template<typename C >
Linear_Form< C > operator+ ( Variable  v,
const Linear_Form< C > &  f 
)
related

Returns the linear form v + f.

template<typename C >
Linear_Form< C > operator+ ( const Linear_Form< C > &  f,
Variable  v 
)
related

Returns the linear form f + v.

template<typename C >
Linear_Form< C > operator+ ( const C &  n,
const Linear_Form< C > &  f 
)
related

Returns the linear form n + f.

template<typename C >
Linear_Form< C > operator+ ( const Linear_Form< C > &  f,
const C &  n 
)
related

Returns the linear form f + n.

template<typename C >
Linear_Form< C > operator+ ( const Linear_Form< C > &  f)
related

Returns the linear form f.

template<typename C >
Linear_Form< C > operator+ ( const Linear_Form< C > &  f1,
const Linear_Form< C > &  f2 
)
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;
}
template<typename C >
Linear_Form< C > operator+ ( const Variable  v,
const Linear_Form< C > &  f 
)
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;
}
template<typename C >
Linear_Form< C > operator+ ( const Linear_Form< C > &  f)
related

Definition at line 128 of file Linear_Form.inlines.hh.

                                   {
  return f;
}
template<typename C >
Linear_Form< C > operator+ ( const Linear_Form< C > &  f,
const C &  n 
)
related

Definition at line 135 of file Linear_Form.inlines.hh.

                                               {
  return n + f;
}
template<typename C >
Linear_Form< C > operator+ ( const C &  n,
const Linear_Form< C > &  f 
)
related

Definition at line 139 of file Linear_Form.templates.hh.

                                               {
  Linear_Form<C> r(f);
  r[0] += n;
  return r;
}
template<typename C >
Linear_Form< C > operator+ ( const Linear_Form< C > &  f,
const Variable  v 
)
related

Definition at line 142 of file Linear_Form.inlines.hh.

                                                     {
  return v + f;
}
template<typename C>
Linear_Form<C> operator+ ( const Linear_Form< C > &  f1,
const Linear_Form< C > &  f2 
)
friend
template<typename C>
Linear_Form<C> operator+ ( const C &  n,
const Linear_Form< C > &  f 
)
friend
template<typename C>
Linear_Form<C> operator+ ( const Linear_Form< C > &  f,
const C &  n 
)
friend
template<typename C>
Linear_Form<C> operator+ ( Variable  v,
const Linear_Form< C > &  f 
)
friend
template<typename C >
Linear_Form< C > & operator+= ( Linear_Form< C > &  f1,
const Linear_Form< C > &  f2 
)
related

Returns the linear form f1 + f2 and assigns it to e1.

template<typename C >
Linear_Form< C > & operator+= ( Linear_Form< C > &  f,
Variable  v 
)
related

Returns the linear form f + v and assigns it to f.

Exceptions:
std::length_errorThrown if the space dimension of v exceeds Linear_Form::max_space_dimension().
template<typename C >
Linear_Form< C > & operator+= ( Linear_Form< C > &  f,
const C &  n 
)
related

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 
)
related

Definition at line 170 of file Linear_Form.inlines.hh.

                                          {
  f[0] += n;
  return f;
}
template<typename C >
Linear_Form< C > & operator+= ( Linear_Form< C > &  f1,
const Linear_Form< C > &  f2 
)
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;
}
template<typename C >
Linear_Form< C > & operator+= ( Linear_Form< C > &  f,
const Variable  v 
)
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;
}
template<typename C>
Linear_Form<C>& operator+= ( Linear_Form< C > &  f1,
const Linear_Form< C > &  f2 
)
friend
template<typename C>
Linear_Form<C>& operator+= ( Linear_Form< C > &  f,
Variable  v 
)
friend
template<typename C>
Linear_Form<C>& operator+= ( Linear_Form< C > &  f,
const C &  n 
)
friend
template<typename C >
Linear_Form< C > operator- ( const Linear_Form< C > &  f)
related

Returns the linear form - f.

template<typename C >
Linear_Form< C > operator- ( const Linear_Form< C > &  f1,
const Linear_Form< C > &  f2 
)
related

Returns the linear form f1 - f2.

template<typename C >
Linear_Form< C > operator- ( Variable  v,
const Linear_Form< C > &  f 
)
related

Returns the linear form v - f.

template<typename C >
Linear_Form< C > operator- ( const Linear_Form< C > &  f,
Variable  v 
)
related

Returns the linear form f - v.

template<typename C >
Linear_Form< C > operator- ( const C &  n,
const Linear_Form< C > &  f 
)
related

Returns the linear form n - f.

template<typename C >
Linear_Form< C > operator- ( const Linear_Form< C > &  f,
const C &  n 
)
related

Returns the linear form f - n.

template<typename C >
Linear_Form< C > operator- ( const Linear_Form< C > &  f)
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;
}
template<typename C >
Linear_Form< C > operator- ( const Linear_Form< C > &  f,
const C &  n 
)
related

Definition at line 149 of file Linear_Form.inlines.hh.

                                               {
  return -n + f;
}
template<typename C >
Linear_Form< C > operator- ( const Variable  v,
const Variable  w 
)
related

Definition at line 156 of file Linear_Form.inlines.hh.

                                              {
  return Linear_Form<C>(v, w);
}
template<typename C >
Linear_Form< C > operator- ( const Linear_Form< C > &  f1,
const Linear_Form< C > &  f2 
)
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;
  }
}
template<typename C >
Linear_Form< C > operator- ( const Variable  v,
const Linear_Form< C > &  f 
)
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;
}
template<typename C >
Linear_Form< C > operator- ( const Linear_Form< C > &  f,
const Variable  v 
)
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;
}
template<typename C >
Linear_Form< C > operator- ( const C &  n,
const Linear_Form< C > &  f 
)
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;
}
template<typename C>
Linear_Form<C> operator- ( const Linear_Form< C > &  f)
friend
template<typename C>
Linear_Form<C> operator- ( const Linear_Form< C > &  f1,
const Linear_Form< C > &  f2 
)
friend
template<typename C>
Linear_Form<C> operator- ( const C &  n,
const Linear_Form< C > &  f 
)
friend
template<typename C>
Linear_Form<C> operator- ( const Linear_Form< C > &  f,
const C &  n 
)
friend
template<typename C>
Linear_Form<C> operator- ( Variable  v,
const Linear_Form< C > &  f 
)
friend
template<typename C>
Linear_Form<C> operator- ( const Linear_Form< C > &  f,
Variable  v 
)
friend
template<typename C >
Linear_Form< C > & operator-= ( Linear_Form< C > &  f1,
const Linear_Form< C > &  f2 
)
related

Returns the linear form f1 - f2 and assigns it to f1.

template<typename C >
Linear_Form< C > & operator-= ( Linear_Form< C > &  f,
Variable  v 
)
related

Returns the linear form f - v and assigns it to f.

Exceptions:
std::length_errorThrown if the space dimension of v exceeds Linear_Form::max_space_dimension().
template<typename C >
Linear_Form< C > & operator-= ( Linear_Form< C > &  f,
const C &  n 
)
related

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 
)
related

Definition at line 178 of file Linear_Form.inlines.hh.

                                          {
  f[0] -= n;
  return f;
}
template<typename C >
Linear_Form< C > & operator-= ( Linear_Form< C > &  f1,
const Linear_Form< C > &  f2 
)
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;
}
template<typename C >
Linear_Form< C > & operator-= ( Linear_Form< C > &  f,
const Variable  v 
)
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;
}
template<typename C>
Linear_Form<C>& operator-= ( Linear_Form< C > &  f1,
const Linear_Form< C > &  f2 
)
friend
template<typename C>
Linear_Form<C>& operator-= ( Linear_Form< C > &  f,
Variable  v 
)
friend
template<typename C>
Linear_Form<C>& operator-= ( Linear_Form< C > &  f,
const C &  n 
)
friend
template<typename C >
Linear_Form< C > & operator/= ( Linear_Form< C > &  f,
const C &  n 
)
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.

template<typename C >
Linear_Form< C > & operator/= ( Linear_Form< C > &  f,
const C &  n 
)
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;
}
template<typename C>
Linear_Form<C>& operator/= ( Linear_Form< C > &  f,
const C &  n 
)
friend
template<typename C >
std::ostream & operator<< ( std::ostream &  s,
const Linear_Form< C > &  f 
)
related

Output operator.

template<typename C >
std::ostream & operator<< ( std::ostream &  s,
const Linear_Form< C > &  f 
)
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;
}
template<typename C >
bool operator== ( const Linear_Form< C > &  x,
const Linear_Form< C > &  y 
)
related

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 
)
friend
template<typename C>
std::ostream& Parma_Polyhedra_Library::IO_Operators::operator ( std::ostream &  s,
const Linear_Form< C > &  f 
)
friend
template<typename C >
void swap ( Linear_Form< C > &  x,
Linear_Form< C > &  y 
)
related

Swaps x with y.

template<typename C >
void swap ( Linear_Form< C > &  x,
Linear_Form< C > &  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);
}
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 
)
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;
  }
}

Member Data Documentation

template<typename C>
C Parma_Polyhedra_Library::Linear_Form< C >::zero
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==().


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