From 9d393298ce21159907884ea9b7318c52585409ee Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Fri, 22 Apr 2011 13:38:32 -0400 Subject: make compatible with FastSparseVector --- utils/ts.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'utils/ts.cc') diff --git a/utils/ts.cc b/utils/ts.cc index 28b5f9b1..563794c5 100644 --- a/utils/ts.cc +++ b/utils/ts.cc @@ -11,7 +11,7 @@ using namespace std; template -void Print(const T& x) { +void MPrint(const T& x) { typename T::const_iterator it = x.begin(); for (; it != x.end(); ++it) { cerr << it->first << ":" << it->second << " "; @@ -24,16 +24,30 @@ void test_unique() { T x; x.set_value(100, 1.0); x.set_value(100, 2.0); - Print(x); + MPrint(x); assert(x.size() == 1); assert(x.value(100) == 2.0); } +void test_logv() { + FastSparseVector x; + cerr << "FSV = " << sizeof(FastSparseVector) << endl; + x.set_value(999, prob_t(0.5)); + x.set_value(0, prob_t()); + x.set_value(1, prob_t(1)); + MPrint(x); + x += x; + MPrint(x); + x -= x; + MPrint(x); +} + int main() { cerr << sizeof(prob_t) << " " << sizeof(LogVal) << endl; cerr << " sizeof(FSV) = " << sizeof(FastSparseVector) << endl; cerr << "sizeof(FSV) = " << sizeof(FastSparseVector) << endl; test_unique >(); + test_logv(); // sranddev(); int c = 0; FastSparseVector p; -- cgit v1.2.3