diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-16 01:56:51 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-16 01:56:51 +0000 |
commit | f15664f3c9f2443b96c30735feae01bc3552d3b5 (patch) | |
tree | 0be425c5c217af05c81a1f6d5cf12a9dcda44148 /decoder | |
parent | 8d7ee7ad908b1fd797881a140057f3504b845b87 (diff) |
disable ill defined operations, add binary + -
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@278 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder')
-rw-r--r-- | decoder/sparse_vector.h | 13 |
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) |