18 #define ITYPE long long
19 #define OFFSET_EPETRA64 ((long long)(2)*(long long)INT_MAX)
29 #define FINALIZE MPI_Finalize()
50 #define MIN(a,b) ((a) < (b) ? (a) : (b))
52 int main(
int narg,
char *arg[])
64 int me = comm.
MyPID();
67 ITYPE nGlobalRows = 10;
69 nGlobalRows = (
ITYPE) atol(arg[1]);
71 bool verbose = (nGlobalRows < 20);
75 int nMyRows = (int) (nGlobalRows / np + (nGlobalRows % np > me));
76 ITYPE myFirstRow = (
ITYPE)(me * (nGlobalRows / np) +
MIN(nGlobalRows%np, me));
78 for (
int i = 0; i < nMyRows; i++)
81 if (verbose) rowMap->
Print(std::cout);
85 std::vector<int> nnzPerRow(nMyRows+1, 0);
90 std::vector<ITYPE> iv(3*nMyRows+1);
91 std::vector<ITYPE> jv(3*nMyRows+1);
92 std::vector<double> vv(3*nMyRows+1);
95 ITYPE nMyNonzeros = 0;
96 for (
ITYPE i = 0, myrowcnt = 0; i < nGlobalRows; i++) {
97 if (rowMap->
MyGID(i+OFFSET_EPETRA64)) {
102 vv[nMyNonzeros] = -1;
104 std::cout <<
"(" << iv[nMyNonzeros] <<
"," << jv[nMyNonzeros] <<
")="
105 << vv[nMyNonzeros] <<
" on processor " << me
106 <<
" in " << myrowcnt << std::endl;
108 nnzPerRow[myrowcnt]++;
113 vv[nMyNonzeros] = ((i == 0 || i == nGlobalRows-1) ? 1. : 2.);
115 std::cout <<
"(" << iv[nMyNonzeros] <<
"," << jv[nMyNonzeros] <<
")="
116 << vv[nMyNonzeros] <<
" on processor " << me
117 <<
" in " << myrowcnt << std::endl;
119 nnzPerRow[myrowcnt]++;
121 if (i < nGlobalRows - 1) {
124 vv[nMyNonzeros] = -1;
126 std::cout <<
"(" << iv[nMyNonzeros] <<
"," << jv[nMyNonzeros] <<
")="
127 << vv[nMyNonzeros] <<
" on processor " << me
128 <<
" in " << myrowcnt << std::endl;
130 nnzPerRow[myrowcnt]++;
144 for (
int i=0; i < nMyRows; i++) {
147 std::cout <<
"InsertGlobalValus row " << iv[sum]
148 <<
" count " << nnzPerRow[i]
149 <<
" cols " << jv[sum] <<
" " << jv[sum+1] <<
" ";
150 if (nnzPerRow[i] == 3) std::cout << jv[sum+2];
151 std::cout << std::endl;
168 if (verbose) A->
Print(std::cout);
175 A->
Multiply(
false, sanity, sanityres);
177 double jjone, jjtwo, jjmax;
178 sanityres.Norm1(&jjone);
179 sanityres.Norm2(&jjtwo);
180 sanityres.NormInf(&jjmax);
182 std::cout <<
"SanityTest norms 1/2/inf: " << jjone <<
" "
183 << jjtwo <<
" " << jjmax << std::endl;
185 bool test_failed = (jjone != 0) || (jjtwo != 0) || (jjmax != 0);
187 sanityres.MinValue(&jjone);
188 sanityres.MeanValue(&jjtwo);
189 sanityres.MaxValue(&jjmax);
191 std::cout <<
"SanityTest values min/max/avg: " << jjone <<
" "
192 << jjmax <<
" " << jjtwo << std::endl;
194 test_failed = test_failed || (jjone != 0) || (jjtwo != 0) || (jjmax != 0);
198 std::cout <<
"Bug_5794_IndexBase_LL tests FAILED" << std::endl;
203 delete [] myGlobalRows;
Epetra_Map: A class for partitioning vectors and matrices.
const Epetra_Map & RangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
int Multiply(bool TransA, const Epetra_Vector &x, Epetra_Vector &y) const
Returns the result of a Epetra_CrsMatrix multiplied by a Epetra_Vector x in y.
virtual void Print(std::ostream &os) const
Print object to an output stream.
int PutScalar(double ScalarConstant)
Initialize all values in a multi-vector with constant value.
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Insert a list of elements in a given global row of the matrix.
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.
int FillComplete(bool OptimizeDataStorage=true)
Signal that data entry is complete. Perform transformations to local index space. ...
virtual void Print(std::ostream &os) const
Print method.
bool MyGID(int GID_in) const
Returns true if the GID passed in belongs to the calling processor in this map, otherwise returns fal...
int NumProc() const
Returns total number of processes (always returns 1 for SerialComm).
Epetra_SerialComm: The Epetra Serial Communication Class.
Epetra_CrsMatrix: A class for constructing and using real-valued double-precision sparse compressed r...
const Epetra_Map & DomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator. ...
int main(int argc, char *argv[])