54 #include "../epetra_test_err.h"
60 long long NumGlobalNonzeros1,
long long * MyGlobalElements,
bool verbose);
66 double * lambda,
int niters,
double tolerance,
71 int main(
int argc,
char *argv[])
73 int ierr = 0, forierr = 0;
80 MPI_Init(&argc,&argv);
83 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
96 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
98 int verbose_int = verbose ? 1 : 0;
100 verbose = verbose_int==1 ?
true :
false;
109 int MyPID = Comm.
MyPID();
112 if(verbose && MyPID==0)
115 if (verbose) cout <<
"Processor "<<MyPID<<
" of "<< NumProc
116 <<
" is alive."<<endl;
118 bool verbose1 = verbose;
121 if(verbose && rank!=0)
124 int NumMyEquations = 10000;
125 long long NumGlobalEquations = (NumMyEquations * NumProc) +
EPETRA_MIN(NumProc,3);
131 Epetra_Map Map(NumGlobalEquations, NumMyEquations, 0LL, Comm);
134 long long* MyGlobalElements =
new long long[Map.
NumMyElements()];
140 int* NumNz =
new int[NumMyEquations];
145 for (
int i = 0; i < NumMyEquations; i++)
146 if((MyGlobalElements[i] == 0) || (MyGlobalElements[i] == NumGlobalEquations - 1))
162 double* Values =
new double[2];
165 long long* Indices =
new long long[2];
170 for (
int i = 0; i < NumMyEquations; i++) {
171 if(MyGlobalElements[i] == 0) {
175 else if (MyGlobalElements[i] == NumGlobalEquations-1) {
176 Indices[0] = NumGlobalEquations-2;
180 Indices[0] = MyGlobalElements[i]-1;
181 Indices[1] = MyGlobalElements[i]+1;
184 forierr += !(A.
InsertGlobalValues(MyGlobalElements[i], NumEntries, Values, Indices)==0);
185 forierr += !(A.
InsertGlobalValues(MyGlobalElements[i], 1, &two, MyGlobalElements+i)>0);
189 int * indexOffsetTmp;
207 int NumMyNonzeros = 3 * NumMyEquations;
210 if(A.
LRID(NumGlobalEquations-1) >= 0)
212 EPETRA_TEST_ERR(
check(A, NumMyEquations, NumGlobalEquations, NumMyNonzeros, 3*NumGlobalEquations-2,
213 MyGlobalElements, verbose),ierr);
215 for (
int i = 0; i < NumMyEquations; i++)
219 for (
int i = 0; i < NumMyEquations; i++)
223 if (verbose) cout <<
"\n\nNumEntries function check OK" << std::endl<< std::endl;
237 double tolerance = 1.0e-1;
254 double MFLOPs = total_flops/elapsed_time/1000000.0;
256 if (verbose) cout <<
"\n\nTotal MFLOPs for first solve = " << MFLOPs << std::endl<< std::endl;
262 if (verbose) cout <<
"\n\nUsing transpose of matrix and solving again (should give same result).\n\n"
271 MFLOPs = total_flops/elapsed_time/1000000.0;
273 if (verbose) cout <<
"\n\nTotal MFLOPs for transpose solve = " << MFLOPs << std::endl<< endl;
279 if (verbose) cout <<
"\n\nIncreasing the magnitude of first diagonal term and solving again\n\n"
285 double * Rowvals =
new double [numvals];
286 long long * Rowinds =
new long long[numvals];
289 for (
int i=0; i<numvals; i++)
if (Rowinds[i] == 0) Rowvals[i] *= 10.0;
302 MFLOPs = total_flops/elapsed_time/1000000.0;
304 if (verbose) cout <<
"\n\nTotal MFLOPs for second solve = " << MFLOPs << endl<< endl;
310 if (verbose) cout <<
"\n\nUsing transpose of matrix and solving again (should give same result).\n\n"
320 MFLOPs = total_flops/elapsed_time/1000000.0;
323 if (verbose) cout <<
"\n\nTotal MFLOPs for tranpose of second solve = " << MFLOPs << endl<< endl;
325 if (verbose) cout <<
"\n\n*****Testing constant entry constructor" << endl<< endl;
331 double dble_one = 1.0;
332 for (
int i=0; i< NumMyEquations; i++) AA.
InsertGlobalValues(MyGlobalElements[i], 1, &dble_one, MyGlobalElements+i);
348 EPETRA_TEST_ERR(
check(AA, NumMyEquations, NumGlobalEquations, NumMyEquations, NumGlobalEquations,
349 MyGlobalElements, verbose),ierr);
354 for (
int i=0; i<NumMyEquations; i++) forierr += !(AA.
NumGlobalEntries(MyGlobalElements[i])==1);
357 if (verbose) cout <<
"\n\nNumEntries function check OK" << endl<< endl;
361 if (verbose) cout <<
"\n\n*****Testing copy constructor" << endl<< endl;
364 EPETRA_TEST_ERR(
check(B, NumMyEquations, NumGlobalEquations, NumMyEquations, NumGlobalEquations,
365 MyGlobalElements, verbose),ierr);
368 for (
int i=0; i<NumMyEquations; i++) forierr += !(B.
NumGlobalEntries(MyGlobalElements[i])==1);
371 if (verbose) cout <<
"\n\nNumEntries function check OK" << endl<< endl;
375 if (verbose) cout <<
"\n\n*****Testing local view constructor" << endl<< endl;
382 for (
int i = 0; i < NumMyEquations; i++) {
384 forierr += !(BV.InsertMyValues(i, NumEntries, Vals, Inds)==0);
387 EPETRA_TEST_ERR(
check(BV, NumMyEquations, NumGlobalEquations, NumMyEquations, NumGlobalEquations,
388 MyGlobalElements, verbose),ierr);
391 for (
int i=0; i<NumMyEquations; i++) forierr += !(BV.NumGlobalEntries(MyGlobalElements[i])==1);
394 if (verbose) cout <<
"\n\nNumEntries function check OK" << endl<< endl;
397 if (verbose) cout <<
"\n\n*****Testing post construction modifications" << endl<< endl;
406 delete [] MyGlobalElements;
413 int NumMyElements1 = 2;
414 int NumMyEquations1 = NumMyElements1;
415 int NumGlobalEquations1 = NumMyEquations1*NumProc;
417 Epetra_Map Map1((
long long)-1, NumMyElements1, 0LL, Comm);
420 long long* MyGlobalElements1 =
new long long[Map1.
NumMyElements()];
426 int * NumNz1 =
new int[NumMyEquations1];
431 for (
int i=0; i<NumMyEquations1; i++)
432 if (MyGlobalElements1[i]==0 || MyGlobalElements1[i] == NumGlobalEquations1-1)
446 double *Values1 =
new double[2];
447 Values1[0] = -1.0; Values1[1] = -1.0;
448 long long *Indices1 =
new long long[2];
453 for (
int i=0; i<NumMyEquations1; i++)
455 if (MyGlobalElements1[i]==0)
460 else if (MyGlobalElements1[i] == NumGlobalEquations1-1)
462 Indices1[0] = NumGlobalEquations1-2;
467 Indices1[0] = MyGlobalElements1[i]-1;
468 Indices1[1] = MyGlobalElements1[i]+1;
471 forierr += !(A1.
InsertGlobalValues(MyGlobalElements1[i], NumEntries1, Values1, Indices1)==0);
472 forierr += !(A1.
InsertGlobalValues(MyGlobalElements1[i], 1, &two1, MyGlobalElements1+i)>0);
487 for (
int i=0; i<NumMyEquations1; i++) forierr += !(checkDiag[i]==two1);
493 for (
int i=0; i<NumMyEquations1; i++) checkDiag[i]=two1*two1;
502 for (
int i=0; i<NumMyEquations1; i++) forierr += !(checkDiag[i]==checkDiag1[i]);
505 if (verbose) cout <<
"\n\nDiagonal extraction and replacement OK.\n\n" << endl;
507 double orignorm = A1.
NormOne();
511 if (verbose) cout <<
"\n\nMatrix scale OK.\n\n" << endl;
513 if (verbose) cout <<
"\n\nPrint out tridiagonal matrix, each part on each processor.\n\n" << endl;
519 delete [] MyGlobalElements1;
523 if (verbose) cout <<
"\n\n*****Testing LeftScale and RightScale" << endl << endl;
525 int NumMyElements2 = 7;
528 Epetra_Map RowMap((
long long)-1,NumMyRows2,0LL,Comm);
529 Epetra_Map ColMap((
long long)NumMyElements2,NumMyElements2,0LL,Comm);
532 Epetra_Map DomainMap((
long long)NumMyElements2,0LL,Comm);
533 int NumMyRangeElements2 = 0;
536 NumMyRangeElements2 = NumMyRows2*2;
537 if (NumProc % 2 == 1 && MyPID == NumProc-1)
538 NumMyRangeElements2 = NumMyRows2;
540 Epetra_Map RangeMap((
long long)-1,NumMyRangeElements2,0LL,Comm);
542 double * Values2 =
new double[NumMyElements2];
543 int * Indices2 =
new int[NumMyElements2];
545 for (
int i=0; i<NumMyElements2; i++) {
546 Values2[i] = i+MyPID;
554 double * RowLeftScaleValues =
new double[NumMyRows2];
555 double * ColRightScaleValues =
new double[NumMyElements2];
557 for (
long long i=0; i<RowLoopLength; i++)
558 RowLeftScaleValues[i] = (
double) ((i + RowMap.
MinMyGID64() ) % 2 + 1);
560 for (
int i=0; i<NumMyElements2;i++)
561 ColRightScaleValues[i] = i % 2 + 1;
564 double * RangeLeftScaleValues =
new double[(std::size_t) RangeLoopLength];
566 double * DomainRightScaleValues =
new double[(std::size_t) DomainLoopLength];
567 for (
long long i=0; i<RangeLoopLength; i++)
568 RangeLeftScaleValues[i] = 1.0/((i + RangeMap.
MinMyGID64() ) % 2 + 1);
569 for (
long long i=0; i<DomainLoopLength;i++)
570 DomainRightScaleValues[i] = 1.0/((i + DomainMap.
MinMyGID64() ) % 2 + 1);
577 double A2infNorm = A2.
NormInf();
578 double A2oneNorm = A2.
NormOne();
580 if (verbose1) cout << A2;
582 double A2infNorm1 = A2.NormInf();
583 double A2oneNorm1 = A2.NormOne();
584 bool ScalingBroke =
false;
585 if (A2infNorm1>2*A2infNorm||A2infNorm1<A2infNorm) {
589 if (A2oneNorm1>2*A2oneNorm||A2oneNorm1<A2oneNorm) {
594 if (verbose1) cout << A2;
596 double A2infNorm2 = A2.NormInf();
597 double A2oneNorm2 = A2.NormOne();
598 if (A2infNorm2>=2*A2infNorm1||A2infNorm2<=A2infNorm1) {
602 if (A2oneNorm2>2*A2oneNorm1||A2oneNorm2<=A2oneNorm1) {
606 if (verbose1) cout << A2;
608 double A2infNorm3 = A2.NormInf();
609 double A2oneNorm3 = A2.NormOne();
611 if (A2infNorm3!=A2infNorm1) {
615 if (A2oneNorm3!=A2oneNorm1) {
619 if (verbose1) cout << A2;
621 double A2infNorm4 = A2.NormInf();
622 double A2oneNorm4 = A2.NormOne();
624 if (A2infNorm4!=A2infNorm) {
628 if (A2oneNorm4!=A2oneNorm) {
640 int num_my_rows = A2.NumMyRows() ;
643 for (
int i=0 ; i< num_my_rows; i++ ) {
644 EPETRA_TEST_ERR( A2.ExtractMyRowView( i, num_entries, values ), ierr );
645 for (
int j = 0 ; j <num_entries; j++ ) {
652 A2.SumIntoGlobalValues((
long long) 0, 0, 0, 0 ) ;
654 double A2infNorm5 = A2.NormInf();
655 double A2oneNorm5 = A2.NormOne();
657 if (A2infNorm5!=2.0 * A2infNorm4) {
661 if (A2oneNorm5!= 2.0 * A2oneNorm4) {
669 for (
int i=0 ; i< num_my_rows; i++ ) {
670 EPETRA_TEST_ERR( A2.ExtractMyRowView( i, num_entries, values ), ierr );
671 for (
int j = 0 ; j <num_entries; j++ ) {
676 if (verbose1) cout << A2;
679 if (verbose) cout << endl <<
"LeftScale and RightScale tests FAILED" << endl << endl;
682 if (verbose) cout << endl <<
"LeftScale and RightScale tests PASSED" << endl << endl;
687 if (verbose) cout <<
"\n\n*****Testing InvRowMaxs and InvColMaxs" << endl << endl;
689 if (verbose1) cout << A2 << endl;
692 if (verbose1) cout << xRow << endl << xRange << endl;
694 if (verbose) cout <<
"\n\n*****Testing InvRowSums and InvColSums" << endl << endl;
695 bool InvSumsBroke =
false;
698 if (verbose1) cout << xRow;
700 float A2infNormFloat = A2.NormInf();
701 if (verbose1) cout << A2 << endl;
702 if (fabs(1.0-A2infNormFloat) > 1.e-5) {
708 int expectedcode = 1;
709 if (Comm.
NumProc()>1) expectedcode = 0;
711 if (verbose1) cout << xDomain << endl;
713 float A2oneNormFloat2 = A2.NormOne();
714 if (verbose1) cout << A2;
715 if (fabs(1.0-A2oneNormFloat2)>1.e-5) {
723 if (verbose1) cout << xRange;
725 float A2infNormFloat2 = A2.NormInf();
727 if (verbose1) cout << A2;
728 if (fabs(1.0-A2infNormFloat2)>1.e-5) {
729 cout <<
"InfNorm should be = 1, but InfNorm = " << A2infNormFloat2 << endl;
745 delete [] ColRightScaleValues;
746 delete [] DomainRightScaleValues;
747 if (verbose) cout <<
"Begin partial sum testing." << endl;
751 long long * myGlobalElements =
new long long[NumMyRows3];
752 for (
int i=0; i<NumMyRows3; i++) myGlobalElements[i] = MyPID+i;
753 Epetra_Map RowMap3((
long long)NumProc*2, NumMyRows3, myGlobalElements, 0LL, Comm);
754 int NumMyElements3 = 5;
756 double * Values3 =
new double[NumMyElements3];
757 long long * Indices3 =
new long long[NumMyElements3];
758 for (
int i=0; i < NumMyElements3; i++) {
759 Values3[i] = (int) (MyPID + (i+1));
762 for (
int i=0; i<NumMyRows3; i++) {
765 Epetra_Map RangeMap3((
long long)NumProc+1, 0LL, Comm);
766 Epetra_Map DomainMap3((
long long)NumMyElements3, 0LL, Comm);
768 if (verbose1) cout << A3;
774 if (verbose1) cout << xRange3;
776 float A3infNormFloat = A3.NormInf();
777 if (verbose1) cout << A3;
778 if (1.0!=A3infNormFloat) {
779 cout <<
"InfNorm should be = 1, but InfNorm = " << A3infNormFloat <<endl;
784 int NumMyColumns3 = NumMyRows3;
789 double *Values3cm =
new double[NumMyColumns3];
790 long long * Indices3cm =
new long long[NumMyColumns3];
791 for (
int i=0; i<NumMyColumns3; i++) {
792 Values3cm[i] = MyPID + i + 1;
793 Indices3cm[i]= i + MyPID;
795 for (
int ii=0; ii<NumMyElements3; ii++) {
796 A3cm.InsertGlobalValues(ii, NumMyColumns3, Values3cm, Indices3cm);
806 if (verbose1) cout << A3cm << endl;
814 if (verbose1) cout << xDomain3cm << endl;
817 float A3cmOneNormFloat = A3cm.NormOne();
818 if (verbose1) cout << A3cm << endl;
819 if (1.0!=A3cmOneNormFloat) {
820 cout <<
"OneNorm should be = 1, but OneNorm = " << A3cmOneNormFloat << endl;
825 if (verbose) cout <<
"End partial sum testing" << endl;
826 if (verbose) cout <<
"Begin replicated testing" << endl;
833 for (
int ii=0; ii < NumMyElements3; ii++) {
834 Values3[ii] = (int)((ii*.6)+1.0);
836 for (
int ii=0; ii<NumMyRows3; ii++) {
840 if (verbose1) cout << A4 << endl;
844 if (verbose1) cout << xRow3 << xRange3;
847 if (verbose1) cout << xRow3;
849 float A4infNormFloat = A4.
NormInf();
850 if (verbose1) cout << A4;
851 if (2.0!=A4infNormFloat && NumProc != 1) {
852 if (verbose1) cout <<
"InfNorm should be = 2 (because one column is replicated on two processors and NormOne() does not handle replication), but InfNorm = " << A4infNormFloat <<endl;
856 else if (1.0!=A4infNormFloat && NumProc == 1) {
857 if (verbose1) cout <<
"InfNorm should be = 1, but InfNorm = " << A4infNormFloat <<endl;
865 for (
int ii=0; ii<NumMyElements3; ii++) {
869 if (verbose1) cout << A4cm << endl;
873 if (verbose1) cout << xCol3cm << xDomain3cm;
877 if (verbose1) cout << xCol3cm << endl;
879 float A4cmOneNormFloat = A4cm.
NormOne();
880 if (verbose1) cout << A4cm << endl;
881 if (2.0!=A4cmOneNormFloat && NumProc != 1) {
882 if (verbose1) cout <<
"OneNorm should be = 2 (because one column is replicated on two processors and NormOne() does not handle replication), but OneNorm = " << A4cmOneNormFloat << endl;
886 else if (1.0!=A4cmOneNormFloat && NumProc == 1) {
887 if (verbose1) cout <<
"OneNorm should be = 1, but OneNorm = " << A4infNormFloat <<endl;
892 if (verbose) cout <<
"End replicated testing" << endl;
895 if (verbose) cout << endl <<
"InvRowSums tests FAILED" << endl << endl;
898 if (verbose) cout << endl <<
"InvRowSums tests PASSED" << endl << endl;
901 long long nnz_A3cm = A3cm.Graph().NumGlobalNonzeros64();
902 double check_frobnorm = sqrt(nnz_A3cm*4.0);
903 double frobnorm = A3cm.NormFrobenius();
905 bool frobnorm_test_failed =
false;
906 if (fabs(check_frobnorm-frobnorm) > 5.e-5) {
907 frobnorm_test_failed =
true;
910 if (frobnorm_test_failed) {
911 if (verbose) std::cout <<
"Frobenius-norm test FAILED."<<std::endl;
918 int NumMyRows = (MyPID==0) ? NumGlobalEquations : 0;
919 Epetra_Map Map1((
long long) -1,NumMyRows, (
long long) 0, Comm);
923 for(
int i=0; i<NumMyRows; i++) {
924 long long GID = Map1.
GID64(i);
932 if (verbose) std::cout <<
"Subcommunicator test FAILED."<<std::endl;
944 delete [] myGlobalElements;
948 delete [] Indices3cm;
949 delete [] RangeLeftScaleValues;
950 delete [] RowLeftScaleValues;
961 Epetra_Vector& resid,
double* lambda,
int niters,
double tolerance,
bool verbose)
968 double normz, residual;
972 for(
int iter = 0; iter < niters; iter++) {
974 q.
Scale(1.0/normz, z);
977 if(iter%100==0 || iter+1==niters) {
978 resid.
Update(1.0, z, -(*lambda), q, 0.0);
979 resid.
Norm2(&residual);
980 if(verbose) cout <<
"Iter = " << iter <<
" Lambda = " << *lambda
981 <<
" Residual of A*q - lambda*q = " << residual << endl;
983 if(residual < tolerance) {
992 long long NumGlobalNonzeros1,
long long* MyGlobalElements,
bool verbose)
994 (void)MyGlobalElements;
995 int ierr = 0, forierr = 0;
996 int NumGlobalIndices;
998 int* MyViewIndices = 0;
999 long long* GlobalViewIndices = 0;
1000 double* MyViewValues = 0;
1001 double* GlobalViewValues = 0;
1003 int* MyCopyIndices =
new int[MaxNumIndices];
1004 long long* GlobalCopyIndices =
new long long[MaxNumIndices];
1005 double* MyCopyValues =
new double[MaxNumIndices];
1006 double* GlobalCopyValues =
new double[MaxNumIndices];
1011 if (verbose) cout <<
"\n\nNumber of local Rows = " << NumMyRows << endl<< endl;
1016 if (verbose) cout <<
"\n\nNumber of local Nonzero entries = " << NumMyNonzeros << endl<< endl;
1021 if (verbose) cout <<
"\n\nNumber of global Rows = " << NumGlobalRows << endl<< endl;
1026 if (verbose) cout <<
"\n\nNumber of global Nonzero entries = " << NumGlobalNonzeros << endl<< endl;
1048 for (
int i = 0; i < NumMyRows; i++) {
1049 long long Row = A.
GRID64(i);
1050 A.
ExtractGlobalRowCopy(Row, MaxNumIndices, NumGlobalIndices, GlobalCopyValues, GlobalCopyIndices);
1052 forierr += !(NumGlobalIndices == NumMyIndices);
1053 for(
int j = 1; j < NumMyIndices; j++) {
1054 forierr += !(MyViewIndices[j-1] < MyViewIndices[j]);
1056 for(
int j = 0; j < NumGlobalIndices; j++) {
1057 forierr += !(GlobalCopyIndices[j] == A.
GCID64(MyViewIndices[j]));
1058 forierr += !(A.
LCID(GlobalCopyIndices[j]) == MyViewIndices[j]);
1059 forierr += !(GlobalCopyValues[j] == MyViewValues[j]);
1065 for (
int i = 0; i < NumMyRows; i++) {
1066 long long Row = A.
GRID64(i);
1067 A.
ExtractGlobalRowCopy(Row, MaxNumIndices, NumGlobalIndices, GlobalCopyValues, GlobalCopyIndices);
1068 A.
ExtractMyRowCopy(i, MaxNumIndices, NumMyIndices, MyCopyValues, MyCopyIndices);
1069 forierr += !(NumGlobalIndices == NumMyIndices);
1070 for (
int j = 1; j < NumMyIndices; j++)
1071 forierr += !(MyCopyIndices[j-1] < MyCopyIndices[j]);
1072 for (
int j = 0; j < NumGlobalIndices; j++) {
1073 forierr += !(GlobalCopyIndices[j] == A.
GCID64(MyCopyIndices[j]));
1074 forierr += !(A.
LCID(GlobalCopyIndices[j]) == MyCopyIndices[j]);
1075 forierr += !(GlobalCopyValues[j] == MyCopyValues[j]);
1081 delete [] MyCopyIndices;
1082 delete [] GlobalCopyIndices;
1083 delete [] MyCopyValues;
1084 delete [] GlobalCopyValues;
1086 if (verbose) cout <<
"\n\nRows sorted check OK" << endl<< endl;
1093 int numLocalElems = 5;
1094 int localProc = Comm.
MyPID();
1095 long long firstElem = localProc*numLocalElems;
1097 Epetra_Map map((
long long)-1, numLocalElems, 0LL, Comm);
1101 for (
int i=0; i<numLocalElems; ++i) {
1102 long long row = firstElem+i;
1103 long long col = row;
1108 cerr <<
"A->InsertGlobalValues("<<row<<
") returned err="<<err<<endl;
1119 for (
int i=0; i<numLocalElems; ++i) {
1120 long long row = firstElem+i;
1121 long long col = row;
1124 err =
B.ReplaceGlobalValues(row, 1, &val, &col);
1126 cerr <<
"B.ReplaceGlobalValues("<<row<<
") returned err="<<err<<endl;
long long MinMyGID64() const
void SetFlopCounter(const Epetra_Flops &FlopCounter_in)
Set the internal Epetra_Flops() pointer.
int LRID(int GRID_in) const
Returns the local row index for given global row index, returns -1 if no local row for this global ro...
int ReplaceDiagonalValues(const Epetra_Vector &Diagonal)
Replaces diagonal values of the matrix with those in the user-provided vector.
bool MyGlobalRow(int GID) const
Returns true of GID is owned by the calling processor, otherwise it returns false.
bool MyGRID(int GRID_in) const
Returns true if the GRID passed in belongs to the calling processor in this map, otherwise returns fa...
Epetra_Map: A class for partitioning vectors and matrices.
int NumGlobalEntries(long long Row) const
Returns the current number of nonzero entries in specified global row on this processor.
int Random()
Set multi-vector values to random numbers.
bool StorageOptimized() const
If OptimizeStorage() has been called, this query returns true, otherwise it returns false...
long long NumGlobalRows64() const
int NumMyEntries(int Row) const
Returns the current number of nonzero entries in specified local row on this processor.
int ExtractDiagonalCopy(Epetra_Vector &Diagonal) const
Returns a copy of the main diagonal in a user-provided vector.
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.
#define EPETRA_TEST_ERR(a, b)
int MyGlobalElements(int *MyGlobalElementList) const
Puts list of global elements on this processor into the user-provided array.
double ElapsedTime(void) const
Epetra_Time elapsed time function.
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.
double NormInf() const
Returns the infinity norm of the global matrix.
long long GRID64(int LRID_in) const
static void SetTracebackMode(int TracebackModeValue)
Set the value of the Epetra_Object error traceback report mode.
int power_method(Epetra_CrsMatrix &A, double &lambda, int niters, double tolerance, bool verbose)
double NormOne() const
Returns the one norm of the global 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.
const Epetra_Map & ColMap() const
Returns the Epetra_Map object that describes the set of column-indices that appear in each processor'...
std::string Epetra_Version()
bool IndicesAreLocal() const
If matrix indices has been transformed to local, this query returns true, otherwise it returns false...
int check(Epetra_CrsGraph &A, int NumMyRows1, int NumGlobalRows1, int NumMyNonzeros1, int NumGlobalNonzeros1, int *MyGlobalElements, bool verbose)
bool UpperTriangular() const
If matrix is upper triangular in local index space, this query returns true, otherwise it returns fal...
int InvColSums(Epetra_Vector &x) const
Computes the inverse of the sum of absolute values of the columns of the Epetra_CrsMatrix, results returned in x.
virtual int MyPID() const =0
Return my process ID.
int FillComplete(bool OptimizeDataStorage=true)
Signal that data entry is complete. Perform transformations to local index space. ...
Epetra_Time: The Epetra Timing Class.
int Dot(const Epetra_MultiVector &A, double *Result) const
Computes dot product of each corresponding pair of vectors.
bool MyLRID(int LRID_in) const
Returns true if the LRID passed in belongs to the calling processor in this map, otherwise returns fa...
int ExtractMyRowView(int MyRow, int &NumEntries, double *&Values, int *&Indices) const
Returns a view of the specified local row values via pointers to internal data.
long long NumGlobalNonzeros64() const
const Epetra_Map & RowMap() const
Returns the Epetra_Map object associated with the rows of this matrix.
int NumMyElements() const
Number of elements on the calling processor.
long long GID64(int LID) const
int Scale(double ScalarValue)
Scale the current values of a multi-vector, this = ScalarValue*this.
Epetra_Map * RemoveEmptyProcesses() const
Return a new BlockMap with processes with zero elements removed.
Epetra_Comm: The Epetra Communication Abstract Base Class.
int ExtractGlobalRowView(int GlobalRow, int &NumEntries, double *&Values, int *&Indices) const
Returns a view of the specified global row values via pointers to internal data.
int ExtractGlobalRowCopy(int GlobalRow, int Length, int &NumEntries, double *Values, int *Indices) const
Returns a copy of the specified global row in user-provided arrays.
int OptimizeStorage()
Make consecutive row index sections contiguous, minimize internal storage used for constructing graph...
bool NoDiagonal() const
If matrix has no diagonal entries in global index space, this query returns true, otherwise it return...
int NumMyRows() const
Returns the number of matrix rows owned by the calling processor.
int LCID(int GCID_in) const
Returns the local column index for given global column index, returns -1 if no local column for this ...
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
int RemoveEmptyProcessesInPlace(const Epetra_BlockMap *NewMap)
Remove processes owning zero rows from the Maps and their communicator.
int InvRowSums(Epetra_Vector &x) const
Computes the inverse of the sum of absolute values of the rows of the Epetra_CrsMatrix, results returned in x.
bool LowerTriangular() const
If matrix is lower triangular in local index space, this query returns true, otherwise it returns fal...
int NumProc() const
Returns total number of processes (always returns 1 for SerialComm).
int LeftScale(const Epetra_Vector &x)
Scales the Epetra_CrsMatrix on the left with a Epetra_Vector x.
Epetra_SerialComm: The Epetra Serial Communication Class.
void ResetFlops()
Resets the number of floating point operations to zero for this multi-vector.
bool IndicesAreGlobal() const
If matrix indices has not been transformed to local, this query returns true, otherwise it returns fa...
Epetra_Flops: The Epetra Floating Point Operations Class.
int InvRowMaxs(Epetra_Vector &x) const
Computes the inverse of the max of absolute values of the rows of the Epetra_CrsMatrix, results returned in x.
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
Update multi-vector values with scaled values of A, this = ScalarThis*this + ScalarA*A.
int check_graph_sharing(Epetra_Comm &Comm)
void Barrier() const
Epetra_SerialComm Barrier function.
int InvColMaxs(Epetra_Vector &x) const
Computes the max of absolute values of the columns of the Epetra_CrsMatrix, results returned in x...
bool Filled() const
If FillComplete() has been called, this query returns true, otherwise it returns false.
Epetra_CrsMatrix: A class for constructing and using real-valued double-precision sparse compressed r...
int Norm2(double *Result) const
Compute 2-norm of each vector in multi-vector.
double Flops() const
Returns the number of floating point operations with this multi-vector.
int MaxNumIndices() const
Returns the maximum number of nonzero entries across all rows on this processor.
int main(int argc, char *argv[])
int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const
Returns a copy of the specified local row in user-provided arrays.
const Epetra_CrsGraph & Graph() const
Returns a reference to the Epetra_CrsGraph object associated with this matrix.
int Broadcast(double *MyVals, int Count, int Root) const
Epetra_SerialComm Broadcast function.
int Scale(double ScalarConstant)
Multiply all values in the matrix by a constant value (in place: A <- ScalarConstant * A)...
int InsertMyValues(int MyRow, int NumEntries, const double *Values, const int *Indices)
Insert a list of elements in a given local row of the matrix.
void ResetStartTime(void)
Epetra_Time function to reset the start time for a timer object.
int RightScale(const Epetra_Vector &x)
Scales the Epetra_CrsMatrix on the right with a Epetra_Vector x.
virtual int ReplaceGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Replace specified existing values with this list of entries for a given global row of the matrix...
long long GCID64(int LCID_in) const
long long MaxMyGID64() const
Epetra_CrsGraph: A class for constructing and using sparse compressed row graphs. ...
int ExtractCrsDataPointers(int *&IndexOffset, int *&Indices, double *&Values_in) const
Returns internal data pointers associated with Crs matrix format.
int NumMyNonzeros() const
Returns the number of nonzero entries in the calling processor's portion of the matrix.