64 #include "../../test/epetra_test_err.h"
69 long long NumGlobalNonzeros1,
long long* MyGlobalElements,
bool verbose);
74 int main(
int argc,
char *argv[]) {
85 MPI_Init(&argc,&argv);
88 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
102 if(argv[1][0]==
'-' && argv[1][1]==
'v') {
107 if(verbose && rank == 0)
116 int MyPID = Comm.
MyPID();
118 if(verbose) cout <<
"Processor "<<MyPID<<
" of "<< NumProc <<
" is alive." << endl;
120 bool verbose1 = verbose;
123 if(verbose && rank != 0)
126 int NumMyEquations = 5;
127 long long NumGlobalEquations = NumMyEquations*NumProc+
EPETRA_MIN(NumProc,3);
136 long long* MyGlobalElements =
new long long[Map.
NumMyElements()];
142 int* NumNz =
new int[NumMyEquations];
147 for(i=0; i<NumMyEquations; i++)
148 if(MyGlobalElements[i]==0 || MyGlobalElements[i] == NumGlobalEquations-1)
163 Indices =
new long long[2];
167 for(i = 0; i < NumMyEquations; i++) {
168 if(MyGlobalElements[i] == 0) {
172 else if(MyGlobalElements[i] == NumGlobalEquations-1) {
173 Indices[0] = NumGlobalEquations-2;
177 Indices[0] = MyGlobalElements[i]-1;
178 Indices[1] = MyGlobalElements[i]+1;
181 forierr += !(
A.InsertGlobalIndices(MyGlobalElements[i], NumEntries, Indices)==0);
182 forierr += !(
A.InsertGlobalIndices(MyGlobalElements[i], 1, MyGlobalElements+i)>0);
200 if(verbose) cout <<
"\n*****Testing variable entry constructor\n" << endl;
202 int NumMyNonzeros = 3 * NumMyEquations;
205 if(
A.LRID(NumGlobalEquations-1) >= 0)
209 MyGlobalElements, verbose),ierr);
211 for(i = 0; i < NumMyEquations; i++)
212 forierr += !(
A.NumGlobalIndices(MyGlobalElements[i])==NumNz[i]+1);
214 for(i = 0; i < NumMyEquations; i++)
215 forierr += !(
A.NumMyIndices(i)==NumNz[i]+1);
218 if(verbose) cout <<
"NumIndices function check OK" << endl;
224 if(verbose) cout <<
"\n*****Testing constant entry constructor\n" << endl;
230 for(i = 0; i < NumMyEquations; i++)
248 EPETRA_TEST_ERR(
check(AA, NumMyEquations, NumGlobalEquations, NumMyEquations, NumGlobalEquations,
249 MyGlobalElements, verbose),ierr);
254 for(i = 0; i < NumMyEquations; i++)
258 if(verbose) cout <<
"NumIndices function check OK" << endl;
262 if(verbose) cout <<
"\n*****Testing copy constructor\n" << endl;
268 MyGlobalElements, verbose),ierr);
271 for(i = 0; i < NumMyEquations; i++)
272 forierr += !(
B.NumGlobalIndices(MyGlobalElements[i])==1);
275 if(verbose) cout <<
"NumIndices function check OK" << endl;
279 if(verbose) cout <<
"\n*****Testing post construction modifications\n" << endl;
285 delete[] MyGlobalElements;
294 int NumMyElements1 = 4;
295 int NumMyEquations1 = NumMyElements1;
296 long long NumGlobalEquations1 = NumMyEquations1*NumProc;
301 long long* MyGlobalElements1 =
new long long[Map1.
NumMyElements()];
307 int* NumNz1 =
new int[NumMyEquations1];
312 for(i = 0; i < NumMyEquations1; i++)
313 if(MyGlobalElements1[i]==1 || MyGlobalElements1[i] == NumGlobalEquations1)
327 long long* Indices1 =
new long long[2];
331 for(i = 0; i < NumMyEquations1; i++) {
332 if(MyGlobalElements1[i]==1) {
336 else if(MyGlobalElements1[i] == NumGlobalEquations1) {
337 Indices1[0] = NumGlobalEquations1-1;
341 Indices1[0] = MyGlobalElements1[i]-1;
342 Indices1[1] = MyGlobalElements1[i]+1;
353 if(verbose) cout <<
"Print out tridiagonal matrix, each part on each processor. Index base is one.\n" << endl;
359 delete[] MyGlobalElements1;
367 if(verbose) cout <<
"\n*****Checking cpy ctr, op=, and reference counting." << endl;
370 if(verbose && (tempierr == 0)) cout <<
"Checked OK." << endl;
374 if(verbose) cout <<
"\n*****Checking shared-ownership tests." << endl;
377 if(verbose && (tempierr == 0)) cout <<
"Checked OK." << endl;
394 const int NumMyElements = 10;
395 const long long IndexBase = 0;
396 Epetra_Map Map1((
long long) -1, NumMyElements, IndexBase, Comm);
398 const int NumIndicesPerRow = 5;
404 array1[0] = NumIndicesPerRow / 2;
405 array1[1] = array1[0] + 1;
407 for(
int i = 0; i < NumIndicesPerRow; i++)
410 int soleOutput, sharedOutput;
413 if(verbose) cout <<
"InsertMyIndices..." << endl;
418 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
439 if(verbose) cout <<
"FillComplete..." << endl;
444 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
447 if(verbose) cout <<
"OptimizeStorage..." << endl;
452 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
455 if(verbose) cout <<
"RemoveMyIndices..." << endl;
460 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
463 if(verbose) cout <<
"RemoveMyIndices(#2)..." << endl;
468 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
471 if(verbose) cout <<
"FillComplete(#2)..." << endl;
476 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
485 long long GlobalRow = SoleOwnerG.
GRID64(0);
488 if(verbose) cout <<
"InsertGlobalIndices..." << endl;
493 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
496 if(verbose) cout <<
"RemoveGlobalIndices..." << endl;
501 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
504 if(verbose) cout <<
"RemoveGlobalIndices(#2)..." << endl;
509 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
527 const int NumIndicesPerRow = 10;
528 const long long NumGlobalElements = 50;
529 const long long IndexBase = 0;
530 Epetra_Map Map1(NumGlobalElements, IndexBase, Comm);
535 if(verbose) cout <<
"Graph1 created (def ctr). data addr = " << g1addr <<
" ref. count = " << g1count << endl;
544 if(verbose) cout <<
"Graph2 created (cpy ctr). data addr = " << g2addr <<
" ref. count = " << g2count << endl;
550 if(verbose) cout <<
"Graph2 destroyed. Graph1 data addr = " << g1newaddr <<
" ref. count = " << g1newcount << endl;
557 if(verbose) cout <<
"Graph3 created (op= before). data addr = " << g3addr <<
" ref. count = " << g3count << endl;
563 if(verbose) cout <<
"Graph3 set equal to Graph1 (op= after). data addr = " << g3addr <<
" ref. count = " << g3count << endl;
570 long long NumGlobalNonzeros1,
long long* MyGlobalElements,
bool verbose)
572 (void)MyGlobalElements;
577 int NumGlobalIndices;
580 int MaxNumIndices =
A.MaxNumIndices();
581 int* MyCopyIndices =
new int[MaxNumIndices];
582 long long* GlobalCopyIndices =
new long long[MaxNumIndices];
586 int NumMyRows =
A.NumMyRows();
587 if(verbose) cout <<
"Number of local Rows = " << NumMyRows << endl;
591 int NumMyNonzeros =
A.NumMyNonzeros();
592 if(verbose) cout <<
"Number of local Nonzero entries = " << NumMyNonzeros << endl;
596 long long NumGlobalRows =
A.NumGlobalRows64();
597 if(verbose) cout <<
"Number of global Rows = " << NumGlobalRows << endl;
601 long long NumGlobalNonzeros =
A.NumGlobalNonzeros64();
602 if(verbose) cout <<
"Number of global Nonzero entries = " << NumGlobalNonzeros << endl;
608 EPETRA_TEST_ERR(!(
A.ExtractGlobalRowView(
A.RowMap().MaxMyGID64(), NumGlobalIndices, GlobalCopyIndices)==-2),ierr);
624 for(i = 0; i < NumMyRows; i++) {
625 long long Row =
A.GRID64(i);
626 A.ExtractGlobalRowCopy(Row, MaxNumIndices, NumGlobalIndices, GlobalCopyIndices);
627 A.ExtractMyRowView(i, NumMyIndices, MyViewIndices);
628 forierr += !(NumGlobalIndices==NumMyIndices);
629 for(j = 1; j < NumMyIndices; j++)
EPETRA_TEST_ERR(!(MyViewIndices[j-1]<MyViewIndices[j]),ierr);
630 for(j = 0; j < NumGlobalIndices; j++) {
631 forierr += !(GlobalCopyIndices[j]==
A.GCID64(MyViewIndices[j]));
632 forierr += !(
A.LCID(GlobalCopyIndices[j])==MyViewIndices[j]);
637 for(i = 0; i < NumMyRows; i++) {
638 long long Row =
A.GRID64(i);
639 A.ExtractGlobalRowCopy(Row, MaxNumIndices, NumGlobalIndices, GlobalCopyIndices);
640 A.ExtractMyRowCopy(i, MaxNumIndices, NumMyIndices, MyCopyIndices);
641 forierr += !(NumGlobalIndices==NumMyIndices);
642 for(j = 1; j < NumMyIndices; j++)
644 for(j = 0; j < NumGlobalIndices; j++) {
645 forierr += !(GlobalCopyIndices[j]==
A.GCID64(MyCopyIndices[j]));
646 forierr += !(
A.LCID(GlobalCopyIndices[j])==MyCopyIndices[j]);
652 delete[] MyCopyIndices;
653 delete[] GlobalCopyIndices;
655 if(verbose) cout <<
"Rows sorted check OK" << endl;