Skip to content

Commit

Permalink
Merge pull request #6 from terrylyons/fix-key-add-sub-scal-div
Browse files Browse the repository at this point in the history
Fix key add sub scal div
  • Loading branch information
inakleinbottle authored Feb 5, 2021
2 parents 6c94107 + 1fbaa19 commit f65bc30
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libalgebra/sparse_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,20 @@ class sparse_vector :
}
return *this;
}

inline sparse_vector& add_scal_div(const KEY& rhs, const RATIONAL& s)
{
if (zero == (operator[](rhs) += one / s)) erase(rhs);
return *this;

}

inline sparse_vector& sub_scal_div(const KEY& rhs, const RATIONAL& s)
{
if (zero == (operator[](rhs) -= one / s)) erase(rhs);
return *this;
}

/// Compares the instance to a sparse_vector.
bool operator==(const sparse_vector& rhs) const
{
Expand Down

0 comments on commit f65bc30

Please sign in to comment.