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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
#include <sys/time.h>
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <sstream>
#include "../FullyDistSpVec.h"
#include "../FullyDistVec.h"
using namespace std;
using namespace combblas;
template <class T>
struct IsOdd : public unary_function<T,bool> {
bool operator() (T number) {return (number%2==1);}
};
int main(int argc, char* argv[])
{
int nprocs, myrank;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
try
{
FullyDistSpVec<int64_t, int64_t> SPV_A(1024);
SPV_A.SetElement(2,2);
SPV_A.SetElement(83,-83);
SPV_A.SetElement(284,284);
SpParHelper::Print("Printing SPV_A\n");
SPV_A.DebugPrint();
FullyDistSpVec<int64_t, int64_t> SPV_B(1024);
SPV_B.SetElement(2,4);
SPV_B.SetElement(184,368);
SPV_B.SetElement(83,-1);
SpParHelper::Print("Printing SPV_B\n");
SPV_B.DebugPrint();
FullyDistVec<int64_t, int64_t> FDV(-1);
FDV.iota(64,0);
SpParHelper::Print("Printing FPV\n");
FDV.DebugPrint();
FullyDistSpVec<int64_t, int64_t> FDSV = FDV.Find(IsOdd<int64_t>());
SpParHelper::Print("Printing FPSV\n");
FDSV.DebugPrint();
FullyDistSpVec<int64_t, int64_t> SPV_C(12);
SPV_C.SetElement(2,2);
SPV_C.SetElement(4,4);
SPV_C.SetElement(5,-5);
SPV_C.SetElement(6,6);
SpParHelper::Print("Printing SPV_C\n");
SPV_C.DebugPrint();
FullyDistSpVec<int64_t, int64_t> SPV_D(12);
SPV_D.SetElement(2,4);
SPV_D.SetElement(3,9);
SPV_D.SetElement(5,-25);
SPV_D.SetElement(7,-49);
SpParHelper::Print("Printing SPV_D\n");
SPV_D.DebugPrint();
SPV_C += SPV_D;
SPV_D += SPV_D;
SpParHelper::Print("Printing SPV_C + SPV_D\n");
SPV_C.DebugPrint();
SpParHelper::Print("Printing SPV_D + SPV_D\n");
SPV_D.DebugPrint();
FullyDistSpVec<int64_t, int64_t> SPV_E(3);
SPV_E.SetElement(0,3);
SPV_E.SetElement(1,7);
SPV_E.SetElement(2,10);
SpParHelper::Print("Printing SPV_E\n");
SPV_E.DebugPrint();
FullyDistSpVec<int64_t, int64_t> SPV_F = SPV_C(SPV_E);
SpParHelper::Print("Printing SPV_F = SPV_C(SPV_E)\n");
SPV_F.DebugPrint();
FullyDistSpVec<int64_t, int64_t> SPV_H = SPV_C;
FullyDistSpVec<int64_t, int64_t> SPV_J = SPV_H(SPV_F);
int64_t val = SPV_J[8];
stringstream tss;
string ss;
if(val == SPV_J.NOT_FOUND)
{
ss = "NOT_FOUND";
}
else
{
tss << val;
ss = tss.str();
}
if(myrank == 0)
cout << ss << endl;
SPV_J.SetElement(8, 777);
val = SPV_J[8];
if(val == SPV_J.NOT_FOUND)
{
ss = "NOT_FOUND";
}
else
{
tss << val;
ss = tss.str();
}
if(myrank == 0)
cout << ss << endl;
}
catch (exception& e)
{
cout << e.what() << endl;
}
MPI_Finalize();
return 0;
}
|