58 #include "../epetra_test_err.h"
67 int main(
int argc,
char *argv[]) {
77 MPI_Init(&argc,&argv);
86 if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
90 int verbose_int = verbose ? 1 : 0;
92 verbose = verbose_int==1 ?
true :
false;
95 Comm.SetTracebackMode(0);
98 if (verbose && Comm.
MyPID()==0)
125 int MyPID = Comm.
MyPID();
129 bool verbose1 = verbose;
131 if (verbose) verbose = (MyPID==0);
134 cerr <<
"================check_rowpermute_crsmatrix_local_diagonal=========="
138 int NumMyElements = 5;
139 long long NumGlobalElements = ((
long long)NumMyElements)*NumProc;
141 Epetra_Map Map(NumGlobalElements, NumMyElements, 0, Comm);
143 long long* p =
new long long[NumMyElements];
144 long long firstGlobalRow = ((
long long)MyPID)*NumMyElements;
150 cout <<
"Permutation P:"<<endl;
155 for(i=0; i<NumMyElements; ++i) {
156 p[i] = firstGlobalRow+NumMyElements-1-i;
158 cout <<
"p["<<firstGlobalRow+i<<
"]: "<<p[i]<<endl;
170 for(i=0; i<NumMyElements; ++i) {
171 long long row = firstGlobalRow+i;
175 A.InsertGlobalValues(row, 1, &val, &col);
181 cout <<
"********** matrix A: **************"<<endl;
190 cout <<
"************ permuted matrix B: ***************"<<endl;
203 int MyPID = Comm.
MyPID();
207 bool verbose1 = verbose;
209 if (verbose) verbose = (MyPID==0);
212 cerr <<
"================check_rowpermute_crsgraph_local_diagonal=========="
216 int NumMyElements = 5;
217 long long NumGlobalElements = ((
long long)NumMyElements)*NumProc;
219 Epetra_Map Map(NumGlobalElements, NumMyElements, 0, Comm);
221 long long* p =
new long long[NumMyElements];
222 long long firstGlobalRow = ((
long long)MyPID)*NumMyElements;
228 cout <<
"Permutation P:"<<endl;
233 for(i=0; i<NumMyElements; ++i) {
234 p[i] = firstGlobalRow+NumMyElements-1-i;
236 cout <<
"p["<<firstGlobalRow+i<<
"]: "<<p[i]<<endl;
247 for(i=0; i<NumMyElements; ++i) {
248 long long row = firstGlobalRow+i;
251 Agrph.InsertGlobalIndices(row, 1, &col);
254 Agrph.FillComplete();
257 cout <<
"*************** graph Agrph: ********************"<<endl;
258 cout << Agrph << endl;
266 cout <<
"************* permuted graph Bgrph: ****************"<<endl;
267 cout << Bgrph << endl;
279 int MyPID = Comm.
MyPID();
283 bool verbose1 = verbose;
285 if (verbose) verbose = (MyPID==0);
288 cerr <<
"================check_colpermute_crsgraph=========="
292 int NumMyElements = 5;
293 long long NumGlobalElements = ((
long long)NumMyElements)*NumProc;
295 Epetra_Map Map(NumGlobalElements, NumMyElements, 0, Comm);
297 long long* p =
new long long[NumMyElements];
298 long long firstGlobalRow = ((
long long)MyPID)*NumMyElements;
301 cout <<
"Permutation P:"<<endl;
306 for(i=0; i<NumMyElements; ++i) {
307 long long row = firstGlobalRow+i;
308 p[i] = NumGlobalElements - row - 1;
310 cout <<
"p["<<firstGlobalRow+i<<
"]: "<<p[i]<<endl;
320 for(i=0; i<NumMyElements; ++i) {
321 long long row = firstGlobalRow+i;
322 col = NumGlobalElements - row - 1;
324 Agrph.InsertGlobalIndices(row, 1, &col);
327 long long colm1 = col-1;
328 Agrph.InsertGlobalIndices(row, 1, &colm1);
331 if (col < NumGlobalElements-1) {
332 long long colp1 = col+1;
333 Agrph.InsertGlobalIndices(row, 1, &colp1);
337 Agrph.FillComplete();
340 cout <<
"*************** graph Agrph: ********************"<<endl;
341 cout << Agrph << endl;
346 bool column_permutation =
true;
350 cout <<
"************* column-permuted graph Bgrph: ****************"<<endl;
351 cout << Bgrph << endl;
363 int MyPID = Comm.
MyPID();
367 bool verbose1 = verbose;
369 if (verbose) verbose = (MyPID==0);
372 cerr <<
"================check_rowpermute_crsmatrix_global_diagonal=========="
376 int NumMyElements = 5;
377 long long NumGlobalElements = ((
long long)NumMyElements)*NumProc;
379 Epetra_Map Map(NumGlobalElements, NumMyElements, 0, Comm);
381 long long* p =
new long long[NumMyElements];
382 long long firstGlobalRow = ((
long long)MyPID)*NumMyElements;
398 for(i=0; i<NumMyElements; ++i) {
399 long long row = firstGlobalRow+i;
403 A.InsertGlobalValues(row, 1, &val, &col);
409 cout <<
"******************* matrix A: ****************************"<<endl;
414 cout <<
"Permutation P:"<<endl;
417 for(i=0; i<NumMyElements; ++i) {
418 long long globalrow = NumGlobalElements-(firstGlobalRow+i)-1;
421 cout <<
"p["<<firstGlobalRow+i<<
"]: "<<p[i]<<endl;
430 cout <<
"******************* permuted matrix Bglobal: *******************" <<endl;
431 cout << Bglobal << endl;
443 int MyPID = Comm.
MyPID();
447 bool verbose1 = verbose;
449 if (verbose) verbose = (MyPID==0);
452 cerr <<
"================check_colpermute_crsmatrix=========="
456 int NumMyElements = 5;
457 long long NumGlobalElements = ((
long long)NumMyElements)*NumProc;
459 Epetra_Map Map(NumGlobalElements, NumMyElements, 0, Comm);
461 long long* p =
new long long[NumMyElements];
462 long long firstGlobalRow = ((
long long)MyPID)*NumMyElements;
465 cout <<
"Permutation P:"<<endl;
470 for(i=0; i<NumMyElements; ++i) {
471 long long row = firstGlobalRow+i;
472 p[i] = NumGlobalElements - row - 1;
474 cout <<
"p["<<firstGlobalRow+i<<
"]: "<<p[i]<<endl;
485 for(i=0; i<NumMyElements; ++i) {
486 long long row = firstGlobalRow+i;
487 col = NumGlobalElements - row - 1;
490 A.InsertGlobalValues(row, 1, &val, &col);
493 long long colm1 = col-1;
495 A.InsertGlobalValues(row, 1, &val, &colm1);
498 if (col < NumGlobalElements-1) {
499 long long colp1 = col+1;
501 A.InsertGlobalValues(row, 1, &val, &colp1);
508 cout <<
"*************** matrix A: ********************"<<endl;
514 bool column_permutation =
true;
518 cout <<
"************* column-permuted matrix B: ****************"<<endl;
531 int MyPID = Comm.
MyPID();
535 bool verbose1 = verbose;
537 if (verbose) verbose = (MyPID==0);
540 cerr <<
"================check_rowpermute_multivector_local=========="
544 int NumMyElements = 5;
545 long long NumGlobalElements = ((
long long)NumMyElements)*NumProc;
547 Epetra_Map Map(NumGlobalElements, NumMyElements, 0, Comm);
549 long long* p =
new long long[NumMyElements];
550 long long firstGlobalRow = ((
long long)MyPID)*NumMyElements;
556 cout <<
"Permutation P:"<<endl;
561 for(i=0; i<NumMyElements; ++i) {
562 p[i] = firstGlobalRow+NumMyElements-1-i;
564 cout <<
"p["<<firstGlobalRow+i<<
"]: "<<p[i]<<endl;
574 for(i=0; i<NumMyElements; ++i) {
575 v0[i] = 1.0*(firstGlobalRow+i) + 0.1;
576 v1[i] = 1.0*(firstGlobalRow+i) + 0.2;
577 v2[i] = 1.0*(firstGlobalRow+i) + 0.3;
581 cout <<
"*************** MultiVector v: ********************"<<endl;
590 cout <<
"************* permuted MultiVector Pv: ****************"<<endl;
#define EPETRA_CHK_ERR(a)
std::string EpetraExt_Version()
virtual void Barrier() const =0
int check_colpermute_crsgraph(Epetra_Comm &Comm, bool verbose)
virtual int MyPID() const =0
int main(int argc, char **argv)
int check_rowpermute_crsmatrix_global_diagonal(Epetra_Comm &Comm, bool verbose)
int check_rowpermute_crsmatrix_local_diagonal(Epetra_Comm &Comm, bool verbose)
virtual int NumProc() const =0
int check_rowpermute_crsgraph_local_diagonal(Epetra_Comm &Comm, bool verbose)
int Broadcast(double *MyVals, int Count, int Root) const
int check_rowpermute_multivector_local(Epetra_Comm &Comm, bool verbose)
int check_colpermute_crsmatrix(Epetra_Comm &Comm, bool verbose)