Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::glop::SparseVector< IndexType, IteratorType > Class Template Reference

Detailed Description

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

Definition at line 87 of file sparse_vector.h.

#include <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_ = nullptr
Fractionalcoefficient_ = nullptr
bool may_contain_duplicates_

Member Typedef Documentation

◆ DenseVector

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
typedef StrictITIVector<Index, Fractional> operations_research::glop::SparseVector< IndexType, IteratorType >::DenseVector

Definition at line 91 of file sparse_vector.h.

◆ Entry

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
using operations_research::glop::SparseVector< IndexType, IteratorType >::Entry = typename Iterator::Entry

Definition at line 95 of file sparse_vector.h.

◆ Index

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

Definition at line 89 of file sparse_vector.h.

◆ IndexPermutation

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
typedef Permutation<Index> operations_research::glop::SparseVector< IndexType, IteratorType >::IndexPermutation

Definition at line 92 of file sparse_vector.h.

◆ Iterator

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

Definition at line 94 of file sparse_vector.h.

Constructor & Destructor Documentation

◆ SparseVector() [1/3]

template<typename IndexType, typename IteratorType>
operations_research::glop::SparseVector< IndexType, IteratorType >::SparseVector ( )

Definition at line 467 of file sparse_vector.h.

◆ SparseVector() [2/3]

template<typename IndexType, typename IteratorType>
operations_research::glop::SparseVector< IndexType, IteratorType >::SparseVector ( const SparseVector< IndexType, IteratorType > & other)

Definition at line 475 of file sparse_vector.h.

◆ SparseVector() [3/3]

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
operations_research::glop::SparseVector< IndexType, IteratorType >::SparseVector ( SparseVector< IndexType, IteratorType > && other)
default

Member Function Documentation

◆ AddEntry()

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
void operations_research::glop::SparseVector< IndexType, IteratorType >::AddEntry ( Index index,
Fractional value )
inlineprotected

Definition at line 321 of file sparse_vector.h.

◆ AddMultipleToDenseVector()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::AddMultipleToDenseVector ( Fractional multiplier,
DenseVector * dense_vector ) const

Definition at line 828 of file sparse_vector.h.

◆ AddMultipleToSparseVectorAndDeleteCommonIndex()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::AddMultipleToSparseVectorAndDeleteCommonIndex ( Fractional multiplier,
Index removed_common_index,
Fractional drop_tolerance,
SparseVector< IndexType, IteratorType > * accumulator_vector ) const

Definition at line 838 of file sparse_vector.h.

◆ AddMultipleToSparseVectorAndIgnoreCommonIndex()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::AddMultipleToSparseVectorAndIgnoreCommonIndex ( Fractional multiplier,
Index removed_common_index,
Fractional drop_tolerance,
SparseVector< IndexType, IteratorType > * accumulator_vector ) const

Definition at line 847 of file sparse_vector.h.

◆ AllEntryIndices()

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
::util::IntegerRange< EntryIndex > operations_research::glop::SparseVector< IndexType, IteratorType >::AllEntryIndices ( ) const
inline

Definition at line 306 of file sparse_vector.h.

◆ AppendEntriesWithOffset()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::AppendEntriesWithOffset ( const SparseVector< IndexType, IteratorType > & sparse_vector,
Index offset )

Definition at line 639 of file sparse_vector.h.

◆ ApplyIndexPermutation()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::ApplyIndexPermutation ( const IndexPermutation & index_perm)

Definition at line 946 of file sparse_vector.h.

◆ ApplyPartialIndexPermutation()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::ApplyPartialIndexPermutation ( const IndexPermutation & index_perm)

Definition at line 954 of file sparse_vector.h.

◆ begin()

template<typename IndexType, typename IteratorType>
IteratorType operations_research::glop::SparseVector< IndexType, IteratorType >::begin ( ) const

Definition at line 452 of file sparse_vector.h.

◆ CheckNoDuplicates() [1/2]

template<typename IndexType, typename IteratorType>
bool operations_research::glop::SparseVector< IndexType, IteratorType >::CheckNoDuplicates ( ) const

Definition at line 682 of file sparse_vector.h.

◆ CheckNoDuplicates() [2/2]

template<typename IndexType, typename IteratorType>
bool operations_research::glop::SparseVector< IndexType, IteratorType >::CheckNoDuplicates ( StrictITIVector< Index, bool > * boolean_vector) const

Definition at line 650 of file sparse_vector.h.

◆ CleanUp()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::CleanUp ( )

Definition at line 552 of file sparse_vector.h.

◆ Clear()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::Clear ( )

Definition at line 487 of file sparse_vector.h.

◆ ClearAndRelease()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::ClearAndRelease ( )

Definition at line 493 of file sparse_vector.h.

◆ ComponentWiseDivide()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::ComponentWiseDivide ( const DenseVector & factors)

Definition at line 799 of file sparse_vector.h.

◆ ComponentWiseMultiply()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::ComponentWiseMultiply ( const DenseVector & factors)

Definition at line 783 of file sparse_vector.h.

◆ CopyToDenseVector()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::CopyToDenseVector ( Index num_indices,
DenseVector * dense_vector ) const

Definition at line 807 of file sparse_vector.h.

◆ DebugString()

template<typename IndexType, typename IteratorType>
std::string operations_research::glop::SparseVector< IndexType, IteratorType >::DebugString ( ) const

Definition at line 1027 of file sparse_vector.h.

◆ DeleteEntry()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::DeleteEntry ( Index index)

Definition at line 700 of file sparse_vector.h.

◆ DivideByConstant()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::DivideByConstant ( Fractional factor)

Definition at line 791 of file sparse_vector.h.

◆ end()

template<typename IndexType, typename IteratorType>
IteratorType operations_research::glop::SparseVector< IndexType, IteratorType >::end ( ) const

Definition at line 457 of file sparse_vector.h.

◆ GetCoefficient()

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
Fractional operations_research::glop::SparseVector< IndexType, IteratorType >::GetCoefficient ( EntryIndex i) const
inlineprotected

Definition at line 353 of file sparse_vector.h.

◆ GetFirstCoefficient()

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
Fractional operations_research::glop::SparseVector< IndexType, IteratorType >::GetFirstCoefficient ( ) const
inline

Definition at line 287 of file sparse_vector.h.

◆ GetFirstIndex()

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
Index operations_research::glop::SparseVector< IndexType, IteratorType >::GetFirstIndex ( ) const
inline

Definition at line 283 of file sparse_vector.h.

◆ GetIndex()

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
Index operations_research::glop::SparseVector< IndexType, IteratorType >::GetIndex ( EntryIndex i) const
inlineprotected

Definition at line 348 of file sparse_vector.h.

◆ GetLastCoefficient()

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
Fractional operations_research::glop::SparseVector< IndexType, IteratorType >::GetLastCoefficient ( ) const
inline

Definition at line 297 of file sparse_vector.h.

◆ GetLastIndex()

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
Index operations_research::glop::SparseVector< IndexType, IteratorType >::GetLastIndex ( ) const
inline

Definition at line 293 of file sparse_vector.h.

◆ IsCleanedUp()

template<typename IndexType, typename IteratorType>
bool operations_research::glop::SparseVector< IndexType, IteratorType >::IsCleanedUp ( ) const

Definition at line 588 of file sparse_vector.h.

◆ IsEmpty()

template<typename IndexType, typename IteratorType>
bool operations_research::glop::SparseVector< IndexType, IteratorType >::IsEmpty ( ) const

Definition at line 537 of file sparse_vector.h.

◆ IsEqualTo()

template<typename IndexType, typename IteratorType>
bool operations_research::glop::SparseVector< IndexType, IteratorType >::IsEqualTo ( const SparseVector< IndexType, IteratorType > & other) const

Definition at line 1015 of file sparse_vector.h.

◆ LookUpCoefficient()

template<typename IndexType, typename IteratorType>
Fractional operations_research::glop::SparseVector< IndexType, IteratorType >::LookUpCoefficient ( Index index) const

Definition at line 999 of file sparse_vector.h.

◆ MoveEntryToFirstPosition()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::MoveEntryToFirstPosition ( Index index)

Definition at line 748 of file sparse_vector.h.

◆ MoveEntryToLastPosition()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::MoveEntryToLastPosition ( Index index)

Definition at line 761 of file sparse_vector.h.

◆ MoveTaggedEntriesTo()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::MoveTaggedEntriesTo ( const IndexPermutation & index_perm,
SparseVector< IndexType, IteratorType > * output )

Definition at line 969 of file sparse_vector.h.

◆ MultiplyByConstant()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::MultiplyByConstant ( Fractional factor)

Definition at line 775 of file sparse_vector.h.

◆ MutableCoefficient()

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
Fractional & operations_research::glop::SparseVector< IndexType, IteratorType >::MutableCoefficient ( EntryIndex i)
inlineprotected

Definition at line 366 of file sparse_vector.h.

◆ MutableIndex()

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
Index & operations_research::glop::SparseVector< IndexType, IteratorType >::MutableIndex ( EntryIndex i)
inlineprotected

Definition at line 361 of file sparse_vector.h.

◆ num_entries()

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
EntryIndex operations_research::glop::SparseVector< IndexType, IteratorType >::num_entries ( ) const
inline

Definition at line 274 of file sparse_vector.h.

◆ operator=() [1/2]

template<typename IndexType, typename IteratorType>
SparseVector< IndexType, IteratorType > & operations_research::glop::SparseVector< IndexType, IteratorType >::operator= ( const SparseVector< IndexType, IteratorType > & other)

Definition at line 481 of file sparse_vector.h.

◆ operator=() [2/2]

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
SparseVector & operations_research::glop::SparseVector< IndexType, IteratorType >::operator= ( SparseVector< IndexType, IteratorType > && other)
default

◆ PermutedCopyToDenseVector()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::PermutedCopyToDenseVector ( const IndexPermutation & index_perm,
Index num_indices,
DenseVector * dense_vector ) const

Definition at line 817 of file sparse_vector.h.

◆ PopulateFromDenseVector()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::PopulateFromDenseVector ( const DenseVector & dense_vector)

Definition at line 626 of file sparse_vector.h.

◆ PopulateFromSparseVector()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::PopulateFromSparseVector ( const SparseVector< IndexType, IteratorType > & sparse_vector)

Definition at line 600 of file sparse_vector.h.

◆ RemoveNearZeroEntries()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::RemoveNearZeroEntries ( Fractional threshold)

Definition at line 717 of file sparse_vector.h.

◆ RemoveNearZeroEntriesWithWeights()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::RemoveNearZeroEntriesWithWeights ( Fractional threshold,
const DenseVector & weights )

Definition at line 733 of file sparse_vector.h.

◆ Reserve()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::Reserve ( EntryIndex new_capacity)

Definition at line 503 of file sparse_vector.h.

◆ ResizeDown()

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
void operations_research::glop::SparseVector< IndexType, IteratorType >::ResizeDown ( EntryIndex new_size)
inlineprotected

Definition at line 340 of file sparse_vector.h.

◆ SetCoefficient()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::SetCoefficient ( Index index,
Fractional value )

Definition at line 693 of file sparse_vector.h.

◆ Swap()

template<typename IndexType, typename IteratorType>
void operations_research::glop::SparseVector< IndexType, IteratorType >::Swap ( SparseVector< IndexType, IteratorType > * other)

Definition at line 542 of file sparse_vector.h.

Member Data Documentation

◆ buffer_

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
std::unique_ptr<char[]> operations_research::glop::SparseVector< IndexType, IteratorType >::buffer_
protected

Definition at line 383 of file sparse_vector.h.

◆ capacity_

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
EntryIndex operations_research::glop::SparseVector< IndexType, IteratorType >::capacity_
protected

Definition at line 385 of file sparse_vector.h.

◆ coefficient_

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
Fractional* operations_research::glop::SparseVector< IndexType, IteratorType >::coefficient_ = nullptr
protected

Definition at line 389 of file sparse_vector.h.

◆ index_

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
Index* operations_research::glop::SparseVector< IndexType, IteratorType >::index_ = nullptr
protected

Definition at line 388 of file sparse_vector.h.

◆ may_contain_duplicates_

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
bool operations_research::glop::SparseVector< IndexType, IteratorType >::may_contain_duplicates_
mutableprotected

Definition at line 393 of file sparse_vector.h.

◆ num_entries_

template<typename IndexType, typename IteratorType = VectorIterator<SparseVectorEntry<IndexType>>>
EntryIndex operations_research::glop::SparseVector< IndexType, IteratorType >::num_entries_
protected

Definition at line 384 of file sparse_vector.h.


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