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;
(This code computes the sum of all coefficients).
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
e=v+w;
e+=2*v-3.12*(v-w/2);
e*=3.4;
e/=5;
#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 Functions | |
| (Note that these are not member functions.) | |
| 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. | |
| DualExpr | ( | ) | [inline] |
Construct an empty expression, the coefficients are initialized to zero.
1.7.3