11 #include <Epetra_config.h>
33 if (comm.
MyPID () == 0) {
39 #ifdef EPETRA_NO_32BIT_GLOBAL_INDICES
48 #endif // EPETRA_NO_32BIT_GLOBAL_INDICES
61 const global_ordinal_type numGlobalEntries = comm.
NumProc () * 5;
64 const global_ordinal_type indexBase = 0;
68 Epetra_Map contigMap (numGlobalEntries, indexBase, comm);
87 (void) x.
Norm2 (&theNorm);
88 out <<
"Norm of x (all entries are 42.0): " << theNorm << endl;
95 (void) x.
Norm2 (&theNorm);
96 out <<
"Norm of x (random numbers): " << theNorm << endl;
103 const int localLength = x.
MyLength ();
108 for (
int localIndex = 0; localIndex < localLength; ++localIndex) {
109 if (x[localIndex] < 0.5) {
115 (void) comm.
SumAll (&localCount, &globalCount, 1);
119 out <<
"x has " << globalCount <<
" entr"
120 << (globalCount != 1 ?
"ies" :
"y")
121 <<
" less than 0.5." << endl;
130 const int localLength = x.
MyLength ();
131 for (
int localIndex = 0; localIndex < localLength; ++localIndex) {
133 x[localIndex] +=
static_cast<double> (localIndex);
138 (void) x.
Norm2 (&theNorm);
139 out <<
"Norm of x (modified random numbers): " << theNorm << endl;
153 MPI_Init (&argc, &argv);
159 if (comm.
MyPID () == 0) {
160 cout <<
"Total number of processes: " << comm.
NumProc () << endl;
167 if (comm.
MyPID () == 0) {
168 cout <<
"End Result: TEST PASSED" << endl;
174 (void) MPI_Finalize ();
Epetra_Map: A class for partitioning vectors and matrices.
int Random()
Set multi-vector values to random numbers.
int PutScalar(double ScalarConstant)
Initialize all values in a multi-vector with constant value.
int MyLength() const
Returns the local vector length on the calling processor of vectors in the multi-vector.
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
int MyPID() const
Return my process ID.
Epetra_MpiComm: The Epetra MPI Communication Class.
std::string Epetra_Version()
virtual int MyPID() const =0
Return my process ID.
virtual int SumAll(double *PartialSums, double *GlobalSums, int Count) const =0
Epetra_Comm Global Sum function.
Epetra_Comm: The Epetra Communication Abstract Base Class.
long long global_ordinal_type
int NumProc() const
Returns total number of processes (always returns 1 for SerialComm).
Epetra_SerialComm: The Epetra Serial Communication Class.
virtual int NumProc() const =0
Returns total number of processes.
int Norm2(double *Result) const
Compute 2-norm of each vector in multi-vector.
int main(int argc, char *argv[])
void exampleRoutine(const Epetra_Comm &comm, std::ostream &out)