summaryrefslogtreecommitdiff
path: root/utils/fast_sparse_vector.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/fast_sparse_vector.h')
-rw-r--r--utils/fast_sparse_vector.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/utils/fast_sparse_vector.h b/utils/fast_sparse_vector.h
index 8fe6cb3d..2c49948c 100644
--- a/utils/fast_sparse_vector.h
+++ b/utils/fast_sparse_vector.h
@@ -178,6 +178,12 @@ class FastSparseVector {
T l2norm() const {
return sqrt(l2norm_sq());
}
+ T pnorm(const double p) const {
+ T sum = T();
+ for (const_iterator it = begin(), e = end(); it != e; ++it)
+ sum += pow(fabs(it->second), p);
+ return pow(sum, 1.0 / p);
+ }
// if values are binary, gives |A intersect B|/|A union B|
template<typename S>
S tanimoto_coef(const FastSparseVector<S> &vec) const {
@@ -373,7 +379,7 @@ class FastSparseVector {
}
ar & eff_size;
while (it != this->end()) {
- const std::pair<const std::string&, const T&> wire_pair(FD::Convert(it->first), it->second);
+ const std::pair<std::string, T> wire_pair(FD::Convert(it->first), it->second);
ar & wire_pair;
++it;
}