COMBINATORIAL_BLAS  1.6
VectorTest.cpp
Go to the documentation of this file.
1 #include <sys/time.h>
2 #include <iostream>
3 #include <functional>
4 #include <algorithm>
5 #include <vector>
6 #include <sstream>
7 #include "../FullyDistSpVec.h"
8 #include "../FullyDistVec.h"
9 
10 using namespace std;
11 using namespace combblas;
12 
13 template <class T>
14 struct IsOdd : public unary_function<T,bool> {
15  bool operator() (T number) {return (number%2==1);}
16 };
17 
18 int main(int argc, char* argv[])
19 {
20  int nprocs, myrank;
21  MPI_Init(&argc, &argv);
22  MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
23  MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
24 
25  try
26  {
28  SPV_A.SetElement(2,2);
29  SPV_A.SetElement(83,-83);
30  SPV_A.SetElement(284,284);
31  SpParHelper::Print("Printing SPV_A\n");
32  SPV_A.DebugPrint();
33 
35  SPV_B.SetElement(2,4);
36  SPV_B.SetElement(184,368);
37  SPV_B.SetElement(83,-1);
38  SpParHelper::Print("Printing SPV_B\n");
39  SPV_B.DebugPrint();
40 
42  FDV.iota(64,0);
43  SpParHelper::Print("Printing FPV\n");
44  FDV.DebugPrint();
45 
47  SpParHelper::Print("Printing FPSV\n");
48  FDSV.DebugPrint();
49 
51  SPV_C.SetElement(2,2);
52  SPV_C.SetElement(4,4);
53  SPV_C.SetElement(5,-5);
54  SPV_C.SetElement(6,6);
55 
56  SpParHelper::Print("Printing SPV_C\n");
57  SPV_C.DebugPrint();
58 
60  SPV_D.SetElement(2,4);
61  SPV_D.SetElement(3,9);
62  SPV_D.SetElement(5,-25);
63  SPV_D.SetElement(7,-49);
64 
65  SpParHelper::Print("Printing SPV_D\n");
66  SPV_D.DebugPrint();
67 
68  SPV_C += SPV_D;
69  SPV_D += SPV_D;
70 
71  SpParHelper::Print("Printing SPV_C + SPV_D\n");
72  SPV_C.DebugPrint();
73 
74  SpParHelper::Print("Printing SPV_D + SPV_D\n");
75  SPV_D.DebugPrint();
76 
78  SPV_E.SetElement(0,3);
79  SPV_E.SetElement(1,7);
80  SPV_E.SetElement(2,10);
81 
82  SpParHelper::Print("Printing SPV_E\n");
83  SPV_E.DebugPrint();
84 
85  FullyDistSpVec<int64_t, int64_t> SPV_F = SPV_C(SPV_E);
86 
87  SpParHelper::Print("Printing SPV_F = SPV_C(SPV_E)\n");
88  SPV_F.DebugPrint();
90  FullyDistSpVec<int64_t, int64_t> SPV_J = SPV_H(SPV_F);
91  int64_t val = SPV_J[8];
92  stringstream tss;
93  string ss;
94  if(val == SPV_J.NOT_FOUND)
95  {
96  ss = "NOT_FOUND";
97  }
98  else
99  {
100  tss << val;
101  ss = tss.str();
102  }
103  if(myrank == 0)
104  cout << ss << endl;
105  SPV_J.SetElement(8, 777);
106 
107  val = SPV_J[8];
108  if(val == SPV_J.NOT_FOUND)
109  {
110  ss = "NOT_FOUND";
111  }
112  else
113  {
114  tss << val;
115  ss = tss.str();
116  }
117  if(myrank == 0)
118  cout << ss << endl;
119 
120  }
121  catch (exception& e)
122  {
123  cout << e.what() << endl;
124  }
125  MPI_Finalize();
126  return 0;
127 }
128 
void SetElement(IT indx, NT numx)
Indexing is performed 0-based.
FullyDistSpVec< IT, NT > Find(_Predicate pred) const
Return the elements for which pred is true.
void iota(IT globalsize, NT first)
long int64_t
Definition: compat.h:21
int main(int argc, char *argv[])
Definition: VectorTest.cpp:18
Definition: CCGrid.h:4