OR-Tools  8.2
SparseVector< IndexType, IteratorType >

Detailed Description

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
class operations_research::glop::SparseVector< IndexType, IteratorType >

Definition at line 83 of file sparse_vector.h.

Public Types

typedef IndexType Index
 
typedef StrictITIVector< Index, FractionalDenseVector
 
typedef Permutation< IndexIndexPermutation
 
using Iterator = IteratorType
 
using Entry = typename Iterator::Entry
 

Public Member Functions

 SparseVector ()
 
 SparseVector (const SparseVector &other)
 
 SparseVector (SparseVector &&other)=default
 
SparseVectoroperator= (const SparseVector &other)
 
SparseVectoroperator= (SparseVector &&other)=default
 
Iterator begin () const
 
Iterator end () const
 
void Clear ()
 
void ClearAndRelease ()
 
void Reserve (EntryIndex new_capacity)
 
bool IsEmpty () const
 
void CleanUp ()
 
bool IsCleanedUp () const
 
void Swap (SparseVector *other)
 
void PopulateFromSparseVector (const SparseVector &sparse_vector)
 
void PopulateFromDenseVector (const DenseVector &dense_vector)
 
void AppendEntriesWithOffset (const SparseVector &sparse_vector, Index offset)
 
bool CheckNoDuplicates () const
 
bool CheckNoDuplicates (StrictITIVector< Index, bool > *boolean_vector) const
 
void SetCoefficient (Index index, Fractional value)
 
void DeleteEntry (Index index)
 
void RemoveNearZeroEntries (Fractional threshold)
 
void RemoveNearZeroEntriesWithWeights (Fractional threshold, const DenseVector &weights)
 
void MoveEntryToFirstPosition (Index index)
 
void MoveEntryToLastPosition (Index index)
 
void MultiplyByConstant (Fractional factor)
 
void ComponentWiseMultiply (const DenseVector &factors)
 
void DivideByConstant (Fractional factor)
 
void ComponentWiseDivide (const DenseVector &factors)
 
void CopyToDenseVector (Index num_indices, DenseVector *dense_vector) const
 
void PermutedCopyToDenseVector (const IndexPermutation &index_perm, Index num_indices, DenseVector *dense_vector) const
 
void AddMultipleToDenseVector (Fractional multiplier, DenseVector *dense_vector) const
 
void AddMultipleToSparseVectorAndDeleteCommonIndex (Fractional multiplier, Index removed_common_index, Fractional drop_tolerance, SparseVector *accumulator_vector) const
 
void AddMultipleToSparseVectorAndIgnoreCommonIndex (Fractional multiplier, Index removed_common_index, Fractional drop_tolerance, SparseVector *accumulator_vector) const
 
void ApplyIndexPermutation (const IndexPermutation &index_perm)
 
void ApplyPartialIndexPermutation (const IndexPermutation &index_perm)
 
void MoveTaggedEntriesTo (const IndexPermutation &index_perm, SparseVector *output)
 
Fractional LookUpCoefficient (Index index) const
 
EntryIndex num_entries () const
 
Index GetFirstIndex () const
 
Fractional GetFirstCoefficient () const
 
Index GetLastIndex () const
 
Fractional GetLastCoefficient () const
 
::util::IntegerRange< EntryIndex > AllEntryIndices () const
 
bool IsEqualTo (const SparseVector &other) const
 
std::string DebugString () const
 

Protected Member Functions

void AddEntry (Index index, Fractional value)
 
void ResizeDown (EntryIndex new_size)
 
Index GetIndex (EntryIndex i) const
 
Fractional GetCoefficient (EntryIndex i) const
 
IndexMutableIndex (EntryIndex i)
 
FractionalMutableCoefficient (EntryIndex i)
 

Protected Attributes

std::unique_ptr< char[]> buffer_
 
EntryIndex num_entries_
 
EntryIndex capacity_
 
Indexindex_
 
Fractionalcoefficient_
 
bool may_contain_duplicates_
 

Member Typedef Documentation

◆ DenseVector

Definition at line 87 of file sparse_vector.h.

◆ Entry

using Entry = typename Iterator::Entry

Definition at line 91 of file sparse_vector.h.

◆ Index

typedef IndexType Index

Definition at line 85 of file sparse_vector.h.

◆ IndexPermutation

Definition at line 88 of file sparse_vector.h.

◆ Iterator

using Iterator = IteratorType

Definition at line 90 of file sparse_vector.h.

Constructor & Destructor Documentation

◆ SparseVector() [1/3]

Definition at line 459 of file sparse_vector.h.

◆ SparseVector() [2/3]

SparseVector ( const SparseVector< IndexType, IteratorType > &  other)

Definition at line 467 of file sparse_vector.h.

◆ SparseVector() [3/3]

SparseVector ( SparseVector< IndexType, IteratorType > &&  other)
default

Member Function Documentation

◆ AddEntry()

void AddEntry ( Index  index,
Fractional  value 
)
inlineprotected

Definition at line 317 of file sparse_vector.h.

◆ AddMultipleToDenseVector()

void AddMultipleToDenseVector ( Fractional  multiplier,
DenseVector dense_vector 
) const

Definition at line 815 of file sparse_vector.h.

◆ AddMultipleToSparseVectorAndDeleteCommonIndex()

void AddMultipleToSparseVectorAndDeleteCommonIndex ( Fractional  multiplier,
Index  removed_common_index,
Fractional  drop_tolerance,
SparseVector< IndexType, IteratorType > *  accumulator_vector 
) const

Definition at line 825 of file sparse_vector.h.

◆ AddMultipleToSparseVectorAndIgnoreCommonIndex()

void AddMultipleToSparseVectorAndIgnoreCommonIndex ( Fractional  multiplier,
Index  removed_common_index,
Fractional  drop_tolerance,
SparseVector< IndexType, IteratorType > *  accumulator_vector 
) const

Definition at line 834 of file sparse_vector.h.

◆ AllEntryIndices()

::util::IntegerRange< EntryIndex > AllEntryIndices ( ) const
inline

Definition at line 302 of file sparse_vector.h.

◆ AppendEntriesWithOffset()

void AppendEntriesWithOffset ( const SparseVector< IndexType, IteratorType > &  sparse_vector,
Index  offset 
)

Definition at line 626 of file sparse_vector.h.

◆ ApplyIndexPermutation()

void ApplyIndexPermutation ( const IndexPermutation index_perm)

Definition at line 926 of file sparse_vector.h.

◆ ApplyPartialIndexPermutation()

void ApplyPartialIndexPermutation ( const IndexPermutation index_perm)

Definition at line 934 of file sparse_vector.h.

◆ begin()

IteratorType begin

Definition at line 446 of file sparse_vector.h.

◆ CheckNoDuplicates() [1/2]

bool CheckNoDuplicates

Definition at line 669 of file sparse_vector.h.

◆ CheckNoDuplicates() [2/2]

bool CheckNoDuplicates ( StrictITIVector< Index, bool > *  boolean_vector) const

Definition at line 637 of file sparse_vector.h.

◆ CleanUp()

void CleanUp

Definition at line 544 of file sparse_vector.h.

◆ Clear()

void Clear

Definition at line 479 of file sparse_vector.h.

◆ ClearAndRelease()

void ClearAndRelease

Definition at line 485 of file sparse_vector.h.

◆ ComponentWiseDivide()

void ComponentWiseDivide ( const DenseVector factors)

Definition at line 786 of file sparse_vector.h.

◆ ComponentWiseMultiply()

void ComponentWiseMultiply ( const DenseVector factors)

Definition at line 770 of file sparse_vector.h.

◆ CopyToDenseVector()

void CopyToDenseVector ( Index  num_indices,
DenseVector dense_vector 
) const

Definition at line 794 of file sparse_vector.h.

◆ DebugString()

std::string DebugString

Definition at line 1007 of file sparse_vector.h.

◆ DeleteEntry()

void DeleteEntry ( Index  index)

Definition at line 687 of file sparse_vector.h.

◆ DivideByConstant()

void DivideByConstant ( Fractional  factor)

Definition at line 778 of file sparse_vector.h.

◆ end()

IteratorType end

Definition at line 451 of file sparse_vector.h.

◆ GetCoefficient()

Fractional GetCoefficient ( EntryIndex  i) const
inlineprotected

Definition at line 349 of file sparse_vector.h.

◆ GetFirstCoefficient()

Fractional GetFirstCoefficient ( ) const
inline

Definition at line 283 of file sparse_vector.h.

◆ GetFirstIndex()

Index GetFirstIndex ( ) const
inline

Definition at line 279 of file sparse_vector.h.

◆ GetIndex()

Index GetIndex ( EntryIndex  i) const
inlineprotected

Definition at line 344 of file sparse_vector.h.

◆ GetLastCoefficient()

Fractional GetLastCoefficient ( ) const
inline

Definition at line 293 of file sparse_vector.h.

◆ GetLastIndex()

Index GetLastIndex ( ) const
inline

Definition at line 289 of file sparse_vector.h.

◆ IsCleanedUp()

bool IsCleanedUp

Definition at line 580 of file sparse_vector.h.

◆ IsEmpty()

bool IsEmpty

Definition at line 529 of file sparse_vector.h.

◆ IsEqualTo()

bool IsEqualTo ( const SparseVector< IndexType, IteratorType > &  other) const

Definition at line 995 of file sparse_vector.h.

◆ LookUpCoefficient()

Fractional LookUpCoefficient ( Index  index) const

Definition at line 979 of file sparse_vector.h.

◆ MoveEntryToFirstPosition()

void MoveEntryToFirstPosition ( Index  index)

Definition at line 735 of file sparse_vector.h.

◆ MoveEntryToLastPosition()

void MoveEntryToLastPosition ( Index  index)

Definition at line 748 of file sparse_vector.h.

◆ MoveTaggedEntriesTo()

void MoveTaggedEntriesTo ( const IndexPermutation index_perm,
SparseVector< IndexType, IteratorType > *  output 
)

Definition at line 949 of file sparse_vector.h.

◆ MultiplyByConstant()

void MultiplyByConstant ( Fractional  factor)

Definition at line 762 of file sparse_vector.h.

◆ MutableCoefficient()

Fractional & MutableCoefficient ( EntryIndex  i)
inlineprotected

Definition at line 362 of file sparse_vector.h.

◆ MutableIndex()

Index & MutableIndex ( EntryIndex  i)
inlineprotected

Definition at line 357 of file sparse_vector.h.

◆ num_entries()

EntryIndex num_entries ( ) const
inline

Definition at line 270 of file sparse_vector.h.

◆ operator=() [1/2]

SparseVector< IndexType, IteratorType > & operator= ( const SparseVector< IndexType, IteratorType > &  other)

Definition at line 473 of file sparse_vector.h.

◆ operator=() [2/2]

SparseVector & operator= ( SparseVector< IndexType, IteratorType > &&  other)
default

◆ PermutedCopyToDenseVector()

void PermutedCopyToDenseVector ( const IndexPermutation index_perm,
Index  num_indices,
DenseVector dense_vector 
) const

Definition at line 804 of file sparse_vector.h.

◆ PopulateFromDenseVector()

void PopulateFromDenseVector ( const DenseVector dense_vector)

Definition at line 613 of file sparse_vector.h.

◆ PopulateFromSparseVector()

void PopulateFromSparseVector ( const SparseVector< IndexType, IteratorType > &  sparse_vector)

Definition at line 592 of file sparse_vector.h.

◆ RemoveNearZeroEntries()

void RemoveNearZeroEntries ( Fractional  threshold)

Definition at line 704 of file sparse_vector.h.

◆ RemoveNearZeroEntriesWithWeights()

void RemoveNearZeroEntriesWithWeights ( Fractional  threshold,
const DenseVector weights 
)

Definition at line 720 of file sparse_vector.h.

◆ Reserve()

void Reserve ( EntryIndex  new_capacity)

Definition at line 495 of file sparse_vector.h.

◆ ResizeDown()

void ResizeDown ( EntryIndex  new_size)
inlineprotected

Definition at line 336 of file sparse_vector.h.

◆ SetCoefficient()

void SetCoefficient ( Index  index,
Fractional  value 
)

Definition at line 680 of file sparse_vector.h.

◆ Swap()

void Swap ( SparseVector< IndexType, IteratorType > *  other)

Definition at line 534 of file sparse_vector.h.

Member Data Documentation

◆ buffer_

std::unique_ptr<char[]> buffer_
protected

Definition at line 379 of file sparse_vector.h.

◆ capacity_

EntryIndex capacity_
protected

Definition at line 381 of file sparse_vector.h.

◆ coefficient_

Fractional* coefficient_
protected

Definition at line 385 of file sparse_vector.h.

◆ index_

Index* index_
protected

Definition at line 384 of file sparse_vector.h.

◆ may_contain_duplicates_

bool may_contain_duplicates_
mutableprotected

Definition at line 389 of file sparse_vector.h.

◆ num_entries_

EntryIndex num_entries_
protected

Definition at line 380 of file sparse_vector.h.


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