Loading...
Searching...
No Matches
LpBase::DualExpr Class Reference

## Detailed Description

This data structure represents a column of the matrix, thas is it strores a linear expression of the dual variables (Rows).

There are several ways to access and modify the contents of this container.

e[v]=5;
e[v]+=12;
e.erase(v);

or you can also iterate through its elements.

double s=0;
for(LpBase::DualExpr::ConstCoeffIt i(e);i!=INVALID;++i)
s+=*i;
lemon::INVALID
const Invalid INVALID
Invalid iterators.
Definition base.cc:32
lemon::LpBase::DualExpr::ConstCoeffIt
Iterator over the expression.
Definition lp_base.h:814

(This code computes the sum of all coefficients).

- Numbers (double's) and variables (Rows) directly convert to an DualExpr and the usual linear operations are defined, so
  v+w
  2*v-3.12*(v-w/2)
  v*2.1+(3*v+(v*12+w)*3)/2
  are valid DualExpr dual expressions. The usual assignment operations are also defined.
  e=v+w;
  e+=2*v-3.12*(v-w/2);
  e*=3.4;
  e/=5;
  See also
    Expr

`#include <lemon/lp_base.h>`

## Classes

class | CoeffIt
| Iterator over the expression. More...
class | ConstCoeffIt
| Iterator over the expression. More...

## Public Types

typedef LpBase::Row | Key
| The key type of the expression.
typedef LpBase::Value | Value
| The value type of the expression.

## Public Member Functions

| DualExpr ()
| Default constructor.
| DualExpr (const Row &r)
| Construct an expression from a row.
Value | operator[] (const Row &r) const
| Returns the coefficient of the row.
Value & | operator[] (const Row &r)
| Returns the coefficient of the row.
void | set (const Row &r, const Value &v)
| Sets the coefficient of the row.
void | simplify (Value epsilon=0.0)
| Removes the coefficients which's absolute value does not exceed `epsilon`.
void | clear ()
| Sets all coefficients to 0.
DualExpr & | operator+= (const DualExpr &e)
| Compound assignment.
DualExpr & | operator-= (const DualExpr &e)
| Compound assignment.
DualExpr & | operator*= (const Value &v)
| Multiply with a constant.
DualExpr & | operator/= (const Value &v)
| Division with a constant.

## Related Symbols

(Note that these are not member symbols.)
LpBase::DualExpr | operator+ (const LpBase::DualExpr &a, const LpBase::DualExpr &b)
| Addition.
LpBase::DualExpr | operator- (const LpBase::DualExpr &a, const LpBase::DualExpr &b)
| Substraction.
LpBase::DualExpr | operator* (const LpBase::DualExpr &a, const LpBase::Value &b)
| Multiply with constant.
LpBase::DualExpr | operator* (const LpBase::Value &a, const LpBase::DualExpr &b)
| Multiply with constant.
LpBase::DualExpr | operator/ (const LpBase::DualExpr &a, const LpBase::Value &b)
| Divide with constant.

## Constructor & Destructor Documentation

## DualExpr() [1/2]

DualExpr | ( |  | ) |

inline

Construct an empty expression, the coefficients are initialized to zero.

## DualExpr() [2/2]

DualExpr | ( | const Row & | r | ) |

inline

Construct an expression, which has a term with `r` dual variable and 1.0 coefficient.