summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-16 01:56:51 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-16 01:56:51 +0000
commit4e6718978a6f3a003ee0618cc5a6b97f9899bb0e (patch)
treef715bf0fd0d8e71a558276343737cf36be8f97fe
parent66a93fb13f5dcb5440f65f79e028b7d86cd234aa (diff)
disable ill defined operations, add binary + -
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@278 ec762483-ff6d-05da-a07a-a48fb63a330f
-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)