CoinPackedVectorBase

Abstract base class providing read-only access to sparse vectors.

Abstract base class providing read-only access to sparse vectors.

Derived classes: CoinPackedVector, CoinShallowPackedVector

Description

Since this class is abstract, no object of this type can be created. The sole purpose is to provide const access to sparse vector data. Sparse vectors store only non-zero elements as parallel arrays of indices and values.

Public Methods

getNumElements

Get the number of stored (non-zero) elements.

int getNumElements()

Returns: Count of index/value pairs

getIndices

Get pointer to array of element indices.

const int * getIndices()

Returns: Pointer to indices array (may be null if empty)

getElements

Get pointer to array of element values.

const double * getElements()

Returns: Pointer to values array (may be null if empty)

setTestForDuplicateIndex

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

void setTestForDuplicateIndex(bool test)

Parameters:

setTestForDuplicateIndexWhenTrue

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.

void setTestForDuplicateIndexWhenTrue(bool test)

Parameters:

testForDuplicateIndex

Check if duplicate index testing is enabled.

bool testForDuplicateIndex()

Returns: true if vector will be tested for duplicates when they can occur

setTestsOff

Disable all duplicate checking without exception handling.

void setTestsOff()

denseVector

Convert sparse vector to dense format.

double * denseVector(int denseSize)

Parameters:

Returns: Newly allocated dense array (caller must delete[])

operator[]

Access element by dense index.

double operator[](int i)

Parameters:

Returns: Value at index i, or zero if not stored

getMaxIndex

Get the largest index in the sparse vector.

int getMaxIndex()

Returns: Maximum index value, or -infinity if empty

getMinIndex

Get the smallest index in the sparse vector.

int getMinIndex()

Returns: Minimum index value, or +infinity if empty

duplicateIndex

Throw CoinError if duplicate indices exist.

void duplicateIndex(const char * methodName = NULL, const char * className = NULL)

Parameters:

isExistingIndex

Check if an index exists in the sparse vector.

bool isExistingIndex(int i)

Parameters:

Returns: true if index i is stored

findIndex

Find position of an index in the sparse storage.

int findIndex(int i)

Parameters:

Returns: Position in indices/elements arrays, or -1 if not found

operator==

Equal.

bool operator==(const CoinPackedVectorBase & rhs)

Parameters:

operator!=

Not equal.

bool operator!=(const CoinPackedVectorBase & rhs)

Parameters:

compare

This method establishes an ordering on packed vectors.

int compare(const CoinPackedVectorBase & rhs)

Parameters:

isEquivalent

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 FloatEqual & eq)

Parameters:

isEquivalent

bool isEquivalent(const CoinPackedVectorBase & rhs)

Parameters:

dotProduct

Compute dot product with a dense vector.

double dotProduct(const double * dense)

Parameters:

Returns: Sum of element[i] * dense[index[i]] for all stored elements

oneNorm

Compute the 1-norm (sum of absolute values)

double oneNorm()

Returns: Sum of |element[i]| for all stored elements

normSquare

Compute the squared 2-norm.

double normSquare()

Returns: Sum of element[i]^2 for all stored elements

twoNorm

Compute the 2-norm (Euclidean length)

double twoNorm()

Returns: Square root of normSquare()

infNorm

Compute the infinity-norm (maximum absolute value)

double infNorm()

Returns: Maximum |element[i]| across all stored elements

sum

Compute the sum of all elements.

double sum()

Returns: Sum of element[i] for all stored elements

~CoinPackedVectorBase

Destructor.

 ~CoinPackedVectorBase()

Source

Header: layer-0/CoinUtils/src/CoinPackedVectorBase.hpp