COMBINATORIAL_BLAS
1.3
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
ReleaseTests
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
12
template
<
class
T>
13
struct
IsOdd
:
public
unary_function<T,bool> {
14
bool
operator() (T number) {
return
(number%2==1);}
15
};
16
17
int
main
(
int
argc,
char
* argv[])
18
{
19
int
nprocs, myrank;
20
MPI_Init(&argc, &argv);
21
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
22
MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
23
24
try
25
{
26
FullyDistSpVec<int64_t, int64_t>
SPV_A(1024);
27
SPV_A.
SetElement
(2,2);
28
SPV_A.
SetElement
(83,-83);
29
SPV_A.
SetElement
(284,284);
30
SpParHelper::Print
(
"Printing SPV_A\n"
);
31
SPV_A.
DebugPrint
();
32
33
FullyDistSpVec<int64_t, int64_t>
SPV_B(1024);
34
SPV_B.
SetElement
(2,4);
35
SPV_B.
SetElement
(184,368);
36
SPV_B.
SetElement
(83,-1);
37
SpParHelper::Print
(
"Printing SPV_B\n"
);
38
SPV_B.
DebugPrint
();
39
40
FullyDistVec<int64_t, int64_t>
FDV(-1);
41
FDV.
iota
(64,0);
42
SpParHelper::Print
(
"Printing FPV\n"
);
43
FDV.
DebugPrint
();
44
45
FullyDistSpVec<int64_t, int64_t>
FDSV = FDV.
Find
(
IsOdd<int64_t>
());
46
SpParHelper::Print
(
"Printing FPSV\n"
);
47
FDSV.
DebugPrint
();
48
49
FullyDistSpVec<int64_t, int64_t>
SPV_C(12);
50
SPV_C.
SetElement
(2,2);
51
SPV_C.
SetElement
(4,4);
52
SPV_C.
SetElement
(5,-5);
53
SPV_C.
SetElement
(6,6);
54
55
SpParHelper::Print
(
"Printing SPV_C\n"
);
56
SPV_C.
DebugPrint
();
57
58
FullyDistSpVec<int64_t, int64_t>
SPV_D(12);
59
SPV_D.
SetElement
(2,4);
60
SPV_D.
SetElement
(3,9);
61
SPV_D.
SetElement
(5,-25);
62
SPV_D.
SetElement
(7,-49);
63
64
SpParHelper::Print
(
"Printing SPV_D\n"
);
65
SPV_D.
DebugPrint
();
66
67
SPV_C += SPV_D;
68
SPV_D += SPV_D;
69
70
SpParHelper::Print
(
"Printing SPV_C + SPV_D\n"
);
71
SPV_C.
DebugPrint
();
72
73
SpParHelper::Print
(
"Printing SPV_D + SPV_D\n"
);
74
SPV_D.
DebugPrint
();
75
76
FullyDistSpVec<int64_t, int64_t>
SPV_E(3);
77
SPV_E.
SetElement
(0,3);
78
SPV_E.
SetElement
(1,7);
79
SPV_E.
SetElement
(2,10);
80
81
SpParHelper::Print
(
"Printing SPV_E\n"
);
82
SPV_E.
DebugPrint
();
83
84
FullyDistSpVec<int64_t, int64_t>
SPV_F = SPV_C(SPV_E);
85
86
SpParHelper::Print
(
"Printing SPV_F = SPV_C(SPV_E)\n"
);
87
SPV_F.
DebugPrint
();
88
FullyDistSpVec<int64_t, int64_t>
SPV_H = SPV_C;
89
FullyDistSpVec<int64_t, int64_t>
SPV_J = SPV_H(SPV_F);
90
int64_t
val = SPV_J[8];
91
stringstream tss;
92
string
ss;
93
if
(val == SPV_J.NOT_FOUND)
94
{
95
ss =
"NOT_FOUND"
;
96
}
97
else
98
{
99
tss << val;
100
ss = tss.str();
101
}
102
if
(myrank == 0)
103
cout << ss << endl;
104
SPV_J.
SetElement
(8, 777);
105
106
val = SPV_J[8];
107
if
(val == SPV_J.NOT_FOUND)
108
{
109
ss =
"NOT_FOUND"
;
110
}
111
else
112
{
113
tss << val;
114
ss = tss.str();
115
}
116
if
(myrank == 0)
117
cout << ss << endl;
118
119
}
120
catch
(exception& e)
121
{
122
cout << e.what() << endl;
123
}
124
MPI_Finalize();
125
return
0;
126
}
127
Generated on Wed Feb 6 2013 01:36:33 for COMBINATORIAL_BLAS by
1.8.1.1