# CoinPackedVectorBase Class Reference

Abstract base class for various sparse vectors. More...

`#include <CoinPackedVectorBase.hpp>`

Inheritance diagram for CoinPackedVectorBase:
[legend]

List of all members.

## Public Member Functions
Virtual methods that the derived classes must provide
virtual int | getNumElements () const =0
| Get length of indices and elements vectors.
virtual const int * | getIndices () const =0
| Get indices of elements.
virtual const double * | getElements () const =0
| Get element values.
Methods related to whether duplicate-index checking is performed.
If the checking for duplicate indices is turned off, then some CoinPackedVector methods may not work correctly if there are duplicate indices. Turning off the checking for duplicate indices may result in better run time performance.
void | setTestForDuplicateIndex (bool test) const
| Set to the argument value whether to test for duplicate indices in the vector whenever they can occur.
void | setTestForDuplicateIndexWhenTrue (bool test) const
| Set to the argument value whether to test for duplicate indices in the vector whenever they can occur BUT we know that right now the vector has no duplicate indices.
bool | testForDuplicateIndex () const
| Returns true if the vector should be tested for duplicate indices when they can occur.
void | setTestsOff () const
| Just sets test stuff false without a try etc.
Methods for getting info on the packed vector as a full vector
double * | denseVector (int denseSize) const
| Get the vector as a dense vector.
double | operator[] (int i) const
| Access the i'th element of the full storage vector.
Index methods
int | getMaxIndex () const
| Get value of maximum index.
int | getMinIndex () const
| Get value of minimum index.
void | duplicateIndex (const char *methodName=NULL, const char *className=NULL) const
| Throw an exception if there are duplicate indices.
bool | isExistingIndex (int i) const
| Return true if the i'th element of the full storage vector exists in the packed storage vector.
int | findIndex (int i) const
| Return the position of the i'th element of the full storage vector.
Comparison operators on two packed vectors
bool | operator== (const CoinPackedVectorBase &rhs) const
| Equal.
bool | operator!= (const CoinPackedVectorBase &rhs) const
| Not equal.
int | compare (const CoinPackedVectorBase &rhs) const
| This method establishes an ordering on packed vectors.
template<class FloatEqual >
bool | isEquivalent (const CoinPackedVectorBase &rhs, const FloatEqual &eq) const
| equivalent - If shallow packed vector A & B are equivalent, then they are still equivalent no matter how they are sorted.
bool | isEquivalent (const CoinPackedVectorBase &rhs) const
| Equal.
Arithmetic operators.
double | dotProduct (const double *dense) const
| Create the dot product with a full vector.
double | oneNorm () const
| Return the 1-norm of the vector.
double | normSquare () const
| Return the square of the 2-norm of the vector.
double | twoNorm () const
| Return the 2-norm of the vector.
double | infNorm () const
| Return the infinity-norm of the vector.
double | sum () const
| Sum elements of vector.
## Protected Member Functions
Protected methods
void | findMaxMinIndices () const
| Find Maximum and Minimum Indices.
std::set< int > * | indexSet (const char *methodName=NULL, const char *className=NULL) const
| Return indexSetPtr_ (create it if necessary).
void | clearIndexSet () const
| Delete the indexSet.
void | clearBase () const
| Find Maximum and Minimum Indices.
void | copyMaxMinIndex (const CoinPackedVectorBase &x) const
| Find Maximum and Minimum Indices.
## Private Member Functions
Disabled methods
| CoinPackedVectorBase (const CoinPackedVectorBase &)
| The copy constructor.
CoinPackedVectorBase & | operator= (const CoinPackedVectorBase &)
| This class provides const access to packed vectors, so there's no need to provide an assignment operator.
## Private Attributes
Protected member data
int | maxIndex_
| Contains max index value or -infinity.
int | minIndex_
| Contains minimum index value or infinity.
std::set< int > * | indexSetPtr_
| Store the indices in a set.
bool | testForDuplicateIndex_
| True if the vector should be tested for duplicate indices when they can occur.
bool | testedDuplicateIndex_
| True if the vector has already been tested for duplicate indices.
## Constructors, destructor
NOTE: All constructors are protected. There's no need to expose them, after all, this is an abstract class.
virtual | ~CoinPackedVectorBase ()
| Destructor.
| CoinPackedVectorBase ()
| Default constructor.

## Detailed Description

Abstract base class for various sparse vectors.

Since this class is abstract, no object of this type can be created. The sole purpose of this class is to provide access to a constant packed vector. All members of this class are const methods, they can't change the object.

Definition at line 23 of file CoinPackedVectorBase.hpp.

## Constructor & Destructor Documentation

CoinPackedVectorBase::CoinPackedVectorBase | ( |  | ) | `[protected]`

Default constructor.

virtual CoinPackedVectorBase::~CoinPackedVectorBase | ( |  | ) | `[virtual]`

Destructor.

CoinPackedVectorBase::CoinPackedVectorBase | ( | const CoinPackedVectorBase & |  | ) | `[private]`

The copy constructor.

This must be at least protected, but we make it private. The reason is that when, say, a shallow packed vector is created, first the underlying class, it this one is constructed. However, at that point we don't know how much of the data members of this class we need to copy over. Therefore the copy constructor is not used.

## Member Function Documentation

virtual int CoinPackedVectorBase::getNumElements | ( |  | ) | const`[pure virtual]`

Get length of indices and elements vectors.

Implemented in CoinPackedVector, and CoinShallowPackedVector.

virtual const int* CoinPackedVectorBase::getIndices | ( |  | ) | const`[pure virtual]`

Get indices of elements.

Implemented in CoinPackedVector, and CoinShallowPackedVector.

virtual const double* CoinPackedVectorBase::getElements | ( |  | ) | const`[pure virtual]`

Get element values.

Implemented in CoinPackedVector, and CoinShallowPackedVector.

void CoinPackedVectorBase::setTestForDuplicateIndex | ( | bool | test | ) | const

Set to the argument value whether to test for duplicate indices in the vector whenever they can occur.

Calling this method with `test` set to true will trigger an immediate check for duplicate indices.

void CoinPackedVectorBase::setTestForDuplicateIndexWhenTrue | ( | bool | test | ) | const

Set to the argument value whether to test for duplicate indices in the vector whenever they can occur BUT we know that right now the vector has no duplicate indices.

Calling this method with `test` set to true will not trigger an immediate check for duplicate indices; instead, it's assumed that the result of the test will be true.

bool CoinPackedVectorBase::testForDuplicateIndex | ( |  | ) | const`[inline]`

Returns true if the vector should be tested for duplicate indices when they can occur.

Definition at line 63 of file CoinPackedVectorBase.hpp.

void CoinPackedVectorBase::setTestsOff | ( |  | ) | const`[inline]`

Just sets test stuff false without a try etc.

Definition at line 65 of file CoinPackedVectorBase.hpp.

double* CoinPackedVectorBase::denseVector | ( | int | denseSize | ) | const

Get the vector as a dense vector.

The argument specifies how long this dense vector is.
NOTE: The user needs to `delete[]` this pointer after it's not needed anymore.

double CoinPackedVectorBase::operator[] | ( | int | i | ) | const

Access the i'th element of the full storage vector.

If the i'th is not stored, then zero is returned. The initial use of this method has some computational and storage overhead associated with it.
NOTE: This is very expensive. It is probably much better to use `denseVector()`.

int CoinPackedVectorBase::getMaxIndex | ( |  | ) | const

Get value of maximum index.

int CoinPackedVectorBase::getMinIndex | ( |  | ) | const

Get value of minimum index.

void CoinPackedVectorBase::duplicateIndex | ( | const char * | methodName = `NULL`,
|  | const char * | className = `NULL` |
| ) |  |  | const

Throw an exception if there are duplicate indices.

bool CoinPackedVectorBase::isExistingIndex | ( | int | i | ) | const

Return true if the i'th element of the full storage vector exists in the packed storage vector.

int CoinPackedVectorBase::findIndex | ( | int | i | ) | const

Return the position of the i'th element of the full storage vector.

If index does not exist then -1 is returned

bool CoinPackedVectorBase::operator== | ( | const CoinPackedVectorBase & | rhs | ) | const

Equal.

Returns true if vectors have same length and corresponding element of each vector is equal.

bool CoinPackedVectorBase::operator!= | ( | const CoinPackedVectorBase & | rhs | ) | const

Not equal.

int CoinPackedVectorBase::compare | ( | const CoinPackedVectorBase & | rhs | ) | const

This method establishes an ordering on packed vectors.

It is complete ordering, but not the same as lexicographic ordering. However, it is quick and dirty to compute and thus it is useful to keep packed vectors in a heap when all we care is to quickly check whether a particular vector is already in the heap or not. Returns negative/0/positive depending on whether `this` is smaller/equal.greater than `rhs`.

template<class FloatEqual >

bool CoinPackedVectorBase::isEquivalent | ( | const CoinPackedVectorBase & | rhs,
|  | const FloatEqual & | eq |
| ) |  |  | const`[inline]`

equivalent - If shallow packed vector A & B are equivalent, then they are still equivalent no matter how they are sorted.

In this method the FloatEqual function operator can be specified. The default equivalence test is that the entries are relatively equal.
NOTE: This is a relatively expensive method as it sorts the two shallow packed vectors.

Definition at line 140 of file CoinPackedVectorBase.hpp.

bool CoinPackedVectorBase::isEquivalent | ( | const CoinPackedVectorBase & | rhs | ) | const

Equal.

Returns true if vectors have same length and corresponding element of each vector is equal.

double CoinPackedVectorBase::dotProduct | ( | const double * | dense | ) | const

Create the dot product with a full vector.

double CoinPackedVectorBase::oneNorm | ( |  | ) | const

Return the 1-norm of the vector.

double CoinPackedVectorBase::normSquare | ( |  | ) | const

Return the square of the 2-norm of the vector.

double CoinPackedVectorBase::twoNorm | ( |  | ) | const

Return the 2-norm of the vector.

double CoinPackedVectorBase::infNorm | ( |  | ) | const

Return the infinity-norm of the vector.

double CoinPackedVectorBase::sum | ( |  | ) | const

Sum elements of vector.

CoinPackedVectorBase& CoinPackedVectorBase::operator= | ( | const CoinPackedVectorBase & |  | ) | `[private]`

This class provides const access to packed vectors, so there's no need to provide an assignment operator.

Reimplemented in CoinPackedVector, and CoinShallowPackedVector.

void CoinPackedVectorBase::findMaxMinIndices | ( |  | ) | const`[protected]`

Find Maximum and Minimum Indices.

std::set<int>* CoinPackedVectorBase::indexSet | ( | const char * | methodName = `NULL`,
|  | const char * | className = `NULL` |
| ) |  |  | const`[protected]`

Return indexSetPtr_ (create it if necessary).

void CoinPackedVectorBase::clearIndexSet | ( |  | ) | const`[protected]`

Delete the indexSet.

void CoinPackedVectorBase::clearBase | ( |  | ) | const`[protected]`

Find Maximum and Minimum Indices.

void CoinPackedVectorBase::copyMaxMinIndex | ( | const CoinPackedVectorBase & | x | ) | const`[inline, protected]`

Find Maximum and Minimum Indices.

Definition at line 243 of file CoinPackedVectorBase.hpp.

## Member Data Documentation

int CoinPackedVectorBase::maxIndex_`[mutable, private]`

Contains max index value or -infinity.

Definition at line 253 of file CoinPackedVectorBase.hpp.

int CoinPackedVectorBase::minIndex_`[mutable, private]`

Contains minimum index value or infinity.

Definition at line 255 of file CoinPackedVectorBase.hpp.

std::set<int>* CoinPackedVectorBase::indexSetPtr_`[mutable, private]`

Store the indices in a set.

This set is only created if it is needed. Its primary use is testing for duplicate indices.

Definition at line 259 of file CoinPackedVectorBase.hpp.

bool CoinPackedVectorBase::testForDuplicateIndex_`[mutable, private]`

True if the vector should be tested for duplicate indices when they can occur.

Definition at line 262 of file CoinPackedVectorBase.hpp.

bool CoinPackedVectorBase::testedDuplicateIndex_`[mutable, private]`

True if the vector has already been tested for duplicate indices.

Most of the operations in CoinPackedVector preserves this flag.

Definition at line 265 of file CoinPackedVectorBase.hpp.

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

- /home/coin/svn-release/Blis-0.94.1/CoinUtils/src/CoinPackedVectorBase.hpp