diff options
author | Patrick Simianer <p@simianer.de> | 2014-06-12 13:56:42 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-06-12 13:56:42 +0200 |
commit | a39aa79b18347e22ef36ebc0da5a7eb220bcb23f (patch) | |
tree | 2c0f3009f8e381002bfeb82c0ea3bd0c41125761 /utils/fast_sparse_vector.h | |
parent | 62bd9a4bdcea606d6ff2031fa4b207ef20caac31 (diff) | |
parent | 0e2f8d3d049f06afb08b4639c6a28aa5461cdc78 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'utils/fast_sparse_vector.h')
-rw-r--r-- | utils/fast_sparse_vector.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/utils/fast_sparse_vector.h b/utils/fast_sparse_vector.h index 590a60c4..6e2a77cd 100644 --- a/utils/fast_sparse_vector.h +++ b/utils/fast_sparse_vector.h @@ -384,13 +384,21 @@ class FastSparseVector { T dot(const std::vector<T>& v) const { T res = T(); for (const_iterator it = begin(), e = end(); it != e; ++it) +#if FP_FAST_FMA + if (static_cast<unsigned>(it->first) < v.size()) res = std::fma(it->second, v[it->first], res); +#else if (static_cast<unsigned>(it->first) < v.size()) res += it->second * v[it->first]; +#endif return res; } T dot(const FastSparseVector<T>& other) const { T res = T(); for (const_iterator it = begin(), e = end(); it != e; ++it) +#if FP_FAST_FMA + res = std::fma(other.value(it->first), it->second, res); +#else res += other.value(it->first) * it->second; +#endif return res; } bool operator==(const FastSparseVector<T>& other) const { |