From 4e6718978a6f3a003ee0618cc5a6b97f9899bb0e Mon Sep 17 00:00:00 2001 From: graehl Date: Fri, 16 Jul 2010 01:56:51 +0000 Subject: disable ill defined operations, add binary + - git-svn-id: https://ws10smt.googlecode.com/svn/trunk@278 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/sparse_vector.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 operator -(SparseVector x,SparseVector const& y) { + x-=y; + return x; + } + friend SparseVector operator +(SparseVector x,SparseVector 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 &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 &operator/=(const T &x) { for (typename MapType::iterator it = values_.begin(); it != values_.end(); ++it) -- cgit v1.2.3