PPL  0.12.1
Parma_Polyhedra_Library::Linear_Expression Class Reference

A linear expression. More...

#include <Linear_Expression.defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::Linear_Expression:
Collaboration diagram for Parma_Polyhedra_Library::Linear_Expression:

List of all members.

Public Member Functions

 Linear_Expression ()
 Default constructor: returns a copy of Linear_Expression::zero().
 Linear_Expression (const Linear_Expression &e)
 Ordinary copy constructor.
 ~Linear_Expression ()
 Destructor.
 Linear_Expression (Coefficient_traits::const_reference n)
 Builds the linear expression corresponding to the inhomogeneous term n.
 Linear_Expression (Variable v)
 Builds the linear expression corresponding to the variable v.
 Linear_Expression (const Constraint &c)
 Builds the linear expression corresponding to constraint c.
 Linear_Expression (const Generator &g)
 Builds the linear expression corresponding to generator g (for points and closure points, the divisor is not copied).
 Linear_Expression (const Grid_Generator &g)
 Builds the linear expression corresponding to grid generator g (for points, parameters and lines the divisor is not copied).
 Linear_Expression (const Congruence &cg)
 Builds the linear expression corresponding to congruence cg.
dimension_type space_dimension () const
 Returns the dimension of the vector space enclosing *this.
Coefficient_traits::const_reference coefficient (Variable v) const
 Returns the coefficient of v in *this.
Coefficient_traits::const_reference inhomogeneous_term () const
 Returns the inhomogeneous term of *this.
bool is_zero () const
 Returns true if and only if *this is $0$.
bool all_homogeneous_terms_are_zero () const
 Returns true if and only if all the homogeneous terms of *this are $0$.
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_Expression &y)
 Swaps *this with y.

Static Public Member Functions

static dimension_type max_space_dimension ()
 Returns the maximum space dimension a Linear_Expression can handle.
static void initialize ()
 Initializes the class.
static void finalize ()
 Finalizes the class.
static const Linear_Expressionzero ()
 Returns the (zero-dimension space) constant 0.

Private Member Functions

 Linear_Expression (const Linear_Expression &e, dimension_type sz)
 Copy constructor with a specified space dimension.
 Linear_Expression (dimension_type sz, bool)
 Implementation sizing constructor.
 Linear_Expression (Variable v, Variable w)
 Builds the linear expression corresponding to the difference of v and w.

Static Private Attributes

static const Linear_Expressionzero_p = 0
 Holds (between class initialization and finalization) a pointer to the (zero-dimension space) constant 0.

Friends

class Parma_Polyhedra_Library::Scalar_Products
class Parma_Polyhedra_Library::Constraint
class Parma_Polyhedra_Library::Generator
class Parma_Polyhedra_Library::Grid_Generator
class Parma_Polyhedra_Library::Congruence
class Parma_Polyhedra_Library::Polyhedron
class Parma_Polyhedra_Library::Grid
class Parma_Polyhedra_Library::Constraint_System
class Parma_Polyhedra_Library::Generator_System
class Parma_Polyhedra_Library::Congruence_System
class Parma_Polyhedra_Library::Grid_Generator_System
Linear_Expression operator+ (const Linear_Expression &e1, const Linear_Expression &e2)
Linear_Expression operator+ (Coefficient_traits::const_reference n, const Linear_Expression &e)
Linear_Expression operator+ (const Linear_Expression &e, Coefficient_traits::const_reference n)
Linear_Expression operator+ (Variable v, const Linear_Expression &e)
Linear_Expression operator+ (Variable v, Variable w)
Linear_Expression operator- (const Linear_Expression &e)
Linear_Expression operator- (const Linear_Expression &e1, const Linear_Expression &e2)
Linear_Expression operator- (Variable v, Variable w)
Linear_Expression operator- (Coefficient_traits::const_reference n, const Linear_Expression &e)
Linear_Expression operator- (const Linear_Expression &e, Coefficient_traits::const_reference n)
Linear_Expression operator- (Variable v, const Linear_Expression &e)
Linear_Expression operator- (const Linear_Expression &e, Variable v)
Linear_Expression operator* (Coefficient_traits::const_reference n, const Linear_Expression &e)
Linear_Expression operator* (const Linear_Expression &e, Coefficient_traits::const_reference n)
Linear_Expressionoperator+= (Linear_Expression &e1, const Linear_Expression &e2)
Linear_Expressionoperator+= (Linear_Expression &e, Variable v)
Linear_Expressionoperator+= (Linear_Expression &e, Coefficient_traits::const_reference n)
Linear_Expressionoperator-= (Linear_Expression &e1, const Linear_Expression &e2)
Linear_Expressionoperator-= (Linear_Expression &e, Variable v)
Linear_Expressionoperator-= (Linear_Expression &e, Coefficient_traits::const_reference n)
Linear_Expressionoperator*= (Linear_Expression &e, Coefficient_traits::const_reference n)
Linear_Expressionadd_mul_assign (Linear_Expression &e, Coefficient_traits::const_reference n, Variable v)
Linear_Expressionsub_mul_assign (Linear_Expression &e, Coefficient_traits::const_reference n, Variable v)
std::ostream & Parma_Polyhedra_Library::IO_Operators::operator<< (std::ostream &s, const Linear_Expression &e)

Related Functions

(Note that these are not member functions.)

PPL::Linear_Expression operator+ (const Linear_Expression &e1, const Linear_Expression &e2)
PPL::Linear_Expression operator+ (const Variable v, const Linear_Expression &e)
PPL::Linear_Expression operator+ (Coefficient_traits::const_reference n, const Linear_Expression &e)
PPL::Linear_Expression operator+ (const Variable v, const Variable w)
PPL::Linear_Expression operator- (const Linear_Expression &e)
PPL::Linear_Expression operator- (const Linear_Expression &e1, const Linear_Expression &e2)
PPL::Linear_Expression operator- (const Variable v, const Linear_Expression &e)
PPL::Linear_Expression operator- (const Linear_Expression &e, const Variable v)
PPL::Linear_Expression operator- (Coefficient_traits::const_reference n, const Linear_Expression &e)
PPL::Linear_Expression operator* (Coefficient_traits::const_reference n, const Linear_Expression &e)
PPL::Linear_Expressionoperator+= (Linear_Expression &e1, const Linear_Expression &e2)
PPL::Linear_Expressionoperator+= (Linear_Expression &e, const Variable v)
PPL::Linear_Expressionoperator-= (Linear_Expression &e1, const Linear_Expression &e2)
PPL::Linear_Expressionoperator-= (Linear_Expression &e, const Variable v)
PPL::Linear_Expressionoperator*= (Linear_Expression &e, Coefficient_traits::const_reference n)
PPL::Linear_Expressionadd_mul_assign (Linear_Expression &e, Coefficient_traits::const_reference n, const Variable v)
PPL::Linear_Expressionsub_mul_assign (Linear_Expression &e, Coefficient_traits::const_reference n, const Variable v)
std::ostream & operator<< (std::ostream &s, const Linear_Expression &e)
void swap (Linear_Expression &x, Linear_Expression &y)
 Swaps x with y.
Linear_Expression operator+ (const Linear_Expression &e1, const Linear_Expression &e2)
 Returns the linear expression e1 + e2.
Linear_Expression operator+ (Variable v, Variable w)
 Returns the linear expression v + w.
Linear_Expression operator+ (Variable v, const Linear_Expression &e)
 Returns the linear expression v + e.
Linear_Expression operator+ (const Linear_Expression &e, Variable v)
 Returns the linear expression e + v.
Linear_Expression operator+ (Coefficient_traits::const_reference n, const Linear_Expression &e)
 Returns the linear expression n + e.
Linear_Expression operator+ (const Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the linear expression e + n.
Linear_Expression operator+ (const Linear_Expression &e)
 Returns the linear expression e.
Linear_Expression operator- (const Linear_Expression &e)
 Returns the linear expression - e.
Linear_Expression operator- (const Linear_Expression &e1, const Linear_Expression &e2)
 Returns the linear expression e1 - e2.
Linear_Expression operator- (Variable v, Variable w)
 Returns the linear expression v - w.
Linear_Expression operator- (Variable v, const Linear_Expression &e)
 Returns the linear expression v - e.
Linear_Expression operator- (const Linear_Expression &e, Variable v)
 Returns the linear expression e - v.
Linear_Expression operator- (Coefficient_traits::const_reference n, const Linear_Expression &e)
 Returns the linear expression n - e.
Linear_Expression operator- (const Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the linear expression e - n.
Linear_Expression operator* (Coefficient_traits::const_reference n, const Linear_Expression &e)
 Returns the linear expression n * e.
Linear_Expression operator* (const Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the linear expression e * n.
Linear_Expressionoperator+= (Linear_Expression &e1, const Linear_Expression &e2)
 Returns the linear expression e1 + e2 and assigns it to e1.
Linear_Expressionoperator+= (Linear_Expression &e, Variable v)
 Returns the linear expression e + v and assigns it to e.
Linear_Expressionoperator+= (Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the linear expression e + n and assigns it to e.
Linear_Expressionoperator-= (Linear_Expression &e1, const Linear_Expression &e2)
 Returns the linear expression e1 - e2 and assigns it to e1.
Linear_Expressionoperator-= (Linear_Expression &e, Variable v)
 Returns the linear expression e - v and assigns it to e.
Linear_Expressionoperator-= (Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the linear expression e - n and assigns it to e.
Linear_Expressionoperator*= (Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the linear expression n * e and assigns it to e.
Linear_Expressionadd_mul_assign (Linear_Expression &e, Coefficient_traits::const_reference n, Variable v)
 Returns the linear expression e + n * v and assigns it to e.
Linear_Expressionsub_mul_assign (Linear_Expression &e, Coefficient_traits::const_reference n, Variable v)
 Returns the linear expression e - n * v and assigns it to e.
std::ostream & operator<< (std::ostream &s, const Linear_Expression &e)
 Output operator.
Linear_Expression operator+ (const Linear_Expression &e)
Linear_Expression operator+ (const Linear_Expression &e, Coefficient_traits::const_reference n)
Linear_Expression operator+ (const Linear_Expression &e, const Variable v)
Linear_Expression operator- (const Linear_Expression &e, Coefficient_traits::const_reference n)
Linear_Expression operator- (const Variable v, const Variable w)
Linear_Expression operator* (const Linear_Expression &e, Coefficient_traits::const_reference n)
Linear_Expressionoperator+= (Linear_Expression &e, Coefficient_traits::const_reference n)
Linear_Expressionoperator-= (Linear_Expression &e, Coefficient_traits::const_reference n)
void swap (Linear_Expression &x, Linear_Expression &y)

Detailed Description

A linear expression.

An object of the class Linear_Expression represents the linear expression

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

where $n$ is the dimension of the vector space, each $a_i$ is the integer coefficient of the $i$-th variable $x_i$ and $b$ is the integer for the inhomogeneous term.

How to build a linear expression.

Linear expressions are the basic blocks for defining both constraints (i.e., linear equalities or inequalities) and generators (i.e., lines, rays, points and closure points). A full set of functions is defined to provide a convenient interface for building complex linear expressions starting from simpler ones and from objects of the classes Variable and Coefficient: available operators include unary negation, binary addition and subtraction, as well as multiplication by a Coefficient. The space dimension of a linear expression is defined as the maximum space dimension of the arguments used to build it: in particular, the space dimension of a Variable x is defined as x.id()+1, whereas all the objects of the class Coefficient have space dimension zero.

Example
The following code builds the linear expression $4x - 2y - z + 14$, having space dimension $3$:
  Linear_Expression e = 4*x - 2*y - z + 14;
Another way to build the same linear expression is:
  Linear_Expression e1 = 4*x;
  Linear_Expression e2 = 2*y;
  Linear_Expression e3 = z;
  Linear_Expression e = Linear_Expression(14);
  e += e1 - e2 - e3;
Note that e1, e2 and e3 have space dimension 1, 2 and 3, respectively; also, in the fourth line of code, e is created with space dimension zero and then extended to space dimension 3 in the fifth line.

Definition at line 244 of file Linear_Expression.defs.hh.


Constructor & Destructor Documentation

Default constructor: returns a copy of Linear_Expression::zero().

Definition at line 39 of file Linear_Expression.inlines.hh.

Ordinary copy constructor.

Definition at line 49 of file Linear_Expression.inlines.hh.

  : Linear_Row(e) {
}
Parma_Polyhedra_Library::Linear_Expression::Linear_Expression ( Coefficient_traits::const_reference  n)
inlineexplicit

Builds the linear expression corresponding to the inhomogeneous term n.

Definition at line 64 of file Linear_Expression.inlines.hh.

  : Linear_Row(1, Linear_Row::Flags()) {
  (*this)[0] = n;
}

Builds the linear expression corresponding to the variable v.

Exceptions:
std::length_errorThrown if the space dimension of v exceeds Linear_Expression::max_space_dimension().

Definition at line 81 of file Linear_Expression.cc.

References Parma_Polyhedra_Library::Variable::space_dimension().

  : Linear_Row((v.space_dimension() <= max_space_dimension())
               ? (v.space_dimension() + 1)
               : (throw std::length_error("PPL::Linear_Expression::"
                                          "Linear_Expression(v):\n"
                                          "v exceeds the maximum allowed "
                                          "space dimension."),
                  (v.space_dimension() + 1)),
               Linear_Row::Flags()) {
  ++((*this)[v.space_dimension()]);
}

Builds the linear expression corresponding to constraint c.

Given the constraint $c = \bigl(\sum_{i=0}^{n-1} a_i x_i + b \relsym 0\bigr)$, where $\mathord{\relsym} \in \{ =, \geq, > \}$, this builds the linear expression $\sum_{i=0}^{n-1} a_i x_i + b$. If c is an inequality (resp., equality) constraint, then the built linear expression is unique up to a positive (resp., non-zero) factor.

Definition at line 36 of file Linear_Expression.cc.

References Parma_Polyhedra_Library::Dense_Row::size().

  : Linear_Row(c.space_dimension() + 1, Linear_Row::Flags()) {
  Linear_Expression& e = *this;
  for (dimension_type i = size(); i-- > 0; )
    e[i] = c[i];
}

Builds the linear expression corresponding to generator g (for points and closure points, the divisor is not copied).

Given the generator $g = (\frac{a_0}{d}, \ldots, \frac{a_{n-1}}{d})^\transpose$ (where, for lines and rays, we have $d = 1$), this builds the linear expression $\sum_{i=0}^{n-1} a_i x_i$. The inhomogeneous term of the linear expression will always be 0. If g is a ray, point or closure point (resp., a line), then the linear expression is unique up to a positive (resp., non-zero) factor.

Definition at line 43 of file Linear_Expression.cc.

References Parma_Polyhedra_Library::Dense_Row::size().

  : Linear_Row(g.space_dimension() + 1, Linear_Row::Flags()) {
  Linear_Expression& e = *this;
  // Do not copy the divisor of `g'.
  for (dimension_type i = size(); --i > 0; )
    e[i] = g[i];
}

Builds the linear expression corresponding to grid generator g (for points, parameters and lines the divisor is not copied).

Given the grid generator $g = (\frac{a_0}{d}, \ldots, \frac{a_{n-1}}{d})^\transpose$ this builds the linear expression $\sum_{i=0}^{n-1} a_i x_i$. The inhomogeneous term of the linear expression is always 0.

Definition at line 51 of file Linear_Expression.cc.

References Parma_Polyhedra_Library::Dense_Row::size().

  : Linear_Row(g.space_dimension() + 1, Linear_Row::Flags()) {
  Linear_Expression& e = *this;
  // Do not copy the divisor of `g'.
  for (dimension_type i = size(); --i > 0; )
    e[i] = g[i];
}

Builds the linear expression corresponding to congruence cg.

Given the congruence $cg = \bigl(\sum_{i=0}^{n-1} a_i x_i + b = 0 \pmod{m}\bigr)$, this builds the linear expression $\sum_{i=0}^{n-1} a_i x_i + b$.

Definition at line 74 of file Linear_Expression.cc.

References Parma_Polyhedra_Library::Dense_Row::size().

  : Linear_Row(cg.space_dimension() + 1, Linear_Row::Flags()) {
  Linear_Expression& e = *this;
  for (dimension_type i = size(); i-- > 0; )
    e[i] = cg[i];
}

Copy constructor with a specified space dimension.

Definition at line 58 of file Linear_Expression.inlines.hh.

  : Linear_Row(e, sz, sz) {
}

Implementation sizing constructor.

The bool parameter is just to avoid problems with the constructor Linear_Expression(Coefficient_traits::const_reference n).

Definition at line 44 of file Linear_Expression.inlines.hh.

Builds the linear expression 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_Expression::max_space_dimension().

Definition at line 93 of file Linear_Expression.cc.

References max_space_dimension(), Parma_Polyhedra_Library::Dense_Row::resize(), and Parma_Polyhedra_Library::Variable::space_dimension().

  : Linear_Row() {
  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("PPL::Linear_Expression::"
                            "Linear_Expression(v, w):\n"
                            "v or w exceed the maximum allowed "
                            "space dimension.");
  resize(space_dim+1);
  if (v_space_dim != w_space_dim) {
    ++((*this)[v_space_dim]);
    --((*this)[w_space_dim]);
  }
}

Member Function Documentation

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

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Reimplemented in Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter.

Referenced by ascii_dump().

void Parma_Polyhedra_Library::Linear_Expression::ascii_dump ( std::ostream &  s) const
inline

Writes to s an ASCII representation of *this.

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Reimplemented in Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter.

Definition at line 168 of file Linear_Expression.inlines.hh.

References ascii_dump().

bool Parma_Polyhedra_Library::Linear_Expression::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.

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Reimplemented in Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter.

Definition at line 173 of file Linear_Expression.inlines.hh.

Referenced by Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::ascii_load(), and Parma_Polyhedra_Library::PIP_Solution_Node::ascii_load().

                                           {
  return Linear_Row::ascii_load(s);
}
Coefficient_traits::const_reference Parma_Polyhedra_Library::Linear_Expression::coefficient ( Variable  v) const
inline

Returns the coefficient of v in *this.

Definition at line 75 of file Linear_Expression.inlines.hh.

References Parma_Polyhedra_Library::Coefficient_zero(), Parma_Polyhedra_Library::Variable::id(), Parma_Polyhedra_Library::Variable::space_dimension(), and space_dimension().

Referenced by Parma_Polyhedra_Library::Box< ITV >::affine_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::affine_image(), Parma_Polyhedra_Library::Polyhedron::affine_image(), Parma_Polyhedra_Library::Box< ITV >::affine_preimage(), Parma_Polyhedra_Library::Octagonal_Shape< T >::affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::affine_preimage(), Parma_Polyhedra_Library::Polyhedron::affine_preimage(), Parma_Polyhedra_Library::Affine_Space::Affine_Space(), Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::Artificial_Parameter(), Parma_Polyhedra_Library::Box< ITV >::bounded_affine_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::bounded_affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::bounded_affine_image(), Parma_Polyhedra_Library::Polyhedron::bounded_affine_image(), Parma_Polyhedra_Library::Box< ITV >::bounded_affine_preimage(), Parma_Polyhedra_Library::Octagonal_Shape< T >::bounded_affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::bounded_affine_preimage(), Parma_Polyhedra_Library::Polyhedron::bounded_affine_preimage(), Parma_Polyhedra_Library::Box< ITV >::bounds(), Parma_Polyhedra_Library::Octagonal_Shape< T >::deduce_minus_v_pm_u_bounds(), Parma_Polyhedra_Library::BD_Shape< T >::deduce_u_minus_v_bounds(), Parma_Polyhedra_Library::BD_Shape< T >::deduce_v_minus_u_bounds(), Parma_Polyhedra_Library::Octagonal_Shape< T >::deduce_v_pm_u_bounds(), Parma_Polyhedra_Library::Box< ITV >::frequency(), Parma_Polyhedra_Library::BD_Shape< T >::frequency(), Parma_Polyhedra_Library::Octagonal_Shape< T >::frequency(), Parma_Polyhedra_Library::Box< ITV >::generalized_affine_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::generalized_affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::generalized_affine_image(), Parma_Polyhedra_Library::Grid::generalized_affine_image(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_image(), Parma_Polyhedra_Library::Box< ITV >::generalized_affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::generalized_affine_preimage(), Parma_Polyhedra_Library::Octagonal_Shape< T >::generalized_affine_preimage(), Parma_Polyhedra_Library::Grid::generalized_affine_preimage(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_preimage(), Parma_Polyhedra_Library::Grid::Grid(), Parma_Polyhedra_Library::Linear_Form< C >::Linear_Form(), Parma_Polyhedra_Library::BD_Shape< T >::max_min(), Parma_Polyhedra_Library::Box< ITV >::max_min(), Parma_Polyhedra_Library::Octagonal_Shape< T >::max_min(), Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::operator==(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine(), Parma_Polyhedra_Library::BD_Shape< T >::refine(), and Parma_Polyhedra_Library::Grid::simplify_using_context_assign().

                                               {
  if (v.space_dimension() > space_dimension())
    return Coefficient_zero();
  return Linear_Row::coefficient(v.id());
}

Finalizes the class.

Definition at line 68 of file Linear_Expression.cc.

References PPL_ASSERT.

Referenced by Parma_Polyhedra_Library::Init::~Init().

                               {
  PPL_ASSERT(zero_p != 0);
  delete zero_p;
  zero_p = 0;
}
Coefficient_traits::const_reference Parma_Polyhedra_Library::Linear_Expression::inhomogeneous_term ( ) const
inline

Returns the inhomogeneous term of *this.

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Definition at line 82 of file Linear_Expression.inlines.hh.

Referenced by Parma_Polyhedra_Library::Box< ITV >::affine_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::affine_image(), Parma_Polyhedra_Library::Box< ITV >::affine_preimage(), Parma_Polyhedra_Library::Octagonal_Shape< T >::affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::affine_preimage(), Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::Artificial_Parameter(), Parma_Polyhedra_Library::Octagonal_Shape< T >::bounded_affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::bounded_affine_image(), Parma_Polyhedra_Library::Box< ITV >::frequency(), Parma_Polyhedra_Library::BD_Shape< T >::frequency(), Parma_Polyhedra_Library::Polyhedron::frequency(), Parma_Polyhedra_Library::Octagonal_Shape< T >::frequency(), Parma_Polyhedra_Library::Grid::frequency_no_check(), Parma_Polyhedra_Library::Box< ITV >::generalized_affine_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::generalized_affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::generalized_affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::generalized_affine_preimage(), Parma_Polyhedra_Library::Octagonal_Shape< T >::generalized_affine_preimage(), Parma_Polyhedra_Library::Linear_Form< C >::Linear_Form(), Parma_Polyhedra_Library::BD_Shape< T >::max_min(), Parma_Polyhedra_Library::Box< ITV >::max_min(), Parma_Polyhedra_Library::Grid::max_min(), Parma_Polyhedra_Library::Octagonal_Shape< T >::max_min(), Parma_Polyhedra_Library::Polyhedron::max_min(), Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::operator==(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine(), Parma_Polyhedra_Library::BD_Shape< T >::refine(), and Parma_Polyhedra_Library::Grid::simplify_using_context_assign().

Returns true if and only if *this is $0$.

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Definition at line 87 of file Linear_Expression.inlines.hh.

                                 {
  return Linear_Row::is_zero();
}

Checks if all the invariants are satisfied.

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Reimplemented in Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter.

Definition at line 396 of file Linear_Expression.cc.

References Parma_Polyhedra_Library::Linear_Row::OK().

                               {
  return Linear_Row::OK();
}

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

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Reimplemented in Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter.

Returns the dimension of the vector space enclosing *this.

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Definition at line 70 of file Linear_Expression.inlines.hh.

References Parma_Polyhedra_Library::Dense_Row::size().

Referenced by Parma_Polyhedra_Library::Grid_Generator_System::affine_image(), Parma_Polyhedra_Library::Generator_System::affine_image(), Parma_Polyhedra_Library::Box< ITV >::affine_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::affine_image(), Parma_Polyhedra_Library::Grid::affine_image(), Parma_Polyhedra_Library::Polyhedron::affine_image(), Parma_Polyhedra_Library::Constraint_System::affine_preimage(), Parma_Polyhedra_Library::Congruence_System::affine_preimage(), Parma_Polyhedra_Library::Box< ITV >::affine_preimage(), Parma_Polyhedra_Library::Octagonal_Shape< T >::affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::affine_preimage(), Parma_Polyhedra_Library::Grid::affine_preimage(), Parma_Polyhedra_Library::Polyhedron::affine_preimage(), Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::Artificial_Parameter(), Parma_Polyhedra_Library::Box< ITV >::bounded_affine_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::bounded_affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::bounded_affine_image(), Parma_Polyhedra_Library::Grid::bounded_affine_image(), Parma_Polyhedra_Library::Polyhedron::bounded_affine_image(), Parma_Polyhedra_Library::Box< ITV >::bounded_affine_preimage(), Parma_Polyhedra_Library::Octagonal_Shape< T >::bounded_affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::bounded_affine_preimage(), Parma_Polyhedra_Library::Grid::bounded_affine_preimage(), Parma_Polyhedra_Library::Polyhedron::bounded_affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::bounds(), Parma_Polyhedra_Library::Box< ITV >::bounds(), Parma_Polyhedra_Library::Grid::bounds(), Parma_Polyhedra_Library::Octagonal_Shape< T >::bounds(), Parma_Polyhedra_Library::Polyhedron::bounds(), Parma_Polyhedra_Library::Grid::bounds_no_check(), Parma_Polyhedra_Library::Generator::closure_point(), coefficient(), Parma_Polyhedra_Library::Congruence::create(), Parma_Polyhedra_Library::Box< ITV >::frequency(), Parma_Polyhedra_Library::BD_Shape< T >::frequency(), Parma_Polyhedra_Library::Polyhedron::frequency(), Parma_Polyhedra_Library::Octagonal_Shape< T >::frequency(), Parma_Polyhedra_Library::Grid::frequency(), Parma_Polyhedra_Library::Grid::frequency_no_check(), Parma_Polyhedra_Library::Box< ITV >::generalized_affine_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::generalized_affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::generalized_affine_image(), Parma_Polyhedra_Library::Grid::generalized_affine_image(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_image(), Parma_Polyhedra_Library::Box< ITV >::generalized_affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::generalized_affine_preimage(), Parma_Polyhedra_Library::Octagonal_Shape< T >::generalized_affine_preimage(), Parma_Polyhedra_Library::Grid::generalized_affine_preimage(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_preimage(), Parma_Polyhedra_Library::Grid_Generator::grid_line(), Parma_Polyhedra_Library::Grid_Generator::grid_point(), Parma_Polyhedra_Library::Linear_Form< C >::Linear_Form(), Parma_Polyhedra_Library::BD_Shape< T >::max_min(), Parma_Polyhedra_Library::Box< ITV >::max_min(), Parma_Polyhedra_Library::Octagonal_Shape< T >::max_min(), Parma_Polyhedra_Library::Polyhedron::max_min(), Parma_Polyhedra_Library::MIP_Problem::MIP_Problem(), operator+(), operator-(), operator<<(), Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::operator==(), Parma_Polyhedra_Library::Constraint::operator>(), Parma_Polyhedra_Library::Grid_Generator::parameter(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine(), Parma_Polyhedra_Library::BD_Shape< T >::refine(), Parma_Polyhedra_Library::MIP_Problem::set_objective_function(), Parma_Polyhedra_Library::Grid::simplify_using_context_assign(), Parma_Polyhedra_Library::Box< ITV >::throw_dimension_incompatible(), Parma_Polyhedra_Library::Octagonal_Shape< T >::throw_dimension_incompatible(), Parma_Polyhedra_Library::BD_Shape< T >::throw_dimension_incompatible(), Parma_Polyhedra_Library::Grid::throw_dimension_incompatible(), and Parma_Polyhedra_Library::Polyhedron::throw_dimension_incompatible().

                                         {
  return size() - 1;
}

Returns a lower bound to the total size in bytes of the memory occupied by *this.

Reimplemented from Parma_Polyhedra_Library::Dense_Row.

Reimplemented in Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter.

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

Returns the (zero-dimension space) constant 0.

Definition at line 97 of file Linear_Expression.inlines.hh.

References PPL_ASSERT, and zero_p.

Referenced by Parma_Polyhedra_Library::Congruence::initialize(), and Parma_Polyhedra_Library::Constraint::initialize().

                        {
  PPL_ASSERT(zero_p != 0);
  return *zero_p;
}

Friends And Related Function Documentation

Linear_Expression & add_mul_assign ( Linear_Expression e,
Coefficient_traits::const_reference  n,
Variable  v 
)
related

Returns the linear expression e + n * v and assigns it to e.

PPL::Linear_Expression & add_mul_assign ( Linear_Expression e,
Coefficient_traits::const_reference  n,
const Variable  v 
)
related

Definition at line 359 of file Linear_Expression.cc.

References m_swap(), max_space_dimension(), Parma_Polyhedra_Library::Dense_Row::size(), and Parma_Polyhedra_Library::Variable::space_dimension().

                                      {
  const dimension_type v_space_dim = v.space_dimension();
  if (v_space_dim > Linear_Expression::max_space_dimension())
    throw std::length_error("Linear_Expression& "
                            "PPL::add_mul_assign(e, n, v):\n"
                            "v exceeds the maximum allowed space dimension.");
  const dimension_type e_size = e.size();
  if (e_size <= v_space_dim) {
    Linear_Expression new_e(e, v_space_dim+1);
    e.m_swap(new_e);
  }
  e[v_space_dim] += n;
  return e;
}
Linear_Expression operator* ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Returns the linear expression n * e.

Linear_Expression operator* ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Returns the linear expression e * n.

Linear_Expression operator* ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Definition at line 144 of file Linear_Expression.inlines.hh.

                                                                           {
  return n * e;
}
PPL::Linear_Expression operator* ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Definition at line 272 of file Linear_Expression.cc.

References Parma_Polyhedra_Library::Dense_Row::size().

                                           {
  Linear_Expression r(e);
  for (dimension_type i = e.size(); i-- > 0; )
    r[i] *= n;
  return r;
}
Linear_Expression operator* ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
friend
Linear_Expression operator* ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
friend
Linear_Expression & operator*= ( Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Returns the linear expression n * e and assigns it to e.

PPL::Linear_Expression & operator*= ( Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Definition at line 350 of file Linear_Expression.cc.

References Parma_Polyhedra_Library::Dense_Row::size().

                                                                         {
  dimension_type e_size = e.size();
  for (dimension_type i = e_size; i-- > 0; )
    e[i] *= n;
  return e;
}
Linear_Expression& operator*= ( Linear_Expression e,
Coefficient_traits::const_reference  n 
)
friend
Linear_Expression operator+ ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Returns the linear expression e1 + e2.

Linear_Expression operator+ ( Variable  v,
Variable  w 
)
related

Returns the linear expression v + w.

Linear_Expression operator+ ( Variable  v,
const Linear_Expression e 
)
related

Returns the linear expression v + e.

Linear_Expression operator+ ( const Linear_Expression e,
Variable  v 
)
related

Returns the linear expression e + v.

Linear_Expression operator+ ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Returns the linear expression n + e.

Linear_Expression operator+ ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Returns the linear expression e + n.

Linear_Expression operator+ ( const Linear_Expression e)
related

Returns the linear expression e.

PPL::Linear_Expression operator+ ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Definition at line 112 of file Linear_Expression.cc.

References Parma_Polyhedra_Library::Dense_Row::size().

                                                                       {
  dimension_type e1_size = e1.size();
  dimension_type e2_size = e2.size();
  dimension_type min_size;
  dimension_type max_size;
  const Linear_Expression* p_e_max;
  if (e1_size > e2_size) {
    min_size = e2_size;
    max_size = e1_size;
    p_e_max = &e1;
  }
  else {
    min_size = e1_size;
    max_size = e2_size;
    p_e_max = &e2;
  }

  Linear_Expression r(max_size, false);
  dimension_type i = max_size;
  while (i > min_size) {
    --i;
    r[i] = (*p_e_max)[i];
  }
  while (i > 0) {
    --i;
    r[i] = e1[i] + e2[i];
  }

  return r;
}
Linear_Expression operator+ ( const Linear_Expression e)
related

Definition at line 114 of file Linear_Expression.inlines.hh.

                                      {
  return e;
}
Linear_Expression operator+ ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Definition at line 120 of file Linear_Expression.inlines.hh.

                                                                           {
  return n + e;
}
Linear_Expression operator+ ( const Linear_Expression e,
const Variable  v 
)
related

Definition at line 126 of file Linear_Expression.inlines.hh.

                                                        {
  return v + e;
}
PPL::Linear_Expression operator+ ( const Variable  v,
const Linear_Expression e 
)
related

Definition at line 145 of file Linear_Expression.cc.

References max_space_dimension(), Parma_Polyhedra_Library::Variable::space_dimension(), and space_dimension().

                                                           {
  const dimension_type v_space_dim = v.space_dimension();
  if (v_space_dim > Linear_Expression::max_space_dimension())
    throw std::length_error("Linear_Expression "
                            "PPL::operator+(v, e):\n"
                            "v exceeds the maximum allowed "
                            "space dimension.");
  const dimension_type space_dim = std::max(v_space_dim, e.space_dimension());
  Linear_Expression r(e, space_dim+1);
  ++r[v_space_dim];
  return r;
}
PPL::Linear_Expression operator+ ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Definition at line 160 of file Linear_Expression.cc.

                                           {
  Linear_Expression r(e);
  r[0] += n;
  return r;
}
PPL::Linear_Expression operator+ ( const Variable  v,
const Variable  w 
)
related

Definition at line 169 of file Linear_Expression.cc.

References max_space_dimension(), and Parma_Polyhedra_Library::Variable::space_dimension().

                                                 {
  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 > Linear_Expression::max_space_dimension())
    throw std::length_error("Linear_Expression "
                            "PPL::operator+(v, w):\n"
                            "v or w exceed the maximum allowed "
                            "space dimension.");
  Linear_Expression r(space_dim+1, true);
  ++r[v_space_dim];
  ++r[w_space_dim];
  return r;
}
Linear_Expression operator+ ( const Linear_Expression e1,
const Linear_Expression e2 
)
friend
Linear_Expression operator+ ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
friend
Linear_Expression operator+ ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
friend
Linear_Expression operator+ ( Variable  v,
const Linear_Expression e 
)
friend
Linear_Expression operator+ ( Variable  v,
Variable  w 
)
friend
Linear_Expression & operator+= ( Linear_Expression e1,
const Linear_Expression e2 
)
related

Returns the linear expression e1 + e2 and assigns it to e1.

Linear_Expression & operator+= ( Linear_Expression e,
Variable  v 
)
related

Returns the linear expression e + v and assigns it to e.

Exceptions:
std::length_errorThrown if the space dimension of v exceeds Linear_Expression::max_space_dimension().
Linear_Expression & operator+= ( Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Returns the linear expression e + n and assigns it to e.

Linear_Expression & operator+= ( Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Definition at line 150 of file Linear_Expression.inlines.hh.

                                                                      {
  e[0] += n;
  return e;
}
PPL::Linear_Expression & operator+= ( Linear_Expression e1,
const Linear_Expression e2 
)
related

Definition at line 282 of file Linear_Expression.cc.

References m_swap(), and Parma_Polyhedra_Library::Dense_Row::size().

                                                                  {
  dimension_type e1_size = e1.size();
  dimension_type e2_size = e2.size();
  if (e1_size >= e2_size)
    for (dimension_type i = e2_size; i-- > 0; )
      e1[i] += e2[i];
  else {
    Linear_Expression new_e(e2);
    for (dimension_type i = e1_size; i-- > 0; )
      new_e[i] += e1[i];
    e1.m_swap(new_e);
  }
  return e1;
}
PPL::Linear_Expression & operator+= ( Linear_Expression e,
const Variable  v 
)
related

Definition at line 299 of file Linear_Expression.cc.

References m_swap(), max_space_dimension(), Parma_Polyhedra_Library::Dense_Row::size(), and Parma_Polyhedra_Library::Variable::space_dimension().

                                                      {
  const dimension_type v_space_dim = v.space_dimension();
  if (v_space_dim > Linear_Expression::max_space_dimension())
    throw std::length_error("Linear_Expression& "
                            "PPL::operator+=(e, v):\n"
                            "v exceeds the maximum allowed space dimension.");
  const dimension_type e_size = e.size();
  if (e_size <= v_space_dim) {
    Linear_Expression new_e(e, v_space_dim+1);
    e.m_swap(new_e);
  }
  ++e[v_space_dim];
  return e;
}
Linear_Expression& operator+= ( Linear_Expression e1,
const Linear_Expression e2 
)
friend
Linear_Expression& operator+= ( Linear_Expression e,
Variable  v 
)
friend
Linear_Expression& operator+= ( Linear_Expression e,
Coefficient_traits::const_reference  n 
)
friend
Linear_Expression operator- ( const Linear_Expression e)
related

Returns the linear expression - e.

Linear_Expression operator- ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Returns the linear expression e1 - e2.

Linear_Expression operator- ( Variable  v,
Variable  w 
)
related

Returns the linear expression v - w.

Linear_Expression operator- ( Variable  v,
const Linear_Expression e 
)
related

Returns the linear expression v - e.

Linear_Expression operator- ( const Linear_Expression e,
Variable  v 
)
related

Returns the linear expression e - v.

Linear_Expression operator- ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Returns the linear expression n - e.

Linear_Expression operator- ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Returns the linear expression e - n.

Linear_Expression operator- ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Definition at line 132 of file Linear_Expression.inlines.hh.

                                                                           {
  return -n + e;
}
Linear_Expression operator- ( const Variable  v,
const Variable  w 
)
related

Definition at line 138 of file Linear_Expression.inlines.hh.

                                              {
  return Linear_Expression(v, w);
}
PPL::Linear_Expression operator- ( const Linear_Expression e)
related

Definition at line 186 of file Linear_Expression.cc.

References Parma_Polyhedra_Library::neg_assign(), and Parma_Polyhedra_Library::Dense_Row::size().

                                         {
  Linear_Expression r(e);
  for (dimension_type i = e.size(); i-- > 0; )
    neg_assign(r[i]);
  return r;
}
PPL::Linear_Expression operator- ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Definition at line 195 of file Linear_Expression.cc.

References Parma_Polyhedra_Library::Dense_Row::size().

                                                                       {
  dimension_type e1_size = e1.size();
  dimension_type e2_size = e2.size();
  if (e1_size > e2_size) {
    Linear_Expression r(e1_size, false);
    dimension_type i = e1_size;
    while (i > e2_size) {
      --i;
      r[i] = e1[i];
    }
    while (i > 0) {
      --i;
      r[i] = e1[i] - e2[i];
    }
    return r;
  }
  else {
    Linear_Expression r(e2_size, false);
    dimension_type i = e2_size;
    while (i > e1_size) {
      --i;
      r[i] = -e2[i];
    }
    while (i > 0) {
      --i;
      r[i] = e1[i] - e2[i];
    }
    return r;
  }
}
PPL::Linear_Expression operator- ( const Variable  v,
const Linear_Expression e 
)
related

Definition at line 228 of file Linear_Expression.cc.

References max_space_dimension(), Parma_Polyhedra_Library::neg_assign(), Parma_Polyhedra_Library::Dense_Row::size(), Parma_Polyhedra_Library::Variable::space_dimension(), and space_dimension().

                                                           {
  const dimension_type v_space_dim = v.space_dimension();
  if (v_space_dim > Linear_Expression::max_space_dimension())
    throw std::length_error("Linear_Expression "
                            "PPL::operator-(v, e):\n"
                            "v exceeds the maximum allowed "
                            "space dimension.");
  const dimension_type e_space_dim = e.space_dimension();
  const dimension_type space_dim = std::max(v_space_dim, e_space_dim);
  Linear_Expression r(e, space_dim+1);
  for (dimension_type i = e.size(); i-- > 0; )
    neg_assign(r[i]);
  ++r[v_space_dim];
  return r;
}
PPL::Linear_Expression operator- ( const Linear_Expression e,
const Variable  v 
)
related

Definition at line 246 of file Linear_Expression.cc.

References max_space_dimension(), Parma_Polyhedra_Library::Variable::space_dimension(), and space_dimension().

                                                           {
  const dimension_type v_space_dim = v.space_dimension();
  if (v_space_dim > Linear_Expression::max_space_dimension())
    throw std::length_error("Linear_Expression "
                            "PPL::operator-(e, v):\n"
                            "v exceeds the maximum allowed "
                            "space dimension.");
  const dimension_type space_dim = std::max(v_space_dim, e.space_dimension());
  Linear_Expression r(e, space_dim+1);
  --r[v_space_dim];
  return r;
}
PPL::Linear_Expression operator- ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Definition at line 261 of file Linear_Expression.cc.

References Parma_Polyhedra_Library::neg_assign(), and Parma_Polyhedra_Library::Dense_Row::size().

                                           {
  Linear_Expression r(e);
  for (dimension_type i = e.size(); i-- > 0; )
    neg_assign(r[i]);
  r[0] += n;
  return r;
}
Linear_Expression operator- ( const Linear_Expression e)
friend
Linear_Expression operator- ( const Linear_Expression e1,
const Linear_Expression e2 
)
friend
Linear_Expression operator- ( Variable  v,
Variable  w 
)
friend
Linear_Expression operator- ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
friend
Linear_Expression operator- ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
friend
Linear_Expression operator- ( Variable  v,
const Linear_Expression e 
)
friend
Linear_Expression operator- ( const Linear_Expression e,
Variable  v 
)
friend
Linear_Expression & operator-= ( Linear_Expression e1,
const Linear_Expression e2 
)
related

Returns the linear expression e1 - e2 and assigns it to e1.

Linear_Expression & operator-= ( Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Definition at line 157 of file Linear_Expression.inlines.hh.

                                                                      {
  e[0] -= n;
  return e;
}
Linear_Expression & operator-= ( Linear_Expression e,
Variable  v 
)
related

Returns the linear expression e - v and assigns it to e.

Exceptions:
std::length_errorThrown if the space dimension of v exceeds Linear_Expression::max_space_dimension().
Linear_Expression & operator-= ( Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Returns the linear expression e - n and assigns it to e.

PPL::Linear_Expression & operator-= ( Linear_Expression e1,
const Linear_Expression e2 
)
related

Definition at line 316 of file Linear_Expression.cc.

References m_swap(), and Parma_Polyhedra_Library::Dense_Row::size().

                                                                  {
  dimension_type e1_size = e1.size();
  dimension_type e2_size = e2.size();
  if (e1_size >= e2_size)
    for (dimension_type i = e2_size; i-- > 0; )
      e1[i] -= e2[i];
  else {
    Linear_Expression new_e(e1, e2_size);
    for (dimension_type i = e2_size; i-- > 0; )
      new_e[i] -= e2[i];
    e1.m_swap(new_e);
  }
  return e1;
}
PPL::Linear_Expression & operator-= ( Linear_Expression e,
const Variable  v 
)
related

Definition at line 333 of file Linear_Expression.cc.

References m_swap(), max_space_dimension(), Parma_Polyhedra_Library::Dense_Row::size(), and Parma_Polyhedra_Library::Variable::space_dimension().

                                                      {
  const dimension_type v_space_dim = v.space_dimension();
  if (v_space_dim > Linear_Expression::max_space_dimension())
    throw std::length_error("Linear_Expression& "
                            "PPL::operator-=(e, v):\n"
                            "v exceeds the maximum allowed space dimension.");
  const dimension_type e_size = e.size();
  if (e_size <= v_space_dim) {
    Linear_Expression new_e(e, v_space_dim+1);
    e.m_swap(new_e);
  }
  --e[v_space_dim];
  return e;
}
Linear_Expression& operator-= ( Linear_Expression e1,
const Linear_Expression e2 
)
friend
Linear_Expression& operator-= ( Linear_Expression e,
Variable  v 
)
friend
Linear_Expression& operator-= ( Linear_Expression e,
Coefficient_traits::const_reference  n 
)
friend
std::ostream & operator<< ( std::ostream &  s,
const Linear_Expression e 
)
related

Output operator.

std::ostream & operator<< ( std::ostream &  s,
const Linear_Expression e 
)
related

Definition at line 402 of file Linear_Expression.cc.

References Parma_Polyhedra_Library::Coefficient_zero(), Parma_Polyhedra_Library::neg_assign(), PPL_DIRTY_TEMP_COEFFICIENT, and space_dimension().

                                                                     {
  const dimension_type num_variables = e.space_dimension();
  PPL_DIRTY_TEMP_COEFFICIENT(ev);
  bool first = true;
  for (dimension_type v = 0; v < num_variables; ++v) {
    ev = e[v+1];
    if (ev != 0) {
      if (!first) {
        if (ev > 0)
          s << " + ";
        else {
          s << " - ";
          neg_assign(ev);
        }
      }
      else
        first = false;
      if (ev == -1)
        s << "-";
      else if (ev != 1)
        s << ev << "*";
      s << PPL::Variable(v);
    }
  }
  // Inhomogeneous term.
  PPL_DIRTY_TEMP_COEFFICIENT(it);
  it = e[0];
  if (it != 0) {
    if (!first) {
      if (it > 0)
        s << " + ";
      else {
        s << " - ";
        neg_assign(it);
      }
    }
    else
      first = false;
    s << it;
  }

  if (first)
    // The null linear expression.
    s << Coefficient_zero();
  return s;
}

Definition at line 381 of file Linear_Expression.defs.hh.

Definition at line 396 of file Linear_Expression.defs.hh.

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Definition at line 377 of file Linear_Expression.defs.hh.

Definition at line 388 of file Linear_Expression.defs.hh.

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Definition at line 378 of file Linear_Expression.defs.hh.

Definition at line 392 of file Linear_Expression.defs.hh.

friend class Parma_Polyhedra_Library::Grid
friend

Definition at line 384 of file Linear_Expression.defs.hh.

Definition at line 380 of file Linear_Expression.defs.hh.

Definition at line 400 of file Linear_Expression.defs.hh.

std::ostream& Parma_Polyhedra_Library::IO_Operators::operator<< ( std::ostream &  s,
const Linear_Expression e 
)
friend

Definition at line 383 of file Linear_Expression.defs.hh.

Definition at line 376 of file Linear_Expression.defs.hh.

Linear_Expression & sub_mul_assign ( Linear_Expression e,
Coefficient_traits::const_reference  n,
Variable  v 
)
related

Returns the linear expression e - n * v and assigns it to e.

PPL::Linear_Expression & sub_mul_assign ( Linear_Expression e,
Coefficient_traits::const_reference  n,
const Variable  v 
)
related

Definition at line 378 of file Linear_Expression.cc.

References m_swap(), max_space_dimension(), Parma_Polyhedra_Library::Dense_Row::size(), and Parma_Polyhedra_Library::Variable::space_dimension().

                                      {
  const dimension_type v_space_dim = v.space_dimension();
  if (v_space_dim > Linear_Expression::max_space_dimension())
    throw std::length_error("Linear_Expression& "
                            "PPL::sub_mul_assign(e, n, v):\n"
                            "v exceeds the maximum allowed space dimension.");
  const dimension_type e_size = e.size();
  if (e_size <= v_space_dim) {
    Linear_Expression new_e(e, v_space_dim+1);
    e.m_swap(new_e);
  }
  e[v_space_dim] -= n;
  return e;
}
Linear_Expression& sub_mul_assign ( Linear_Expression e,
Coefficient_traits::const_reference  n,
Variable  v 
)
friend
void swap ( Linear_Expression x,
Linear_Expression y 
)
related

Swaps x with y.

void swap ( Linear_Expression x,
Linear_Expression y 
)
related

Definition at line 179 of file Linear_Expression.inlines.hh.

References m_swap().

                                                 {
  x.m_swap(y);
}

Member Data Documentation

Holds (between class initialization and finalization) a pointer to the (zero-dimension space) constant 0.

Definition at line 374 of file Linear_Expression.defs.hh.

Referenced by zero().


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