summaryrefslogtreecommitdiff
path: root/utils/ts.cc
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2011-04-22 13:38:32 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2011-04-22 13:38:32 -0400
commit9d393298ce21159907884ea9b7318c52585409ee (patch)
treecab034a01642abb2a067818f9c8f29999c4c6797 /utils/ts.cc
parentb6634dff2cd515d9e6f95416512db893a08bde29 (diff)
make compatible with FastSparseVector
Diffstat (limited to 'utils/ts.cc')
-rw-r--r--utils/ts.cc18
1 files changed, 16 insertions, 2 deletions
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 <typename T>
-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<prob_t> x;
+ cerr << "FSV<prob_t> = " << sizeof(FastSparseVector<prob_t>) << 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<float>) << endl;
cerr << " sizeof(FSV<float>) = " << sizeof(FastSparseVector<float>) << endl;
cerr << "sizeof(FSV<double>) = " << sizeof(FastSparseVector<double>) << endl;
test_unique<FastSparseVector<float> >();
+ test_logv();
// sranddev();
int c = 0;
FastSparseVector<float> p;