summaryrefslogtreecommitdiff
path: root/utils/fast_sparse_vector.h
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2011-10-13 19:20:20 +0200
committerPatrick Simianer <p@simianer.de>2011-10-13 19:20:20 +0200
commitb9641702ba7aa86e9cc7ed0d4fffa4dd6271cc8f (patch)
treedb2fcc0e74d141f5c0b4e1602c04e0ea1015b239 /utils/fast_sparse_vector.h
parente377e9de738773d03e600681b0f0d2797df717c6 (diff)
svm impl, faster
Diffstat (limited to 'utils/fast_sparse_vector.h')
-rw-r--r--utils/fast_sparse_vector.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/utils/fast_sparse_vector.h b/utils/fast_sparse_vector.h
index 1301581a..8daaac85 100644
--- a/utils/fast_sparse_vector.h
+++ b/utils/fast_sparse_vector.h
@@ -214,6 +214,14 @@ class FastSparseVector {
}
return *this;
}
+ template <typename O>
+ inline FastSparseVector<O>& plus_eq_v_times_s(const FastSparseVector<O>& other, const O scalar) {
+ const typename FastSparseVector<O>::const_iterator end = other.end();
+ for (typename FastSparseVector<O>::const_iterator it = other.begin(); it != end; ++it) {
+ get_or_create_bin(it->first) += it->second * scalar;
+ }
+ return *this;
+ }
inline FastSparseVector& operator-=(const FastSparseVector& other) {
const typename FastSparseVector::const_iterator end = other.end();
for (typename FastSparseVector::const_iterator it = other.begin(); it != end; ++it) {