- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/Osi-0.98.1/CoinUtils/src/CoinPackedVector.hpp File Reference

`#include <map>`
`#include "CoinPackedVectorBase.hpp"`
`#include "CoinSort.hpp"`

Include dependency graph for CoinPackedVector.hpp:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Classes
class | CoinPackedVector
| Sparse Vector. More...
## Arithmetic operators on packed vectors.
NOTE: These methods operate on those positions where at least one of the arguments has a value listed. At those positions the appropriate operation is executed, Otherwise the result of the operation is considered 0. NOTE 2: There are two kind of operators here. One is used like "c = binaryOp(a, b)", the other is used like "binaryOp(c, a, b)", but they are really the same. The first is much more natural to use, but it involves the creation of a temporary object (the function *must* return an object), while the second form puts the result directly into the argument "c". Therefore, depending on the circumstances, the second form can be significantly faster.
template<class BinaryFunction>
void | binaryOp (CoinPackedVector &retVal, const CoinPackedVectorBase &op1, double value, BinaryFunction bf)
template<class BinaryFunction>
void | binaryOp (CoinPackedVector &retVal, double value, const CoinPackedVectorBase &op2, BinaryFunction bf)
template<class BinaryFunction>
void | binaryOp (CoinPackedVector &retVal, const CoinPackedVectorBase &op1, const CoinPackedVectorBase &op2, BinaryFunction bf)
template<class BinaryFunction>
CoinPackedVector | binaryOp (const CoinPackedVectorBase &op1, double value, BinaryFunction bf)
template<class BinaryFunction>
CoinPackedVector | binaryOp (double value, const CoinPackedVectorBase &op2, BinaryFunction bf)
template<class BinaryFunction>
CoinPackedVector | binaryOp (const CoinPackedVectorBase &op1, const CoinPackedVectorBase &op2, BinaryFunction bf)
CoinPackedVector | operator+ (const CoinPackedVectorBase &op1, const CoinPackedVectorBase &op2)
| Return the sum of two packed vectors.
CoinPackedVector | operator- (const CoinPackedVectorBase &op1, const CoinPackedVectorBase &op2)
| Return the difference of two packed vectors.
CoinPackedVector | operator * (const CoinPackedVectorBase &op1, const CoinPackedVectorBase &op2)
| Return the element-wise product of two packed vectors.
CoinPackedVector | operator/ (const CoinPackedVectorBase &op1, const CoinPackedVectorBase &op2)
| Return the element-wise ratio of two packed vectors.
## Arithmetic operators on packed vector and a constant. <br>
These functions create a packed vector as a result. That packed vector will have the same indices as `op1` and the specified operation is done entry-wise with the given value.
CoinPackedVector | operator+ (const CoinPackedVectorBase &op1, double value)
| Return the sum of a packed vector and a constant.
CoinPackedVector | operator- (const CoinPackedVectorBase &op1, double value)
| Return the difference of a packed vector and a constant.
CoinPackedVector | operator * (const CoinPackedVectorBase &op1, double value)
| Return the element-wise product of a packed vector and a constant.
CoinPackedVector | operator/ (const CoinPackedVectorBase &op1, double value)
| Return the element-wise ratio of a packed vector and a constant.
CoinPackedVector | operator+ (double value, const CoinPackedVectorBase &op1)
| Return the sum of a constant and a packed vector.
CoinPackedVector | operator- (double value, const CoinPackedVectorBase &op1)
| Return the difference of a constant and a packed vector.
CoinPackedVector | operator * (double value, const CoinPackedVectorBase &op1)
| Return the element-wise product of a constant and a packed vector.
CoinPackedVector | operator/ (double value, const CoinPackedVectorBase &op1)
| Return the element-wise ratio of a a constant and packed vector.
## Defines
#define | COIN_DEFAULT_VALUE_FOR_DUPLICATE true
## Functions
double | sparseDotProduct (const CoinPackedVectorBase &op1, const CoinPackedVectorBase &op2)
| Returns the dot product of two CoinPackedVector objects whose elements are doubles.
double | sortedSparseDotProduct (const CoinPackedVectorBase &op1, const CoinPackedVectorBase &op2)
| Returns the dot product of two sorted CoinPackedVector objects.
void | CoinPackedVectorUnitTest ()
| A function that tests the methods in the CoinPackedVector class.

## Define Documentation

#define COIN_DEFAULT_VALUE_FOR_DUPLICATE true

Definition at line 16 of file CoinPackedVector.hpp.

## Function Documentation

template<class BinaryFunction>

void binaryOp | ( | CoinPackedVector & | retVal,
|  | const CoinPackedVectorBase & | op1,
|  | double | value,
|  | BinaryFunction | bf |
| ) |  |  |

Definition at line 348 of file CoinPackedVector.hpp.

References CoinPackedVector::clear(), CoinPackedVectorBase::getElements(), CoinPackedVectorBase::getIndices(), CoinPackedVectorBase::getNumElements(), CoinPackedVector::insert(), and CoinPackedVector::reserve().

Referenced by binaryOp(), operator *(), operator+(), operator-(), and operator/().

template<class BinaryFunction>

void binaryOp | ( | CoinPackedVector & | retVal,
|  | double | value,
|  | const CoinPackedVectorBase & | op2,
|  | BinaryFunction | bf |
| ) |  |  | `[inline]`

Definition at line 365 of file CoinPackedVector.hpp.

References binaryOp().

template<class BinaryFunction>

void binaryOp | ( | CoinPackedVector & | retVal,
|  | const CoinPackedVectorBase & | op1,
|  | const CoinPackedVectorBase & | op2,
|  | BinaryFunction | bf |
| ) |  |  |

Definition at line 373 of file CoinPackedVector.hpp.

References CoinPackedVector::clear(), CoinPackedVectorBase::findIndex(), CoinPackedVectorBase::getElements(), CoinPackedVectorBase::getIndices(), CoinPackedVectorBase::getNumElements(), CoinPackedVector::insert(), CoinPackedVectorBase::isExistingIndex(), and CoinPackedVector::reserve().

template<class BinaryFunction>

CoinPackedVector binaryOp | ( | const CoinPackedVectorBase & | op1,
|  | double | value,
|  | BinaryFunction | bf |
| ) |  |  |

Definition at line 421 of file CoinPackedVector.hpp.

References binaryOp(), and CoinPackedVectorBase::setTestForDuplicateIndex().

template<class BinaryFunction>

CoinPackedVector binaryOp | ( | double | value,
|  | const CoinPackedVectorBase & | op2,
|  | BinaryFunction | bf |
| ) |  |  |

Definition at line 431 of file CoinPackedVector.hpp.

References binaryOp(), and CoinPackedVectorBase::setTestForDuplicateIndex().

template<class BinaryFunction>

CoinPackedVector binaryOp | ( | const CoinPackedVectorBase & | op1,
|  | const CoinPackedVectorBase & | op2,
|  | BinaryFunction | bf |
| ) |  |  |

Definition at line 441 of file CoinPackedVector.hpp.

References binaryOp(), and CoinPackedVectorBase::setTestForDuplicateIndex().

CoinPackedVector operator+ | ( | const CoinPackedVectorBase & | op1,
|  | const CoinPackedVectorBase & | op2 |
| ) |  |  | `[inline]`

Return the sum of two packed vectors.

Definition at line 452 of file CoinPackedVector.hpp.

References binaryOp(), and CoinPackedVectorBase::setTestForDuplicateIndex().

CoinPackedVector operator- | ( | const CoinPackedVectorBase & | op1,
|  | const CoinPackedVectorBase & | op2 |
| ) |  |  | `[inline]`

Return the difference of two packed vectors.

Definition at line 462 of file CoinPackedVector.hpp.

References binaryOp(), and CoinPackedVectorBase::setTestForDuplicateIndex().

CoinPackedVector operator * | ( | const CoinPackedVectorBase & | op1,
|  | const CoinPackedVectorBase & | op2 |
| ) |  |  | `[inline]`

Return the element-wise product of two packed vectors.

Definition at line 472 of file CoinPackedVector.hpp.

References binaryOp(), and CoinPackedVectorBase::setTestForDuplicateIndex().

CoinPackedVector operator/ | ( | const CoinPackedVectorBase & | op1,
|  | const CoinPackedVectorBase & | op2 |
| ) |  |  | `[inline]`

Return the element-wise ratio of two packed vectors.

Definition at line 482 of file CoinPackedVector.hpp.

References binaryOp(), and CoinPackedVectorBase::setTestForDuplicateIndex().

double sparseDotProduct | ( | const CoinPackedVectorBase & | op1,
|  | const CoinPackedVectorBase & | op2 |
| ) |  |  | `[inline]`

Returns the dot product of two CoinPackedVector objects whose elements are doubles.

Use this version if the vectors are *not* guaranteed to be sorted.

Definition at line 494 of file CoinPackedVector.hpp.

References CoinPackedVector::getElements(), and CoinPackedVector::getNumElements().

double sortedSparseDotProduct | ( | const CoinPackedVectorBase & | op1,
|  | const CoinPackedVectorBase & | op2 |
| ) |  |  | `[inline]`

Returns the dot product of two sorted CoinPackedVector objects.

The vectors should be sorted in ascending order of indices.

Definition at line 513 of file CoinPackedVector.hpp.

References CoinPackedVectorBase::getElements(), CoinPackedVectorBase::getIndices(), and CoinPackedVectorBase::getNumElements().

CoinPackedVector operator+ | ( | const CoinPackedVectorBase & | op1,
|  | double | value |
| ) |  |  | `[inline]`

Return the sum of a packed vector and a constant.

Definition at line 555 of file CoinPackedVector.hpp.

CoinPackedVector operator- | ( | const CoinPackedVectorBase & | op1,
|  | double | value |
| ) |  |  | `[inline]`

Return the difference of a packed vector and a constant.

Definition at line 564 of file CoinPackedVector.hpp.

CoinPackedVector operator * | ( | const CoinPackedVectorBase & | op1,
|  | double | value |
| ) |  |  | `[inline]`

Return the element-wise product of a packed vector and a constant.

Definition at line 573 of file CoinPackedVector.hpp.

CoinPackedVector operator/ | ( | const CoinPackedVectorBase & | op1,
|  | double | value |
| ) |  |  | `[inline]`

Return the element-wise ratio of a packed vector and a constant.

Definition at line 582 of file CoinPackedVector.hpp.

CoinPackedVector operator+ | ( | double | value,
|  | const CoinPackedVectorBase & | op1 |
| ) |  |  | `[inline]`

Return the sum of a constant and a packed vector.

Definition at line 593 of file CoinPackedVector.hpp.

CoinPackedVector operator- | ( | double | value,
|  | const CoinPackedVectorBase & | op1 |
| ) |  |  | `[inline]`

Return the difference of a constant and a packed vector.

Definition at line 602 of file CoinPackedVector.hpp.

References CoinPackedVector::getElements(), and CoinPackedVector::getNumElements().

CoinPackedVector operator * | ( | double | value,
|  | const CoinPackedVectorBase & | op1 |
| ) |  |  | `[inline]`

Return the element-wise product of a constant and a packed vector.

Definition at line 615 of file CoinPackedVector.hpp.

CoinPackedVector operator/ | ( | double | value,
|  | const CoinPackedVectorBase & | op1 |
| ) |  |  | `[inline]`

Return the element-wise ratio of a a constant and packed vector.

Definition at line 624 of file CoinPackedVector.hpp.

References CoinPackedVector::getElements(), and CoinPackedVector::getNumElements().

void CoinPackedVectorUnitTest | ( |  | ) |

A function that tests the methods in the CoinPackedVector class.

The only reason for it not to be a member method is that this way it doesn't have to be compiled into the library. And that's a gain, because the library should be compiled with optimization on, but this method should be compiled with debugging.