void test13() { CS225::SparseVector v; for (int i=0;i<10;++i) v[i]=i; std::cout << "v = " << v << std::endl; v.PrintRaw(); std::cout << std::endl; v[1] = v[5] = v[2]; std::cout << "v = " << v << std::endl; v.PrintRaw(); std::cout << std::endl; v[1] += v[5] += v[2]; std::cout << "v = " << v << std::endl; v.PrintRaw(); std::cout << std::endl; }
void test12() { CS225::SparseVector v; for (int i=0;i<10;++i) v.Insert(i+1,i); std::cout << "v = " << v << std::endl; v.PrintRaw(); std::cout << std::endl; v[1] += v[5]; std::cout << "v = " << v << std::endl; v.PrintRaw(); std::cout << std::endl; v[2] -= v[2]; std::cout << "v = " << v << std::endl; v.PrintRaw(); std::cout << std::endl; }
void test17() { CS225::SparseVector v; for (int i=0;i<6;++i) v[i]=i+1; const CS225::SparseVector v_copy(v); std::cout << "v_copy = " << v_copy << std::endl; std::cout << "v_copy[4] = " << v_copy[4] << std::endl; const CS225::SparseVector v_1(0*v_copy); std::cout << "const CS225::SparseVector v_1(0*v_copy);\n"; v_1.PrintRaw(); }
void test11() { CS225::SparseVector v; for (int i=0;i<10;++i) v.Insert(i+1,i); std::cout << "v = " << v << std::endl; std::cout << "Second element is v[2]=" << v[2] << std::endl; v[2]=5; std::cout << "v = " << v << std::endl; v.PrintRaw(); std::cout << std::endl; int temp=v[5]; std::cout << "v[5]=" << temp << std::endl; v.PrintRaw(); std::cout << std::endl; v[6] += -5; v[5] -= 3; std::cout << "v = " << v << std::endl; v.PrintRaw(); std::cout << std::endl; v[2] = v[8]; std::cout << "v = " << v << std::endl; v.PrintRaw(); std::cout << std::endl; }
void test14() { // test for existance of nodes with 0 in them CS225::SparseVector v; for (int i=0;i<16;++i) v[i] = i%2; v.PrintRaw(); CS225::SparseVector v1,v2; for (int i=0;i<20;++i) { v1[i] = i%2; v2[i] = -v1[i]; } CS225::SparseVector v_sum=v1+v2; v_sum.PrintRaw(); CS225::SparseVector v3; for (int i=0;i<20;++i) v3[i]=i+1; for (int i=0;i<20;i+=2) v3[i] -= v3[i]; v3.PrintRaw(); std::cout << "v3 = " << v3 << std::endl; }
void test10 () { CS225::SparseVector v; v[1]=1; v[2]=2; v[13]=13; CS225::SparseVector & vr=v; vr[1]=0; vr[2]=0; vr[6]=6; vr[7]=7; vr[15]=15; v=vr; std::cout << "Should be equal\n"; std::cout << "v = "; v.PrintRaw(); std::cout << std::endl; std::cout << "vr = "; vr.PrintRaw(); std::cout << std::endl; }