OR-Tools  9.6
SparseVector< IndexType, IteratorType >

Detailed Description

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

Definition at line 84 of file lp_data/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 88 of file lp_data/sparse_vector.h.

◆ Entry

using Entry = typename Iterator::Entry

Definition at line 92 of file lp_data/sparse_vector.h.

◆ Index

typedef IndexType Index

Definition at line 86 of file lp_data/sparse_vector.h.

◆ IndexPermutation

Definition at line 89 of file lp_data/sparse_vector.h.

◆ Iterator

using Iterator = IteratorType

Definition at line 91 of file lp_data/sparse_vector.h.

Constructor & Destructor Documentation

◆ SparseVector() [1/3]

Definition at line 460 of file lp_data/sparse_vector.h.

◆ SparseVector() [2/3]

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

Definition at line 468 of file lp_data/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 318 of file lp_data/sparse_vector.h.

◆ AddMultipleToDenseVector()

void AddMultipleToDenseVector ( Fractional  multiplier,
DenseVector dense_vector 
) const

Definition at line 821 of file lp_data/sparse_vector.h.

◆ AddMultipleToSparseVectorAndDeleteCommonIndex()

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

Definition at line 831 of file lp_data/sparse_vector.h.

◆ AddMultipleToSparseVectorAndIgnoreCommonIndex()

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

Definition at line 840 of file lp_data/sparse_vector.h.

◆ AllEntryIndices()

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

Definition at line 303 of file lp_data/sparse_vector.h.

◆ AppendEntriesWithOffset()

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

Definition at line 632 of file lp_data/sparse_vector.h.

◆ ApplyIndexPermutation()

void ApplyIndexPermutation ( const IndexPermutation index_perm)

Definition at line 932 of file lp_data/sparse_vector.h.

◆ ApplyPartialIndexPermutation()

void ApplyPartialIndexPermutation ( const IndexPermutation index_perm)

Definition at line 940 of file lp_data/sparse_vector.h.

◆ begin()

IteratorType begin

Definition at line 447 of file lp_data/sparse_vector.h.

◆ CheckNoDuplicates() [1/2]

bool CheckNoDuplicates

Definition at line 675 of file lp_data/sparse_vector.h.

◆ CheckNoDuplicates() [2/2]

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

Definition at line 643 of file lp_data/sparse_vector.h.

◆ CleanUp()

void CleanUp

Definition at line 545 of file lp_data/sparse_vector.h.

◆ Clear()

void Clear

Definition at line 480 of file lp_data/sparse_vector.h.

◆ ClearAndRelease()

void ClearAndRelease

Definition at line 486 of file lp_data/sparse_vector.h.

◆ ComponentWiseDivide()

void ComponentWiseDivide ( const DenseVector factors)

Definition at line 792 of file lp_data/sparse_vector.h.

◆ ComponentWiseMultiply()

void ComponentWiseMultiply ( const DenseVector factors)

Definition at line 776 of file lp_data/sparse_vector.h.

◆ CopyToDenseVector()

void CopyToDenseVector ( Index  num_indices,
DenseVector dense_vector 
) const

Definition at line 800 of file lp_data/sparse_vector.h.

◆ DebugString()

std::string DebugString

Definition at line 1013 of file lp_data/sparse_vector.h.

◆ DeleteEntry()

void DeleteEntry ( Index  index)

Definition at line 693 of file lp_data/sparse_vector.h.

◆ DivideByConstant()

void DivideByConstant ( Fractional  factor)

Definition at line 784 of file lp_data/sparse_vector.h.

◆ end()

IteratorType end

Definition at line 452 of file lp_data/sparse_vector.h.

◆ GetCoefficient()

Fractional GetCoefficient ( EntryIndex  i) const
inlineprotected

Definition at line 350 of file lp_data/sparse_vector.h.

◆ GetFirstCoefficient()

Fractional GetFirstCoefficient ( ) const
inline

Definition at line 284 of file lp_data/sparse_vector.h.

◆ GetFirstIndex()

Index GetFirstIndex ( ) const
inline

Definition at line 280 of file lp_data/sparse_vector.h.

◆ GetIndex()

Index GetIndex ( EntryIndex  i) const
inlineprotected

Definition at line 345 of file lp_data/sparse_vector.h.

◆ GetLastCoefficient()

Fractional GetLastCoefficient ( ) const
inline

Definition at line 294 of file lp_data/sparse_vector.h.

◆ GetLastIndex()

Index GetLastIndex ( ) const
inline

Definition at line 290 of file lp_data/sparse_vector.h.

◆ IsCleanedUp()

bool IsCleanedUp

Definition at line 581 of file lp_data/sparse_vector.h.

◆ IsEmpty()

bool IsEmpty

Definition at line 530 of file lp_data/sparse_vector.h.

◆ IsEqualTo()

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

Definition at line 1001 of file lp_data/sparse_vector.h.

◆ LookUpCoefficient()

Fractional LookUpCoefficient ( Index  index) const

Definition at line 985 of file lp_data/sparse_vector.h.

◆ MoveEntryToFirstPosition()

void MoveEntryToFirstPosition ( Index  index)

Definition at line 741 of file lp_data/sparse_vector.h.

◆ MoveEntryToLastPosition()

void MoveEntryToLastPosition ( Index  index)

Definition at line 754 of file lp_data/sparse_vector.h.

◆ MoveTaggedEntriesTo()

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

Definition at line 955 of file lp_data/sparse_vector.h.

◆ MultiplyByConstant()

void MultiplyByConstant ( Fractional  factor)

Definition at line 768 of file lp_data/sparse_vector.h.

◆ MutableCoefficient()

Fractional& MutableCoefficient ( EntryIndex  i)
inlineprotected

Definition at line 363 of file lp_data/sparse_vector.h.

◆ MutableIndex()

Index& MutableIndex ( EntryIndex  i)
inlineprotected

Definition at line 358 of file lp_data/sparse_vector.h.

◆ num_entries()

EntryIndex num_entries ( ) const
inline

Definition at line 271 of file lp_data/sparse_vector.h.

◆ operator=() [1/2]

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

Definition at line 474 of file lp_data/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 810 of file lp_data/sparse_vector.h.

◆ PopulateFromDenseVector()

void PopulateFromDenseVector ( const DenseVector dense_vector)

Definition at line 619 of file lp_data/sparse_vector.h.

◆ PopulateFromSparseVector()

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

Definition at line 593 of file lp_data/sparse_vector.h.

◆ RemoveNearZeroEntries()

void RemoveNearZeroEntries ( Fractional  threshold)

Definition at line 710 of file lp_data/sparse_vector.h.

◆ RemoveNearZeroEntriesWithWeights()

void RemoveNearZeroEntriesWithWeights ( Fractional  threshold,
const DenseVector weights 
)

Definition at line 726 of file lp_data/sparse_vector.h.

◆ Reserve()

void Reserve ( EntryIndex  new_capacity)

Definition at line 496 of file lp_data/sparse_vector.h.

◆ ResizeDown()

void ResizeDown ( EntryIndex  new_size)
inlineprotected

Definition at line 337 of file lp_data/sparse_vector.h.

◆ SetCoefficient()

void SetCoefficient ( Index  index,
Fractional  value 
)

Definition at line 686 of file lp_data/sparse_vector.h.

◆ Swap()

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

Definition at line 535 of file lp_data/sparse_vector.h.

Member Data Documentation

◆ buffer_

std::unique_ptr<char[]> buffer_
protected

Definition at line 380 of file lp_data/sparse_vector.h.

◆ capacity_

EntryIndex capacity_
protected

Definition at line 382 of file lp_data/sparse_vector.h.

◆ coefficient_

Fractional* coefficient_
protected

Definition at line 386 of file lp_data/sparse_vector.h.

◆ index_

Index* index_
protected

Definition at line 385 of file lp_data/sparse_vector.h.

◆ may_contain_duplicates_

bool may_contain_duplicates_
mutableprotected

Definition at line 390 of file lp_data/sparse_vector.h.

◆ num_entries_

EntryIndex num_entries_
protected

Definition at line 381 of file lp_data/sparse_vector.h.


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