summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--decoder/sparse_vector.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/decoder/sparse_vector.h b/decoder/sparse_vector.h
index 455a162b..9c7c9c79 100644
--- a/decoder/sparse_vector.h
+++ b/decoder/sparse_vector.h
@@ -176,6 +176,17 @@ public:
return *this;
}
+ friend SparseVector<T> operator -(SparseVector<T> x,SparseVector<T> const& y) {
+ x-=y;
+ return x;
+ }
+ friend SparseVector<T> operator +(SparseVector<T> x,SparseVector<T> const& y) {
+ x+=y;
+ return x;
+ }
+
+private:
+ // DEPRECATED: becuase 0 values are dropped from the map, this doesn't even make sense if you have a fully populated (not really sparse re: what you'll ever use) vector
SparseVector<T> &operator-=(T const& x) {
for (typename MapType::iterator
it = values_.begin(); it != values_.end(); ++it)
@@ -189,7 +200,7 @@ public:
it->second += x;
return *this;
}
-
+public:
SparseVector<T> &operator/=(const T &x) {
for (typename MapType::iterator
it = values_.begin(); it != values_.end(); ++it)