diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2012-01-27 13:19:27 -0500 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2012-01-27 13:19:27 -0500 |
commit | 203c3c3357b9ed8cfe44932c2bf5ea19eba6238c (patch) | |
tree | c446f8e8afbe194ef656b33cfc643f83633cf18c /utils | |
parent | 481a120564fdb73c8c6833e2102acb533683261c (diff) |
migration to new metric api for vest, clean up of unsupported/not functional code
Diffstat (limited to 'utils')
-rw-r--r-- | utils/fast_sparse_vector.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/utils/fast_sparse_vector.h b/utils/fast_sparse_vector.h index 1301581a..17fa47bf 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 { |