From 203c3c3357b9ed8cfe44932c2bf5ea19eba6238c Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Fri, 27 Jan 2012 13:19:27 -0500 Subject: migration to new metric api for vest, clean up of unsupported/not functional code --- utils/fast_sparse_vector.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'utils/fast_sparse_vector.h') 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 S tanimoto_coef(const FastSparseVector &vec) const { -- cgit v1.2.3 From 378ba2373374015c8de4b360a30227f072616c6c Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Thu, 1 Mar 2012 23:09:32 -0500 Subject: compile fix on old versions of gcc with MPI enabled --- utils/fast_sparse_vector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/fast_sparse_vector.h') diff --git a/utils/fast_sparse_vector.h b/utils/fast_sparse_vector.h index 17fa47bf..d11be48f 100644 --- a/utils/fast_sparse_vector.h +++ b/utils/fast_sparse_vector.h @@ -363,7 +363,7 @@ class FastSparseVector { } ar & eff_size; while (it != this->end()) { - const std::pair wire_pair(FD::Convert(it->first), it->second); + const std::pair wire_pair(FD::Convert(it->first), it->second); ar & wire_pair; ++it; } -- cgit v1.2.3