14#ifndef OR_TOOLS_LP_DATA_SCATTERED_VECTOR_H_
15#define OR_TOOLS_LP_DATA_SCATTERED_VECTOR_H_
20#include "absl/log/check.h"
29template <
typename IndexType>
51template <
typename Index,
85 return Iterator(this->non_zeros.data(), this->values.data(), EntryIndex(0));
87 Iterator
end()
const {
88 return Iterator(this->non_zeros.data(), this->values.data(),
117 double ratio_for_using_dense_representation)
const {
119 return static_cast<double>(
non_zeros.size()) >
120 ratio_for_using_dense_representation *
Specializations used in the code.
RowIndex row() const
Returns the row of the current entry.
ScatteredColumnEntry(const RowIndex *indices, const Fractional *coefficients, EntryIndex i)
ColIndex column() const
Returns the column of the current entry.
ScatteredRowEntry(const ColIndex *indices, const Fractional *coefficients, EntryIndex i)
const Fractional * coefficient_
ScatteredVectorEntry(const Index *indices, const Fractional *coefficients, EntryIndex i)
Fractional coefficient() const
void assign(IntType size, const T &v)
void resize(IntType size)
absl::Span< const double > coefficients
bool IsAllZero(const Container &input)
Returns true if the given Fractional container is all zeros.
bool IsAllFalse(const BoolVector &v)
Returns true if the given vector of bool is all false.
const ScatteredRow & TransposedView(const ScatteredColumn &c)
In SWIG mode, we don't want anything besides these top-level includes.
Fractional operator[](Index index) const
void ClearNonZerosIfTooDense(double ratio_for_using_dense_representation)
void Add(Index index, Fractional value)
static constexpr const double kDefaultRatioForUsingDenseIteration
Fractional & operator[](Index index)
void ClearSparseMask()
Efficiently clears the is_non_zero vector.
void SortNonZerosIfNeeded()
StrictITIVector< Index, Fractional > values
bool non_zeros_are_sorted
void ClearNonZerosIfTooDense()
void RepopulateSparseMask()
Update the is_non_zero vector to be consistent with the non_zeros vector.
bool ShouldUseDenseIteration(double ratio_for_using_dense_representation) const
std::vector< Index > non_zeros
bool ShouldUseDenseIteration() const
size_t NumNonZerosEstimate() const
StrictITIVector< Index, bool > is_non_zero