14#ifndef OR_TOOLS_GLOP_RANK_ONE_UPDATE_H_
15#define OR_TOOLS_GLOP_RANK_ONE_UPDATE_H_
49 ColIndex u_index, ColIndex v_index,
73 if (multiplier != 0.0) {
92 if (multiplier != 0.0) {
127 const CompactSparseMatrix* storage_;
151 elementary_matrices_.clear();
157 elementary_matrices_.push_back(update_matrix);
164 for (
int i = elementary_matrices_.size() - 1; i >= 0; --i) {
165 elementary_matrices_[i].LeftSolve(
y);
174 if (
y->non_zeros.empty()) {
181 y->RepopulateSparseMask();
182 bool use_dense =
y->ShouldUseDenseIteration(hypersparse_ratio_);
183 for (
int i = elementary_matrices_.size() - 1; i >= 0; --i) {
185 elementary_matrices_[i].LeftSolve(&
y->values);
187 elementary_matrices_[i].LeftSolveWithNonZeros(
y);
188 use_dense =
y->ShouldUseDenseIteration(hypersparse_ratio_);
191 y->ClearSparseMask();
192 y->ClearNonZerosIfTooDense(hypersparse_ratio_);
199 const size_t end = elementary_matrices_.size();
200 for (
int i = 0; i <
end; ++i) {
201 elementary_matrices_[i].RightSolve(d);
219 const size_t end = elementary_matrices_.size();
220 for (
int i = 0; i <
end; ++i) {
222 elementary_matrices_[i].RightSolve(&d->
values);
224 elementary_matrices_[i].RightSolveWithNonZeros(d);
245 mutable double dtime_ = 0.0;
247 double hypersparse_ratio_;
248 EntryIndex num_entries_;
249 std::vector<RankOneUpdateElementaryMatrix> elementary_matrices_;
EntryIndex num_entries() const
void ColumnCopyToDenseColumn(ColIndex col, DenseColumn *dense_column) const
void ColumnAddMultipleToDenseColumn(ColIndex col, Fractional multiplier, DenseColumn::View dense_column) const
Fractional ColumnScalarProduct(ColIndex col, const DenseRow &vector) const
ColumnView column(ColIndex col) const
void ColumnAddMultipleToSparseScatteredColumn(ColIndex col, Fractional multiplier, ScatteredColumn *column) const
void LeftMultiply(DenseRow *y) const
Computes y.T for a given row vector.
void RightSolve(DenseColumn *x) const
void RightSolveWithNonZeros(ScatteredColumn *x) const
void LeftSolveWithNonZeros(ScatteredRow *y) const
void LeftSolve(DenseRow *y) const
EntryIndex num_entries() const
RankOneUpdateElementaryMatrix(const CompactSparseMatrix *storage, ColIndex u_index, ColIndex v_index, Fractional u_dot_v)
void RightMultiply(DenseColumn *x) const
Computes T.x for a given column vector.
RankOneUpdateFactorization & operator=(const RankOneUpdateFactorization &)=delete
void RightSolve(DenseColumn *d) const
Right-solves all systems from left to right, i.e. T_i.d_{i+1} = d_i.
void LeftSolveWithNonZeros(ScatteredRow *y) const
double DeterministicTimeSinceLastReset() const
void ResetDeterministicTime()
EntryIndex num_entries() const
void set_hypersparse_ratio(double value)
This is currently only visible for testing.
void RightSolveWithNonZeros(ScatteredColumn *d) const
void Clear()
Deletes all elementary matrices of this factorization.
void LeftSolve(DenseRow *y) const
Left-solves all systems from right to left, i.e. y_i = y_{i+1}.(T_i)^{-1}.
void Update(const RankOneUpdateElementaryMatrix &update_matrix)
Updates the factorization.
RankOneUpdateFactorization(const RankOneUpdateFactorization &)=delete
This type is neither copyable nor movable.
RankOneUpdateFactorization()
const DenseRow & Transpose(const DenseColumn &col)
Similar comment as the other Transpose() implementation above.
bool IsAllFalse(const BoolVector &v)
Returns true if the given vector of bool is all false.
static double DeterministicTimeForFpOperations(int64_t n)
In SWIG mode, we don't want anything besides these top-level includes.
#define RETURN_IF_NULL(x)
std::optional< int64_t > end
void ClearNonZerosIfTooDense(double ratio_for_using_dense_representation)
void ClearSparseMask()
Efficiently clears the is_non_zero vector.
StrictITIVector< Index, Fractional > values
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
StrictITIVector< Index, bool > is_non_zero