diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2011-04-21 00:52:17 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2011-04-21 00:52:17 -0400 |
commit | 282bc08647eb6856f798da0c64dd67530e02842a (patch) | |
tree | 97553e7e4208b9c0eb98e2168eb9faefc367ee66 /utils/ts.cc | |
parent | af0526d5994d641352bdba499d9a74f9e4824b4f (diff) |
beginning of fast sparse vector impl
Diffstat (limited to 'utils/ts.cc')
-rw-r--r-- | utils/ts.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/utils/ts.cc b/utils/ts.cc new file mode 100644 index 00000000..1febed3c --- /dev/null +++ b/utils/ts.cc @@ -0,0 +1,36 @@ +#include <iostream> +#include <map> +#include <cassert> + +#include <boost/static_assert.hpp> + +#include "prob.h" +#include "sparse_vector.h" +#include "fast_sparse_vector.h" + +using namespace std; + +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; + sranddev(); + int c = 0; + for (int i = 0; i < 1000000; ++i) { + FastSparseVector<float> x; + //SparseVector<float> x; + for (int j = 0; j < 15; ++j) { + const int k = rand() % 1000; + const float v = rand() / 3.14f; + x.set_value(k,v); + } + //SparseVector<float> y = x; + FastSparseVector<float> y = x; + y += x; + y = x; + if (y.value(50)) { c++; } + } + cerr << "Counted " << c << " times\n"; + return 0; +} + |