From 1fbaa19e83dc796cb08b5ee331baa10a23b6fd84 Mon Sep 17 00:00:00 2001 From: Sam Morley <41870650+inakleinbottle@users.noreply.github.com> Date: Fri, 5 Feb 2021 12:32:31 +0000 Subject: [PATCH] Added implmentations for `add_scal_div` and `sub_scal_div` where rhs is a key. --- libalgebra/sparse_vector.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libalgebra/sparse_vector.h b/libalgebra/sparse_vector.h index f1ff1ba5..0bef7029 100644 --- a/libalgebra/sparse_vector.h +++ b/libalgebra/sparse_vector.h @@ -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 {