Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members | Related Pages

# Parma_Polyhedra_Library::LinExpression Class Reference

A linear expression. More...

List of all members.

## Public Member Functions
| LinExpression ()
| Default constructor: returns a copy of LinExpression::zero().
| LinExpression (const LinExpression &e)
| Ordinary copy-constructor.
| ~LinExpression ()
| Destructor.
| LinExpression (const Integer &n)
| Builds the linear expression corresponding to the inhomogeneous term `n`.
| LinExpression (const Variable v)
| Builds the linear expression corresponding to the variable `v`.
| LinExpression (const Constraint &c)
| Builds the linear expression corresponding to constraint `c`.
| LinExpression (const Generator &g)
| Builds the linear expression corresponding to generator `g` (for points and closure points, the divisor is not copied).
dimension_type | space_dimension () const
| Returns the dimension of the vector space enclosing `*this`.
const Integer & | coefficient (Variable v) const
| Returns the coefficient of `v` in `*this`.
const Integer & | inhomogeneous_term () const
| Returns the inhomogeneous term of `*this`.
## Static Public Member Functions
const LinExpression & | zero ()
| Returns the (zero-dimension space) constant 0.
## Related Functions
(Note that these are not member functions.)
LinExpression | operator+ (const LinExpression &e1, const LinExpression &e2)
| Returns the linear expression `e1` + `e2`.
LinExpression | operator+ (const Integer &n, const LinExpression &e)
| Returns the linear expression `n` + `e`.
LinExpression | operator+ (const LinExpression &e, const Integer &n)
| Returns the linear expression `e` + `n`.
LinExpression | operator+ (const LinExpression &e)
| Returns the linear expression `e`.
LinExpression | operator- (const LinExpression &e)
| Returns the linear expression - `e`.
LinExpression | operator- (const LinExpression &e1, const LinExpression &e2)
| Returns the linear expression `e1` - `e2`.
LinExpression | operator- (const Integer &n, const LinExpression &e)
| Returns the linear expression `n` - `e`.
LinExpression | operator- (const LinExpression &e, const Integer &n)
| Returns the linear expression `e` - `n`.
LinExpression | operator * (const Integer &n, const LinExpression &e)
| Returns the linear expression `n` * `e`.
LinExpression | operator * (const LinExpression &e, const Integer &n)
| Returns the linear expression `e` * `n`.
LinExpression & | operator+= (LinExpression &e1, const LinExpression &e2)
| Returns the linear expression `e1` + `e2` and assigns it to `e1`.
LinExpression & | operator+= (LinExpression &e, const Variable v)
| Returns the linear expression `e` + `v` and assigns it to `e`.
LinExpression & | operator+= (LinExpression &e, const Integer &n)
| Returns the linear expression `e` + `n` and assigns it to `e`.
LinExpression & | operator-= (LinExpression &e1, const LinExpression &e2)
| Returns the linear expression `e1` - `e2` and assigns it to `e1`.
LinExpression & | operator-= (LinExpression &e, const Variable v)
| Returns the linear expression `e` - `v` and assigns it to `e`.
LinExpression & | operator-= (LinExpression &e, const Integer &n)
| Returns the linear expression `e` - `n` and assigns it to `e`.
LinExpression & | operator *= (LinExpression &e, const Integer &n)
| Returns the linear expression `n` * `e` and assigns it to `e`.
std::ostream & | operator<< (std::ostream &s, const LinExpression &e)
| Output operator.
void | swap (Parma_Polyhedra_Library::LinExpression &x, Parma_Polyhedra_Library::LinExpression &y)
| Specializes `std::swap`.

## Detailed Description

A linear expression.

An object of the class LinExpression represents the linear expression

where is the dimension of the space, each is the integer coefficient of the `i` -th variable and 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 Integer: available operators include unary negation, binary addition and subtraction, as well as multiplication by an Integer. 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 Integer have space-dimension zero.

Example
  The following code builds the linear expression , having space-dimension :

        LinExpression e = 4*x - 2*y - z + 14;

  Another way to build the same linear expression is:

        LinExpression e1 = 4*x;
        LinExpression e2 = 2*y;
        LinExpression e3 = z;
        LinExpression e = LinExpression(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.

## Constructor & Destructor Documentation

Parma_Polyhedra_Library::LinExpression::LinExpression | ( | const Constraint & | c | ) | `[explicit]`

| Builds the linear expression corresponding to constraint `c`. Given the constraint , where , builds the linear expression . If `c` is an inequality (resp., equality) constraint, then the built linear expression is unique up to a positive (resp., non-zero) factor.

Parma_Polyhedra_Library::LinExpression::LinExpression | ( | const Generator & | g | ) | `[explicit]`

| Builds the linear expression corresponding to generator `g` (for points and closure points, the divisor is not copied). Given the generator (where, for lines and rays, we have ), builds the linear expression . 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.