summaryrefslogtreecommitdiff
path: root/fast/test/test_sparse_vector.cc
blob: 426bed1e49020263c43a55b9011fb3ba18798221 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "sparse_vector.hh"


int
main(void)
{
  Sv::SparseVector<string, score_t> a;
  a.insert("1", 1);
  a.insert("2", 2);
  cout << "a:" << a << endl;

  Sv::SparseVector<string, score_t> b;
  b.insert("2", 2);
  cout << "b:" << b << endl;

  Sv::SparseVector<string, score_t> c = a + b;
  cout << "a+b:" << c << endl;

  a += b;
  cout << "a+=b:" << a << endl;

  a -= b;
  cout << "a-=b:" << a << endl;

  cout << "a*2:" << a*2 << endl;

  a *= 2;
  cout << "a*=2:" << a << endl;

  string s("\"a\"=2 \"b\"=3");
  Sv::SparseVector<string, score_t>* sv = new Sv::SparseVector<string, score_t>(s);
  cout << *sv << endl;
  cout << sv->dot(*sv) << endl;

  return 0;
}