Epetra Package Browser (Single Doxygen Collection)  Development
test/FusedImportExport/cxx_main.cpp
Go to the documentation of this file.
1 //@HEADER
2 // ************************************************************************
3 //
4 // Epetra: Linear Algebra Services Package
5 // Copyright 2011 Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ************************************************************************
40 //@HEADER
41 
42 
43 #include "Epetra_Map.h"
44 #include "Epetra_Time.h"
45 #include "Epetra_CrsMatrix.h"
46 #include "Epetra_Import.h"
47 #include "Epetra_Export.h"
48 #include "Epetra_Vector.h"
49 #include "Epetra_Flops.h"
50 
51 #ifdef EPETRA_MPI
52 
53 #include "Epetra_MpiComm.h"
54 #include "mpi.h"
55 #include "../epetra_test_err.h"
56 #include "Epetra_Version.h"
57 
58 // prototypes
59 
60 int check(Epetra_CrsMatrix& A, int NumMyRows1, int NumGlobalRows1, int NumMyNonzeros1,
61  int NumGlobalNonzeros1, int * MyGlobalElements, bool verbose);
62 
63 int power_method(bool TransA, Epetra_CrsMatrix& A,
64  Epetra_Vector& q,
65  Epetra_Vector& z,
66  Epetra_Vector& resid,
67  double * lambda, int niters, double tolerance,
68  bool verbose);
69 
71 
72 
74  const Epetra_Map & Xamap = A.DomainMap();
75  const Epetra_Map & Yamap = A.RangeMap();
76  const Epetra_Map & Xbmap = B.DomainMap();
77  const Epetra_Map & Ybmap = B.RangeMap();
78 
79  Epetra_Vector Xa(Xamap), Xb(Xbmap), Ya(Yamap), Yb(Ybmap), Diff(Yamap);
80 
81  Xa.SetSeed(24601);
82  Xa.Random();
83 
84  // Handle domain map change
85  if(!Xamap.SameAs(Xbmap)) {
86  Epetra_Import Ximport(Xbmap,Xamap);
87  Xb.Import(Xa,Ximport,Insert);
88  }
89  else {
90  Xb=Xa;
91  }
92 
93  // Do the multiplies
94  A.Apply(Xa,Ya);
95  B.Apply(Xb,Yb);
96 
97  // Handle Rangemap change
98  if(!Yamap.SameAs(Ybmap)) {
99  Epetra_Import Yimport(Yamap,Ybmap);
100  Diff.Import(Yb,Yimport,Insert);
101  }
102  else {
103  Diff=Yb;
104  }
105 
106  // Check solution
107  Diff.Update(-1.0,Ya,1.0);
108  double norm;
109  Diff.Norm2(&norm);
110 
111  return norm;
112 }
113 
114 
115 // B here is the "reduced" matrix. Square matrices w/ Row=Domain=Range only.
117  const Epetra_Map & Amap = A.DomainMap();
118  Epetra_Vector Xa(Amap), Ya(Amap), Diff(Amap);
119  const Epetra_Map *Bmap = Bfullmap.NumMyElements() > 0 ? &B.DomainMap() : 0;
120  Epetra_Vector *Xb = Bmap ? new Epetra_Vector(*Bmap) : 0;
121  Epetra_Vector *Yb = Bmap ? new Epetra_Vector(*Bmap) : 0;
122 
123  Epetra_Vector Xb_alias(View,Bfullmap, Bmap ? Xb->Values(): 0);
124  Epetra_Vector Yb_alias(View,Bfullmap, Bmap ? Yb->Values(): 0);
125 
126  Epetra_Import Ximport(Bfullmap,Amap);
127 
128  // Set the input vector
129  Xa.SetSeed(24601);
130  Xa.Random();
131  Xb_alias.Import(Xa,Ximport,Insert);
132 
133  // Do the multiplies
134  A.Apply(Xa,Ya);
135  if(Bmap) B.Apply(*Xb,*Yb);
136 
137  // Check solution
138  Epetra_Import Yimport(Amap,Bfullmap);
139  Diff.Import(Yb_alias,Yimport,Insert);
140 
141 
142  Diff.Update(-1.0,Ya,1.0);
143  double norm;
144  Diff.Norm2(&norm);
145 
146  delete Xb; delete Yb;
147  return norm;
148 }
149 
150 
151 
152 int build_matrix_unfused(const Epetra_CrsMatrix & SourceMatrix, Epetra_Import & RowImporter, Epetra_CrsMatrix *&A){
153  int rv=0;
154  rv=A->Import(SourceMatrix, RowImporter, Insert);
155  if(rv) {cerr<<"build_matrix_unfused: Import failed"<<endl; return rv;}
156 
157  rv=A->FillComplete(SourceMatrix.DomainMap(), SourceMatrix.RangeMap());
158  return rv;
159 }
160 
161 int build_matrix_unfused(const Epetra_CrsMatrix & SourceMatrix, Epetra_Export & RowExporter, Epetra_CrsMatrix *&A){
162  int rv=0;
163  rv=A->Export(SourceMatrix, RowExporter, Insert);
164  if(rv) {cerr<<"build_matrix_unfused: Export failed"<<endl; return rv;}
165 
166  rv=A->FillComplete(SourceMatrix.DomainMap(), SourceMatrix.RangeMap());
167  return rv;
168 }
169 
170 
171 
172 void build_test_matrix(Epetra_MpiComm & Comm, int test_number, Epetra_CrsMatrix *&A){
173  int NumProc = Comm.NumProc();
174  int MyPID = Comm.MyPID();
175 
176  if(test_number==1){
177  // Case 1: Tridiagonal
178  int NumMyEquations = 100;
179 
180  int NumGlobalEquations = (NumMyEquations * NumProc) + EPETRA_MIN(NumProc,3);
181  if(MyPID < 3) NumMyEquations++;
182 
183  // Construct a Map that puts approximately the same Number of equations on each processor
184  Epetra_Map Map(NumGlobalEquations, NumMyEquations, 0, Comm);
185 
186  // Get update list and number of local equations from newly created Map
187  int* MyGlobalElements = new int[Map.NumMyElements()];
188  Map.MyGlobalElements(MyGlobalElements);
189 
190  // Create an integer vector NumNz that is used to build the Petra Matrix.
191  // NumNz[i] is the Number of OFF-DIAGONAL term for the ith global equation on this processor
192 
193  int* NumNz = new int[NumMyEquations];
194 
195  // We are building a tridiagonal matrix where each row has (-1 2 -1)
196  // So we need 2 off-diagonal terms (except for the first and last equation)
197 
198  for (int i = 0; i < NumMyEquations; i++)
199  if((MyGlobalElements[i] == 0) || (MyGlobalElements[i] == NumGlobalEquations - 1))
200  NumNz[i] = 1;
201  else
202  NumNz[i] = 2;
203 
204  // Create a Epetra_Matrix
205  A=new Epetra_CrsMatrix(Copy, Map, NumNz);
206 
207  // Add rows one-at-a-time
208  // Need some vectors to help
209  // Off diagonal Values will always be -1
210 
211  double* Values = new double[2];
212  Values[0] = -1.0;
213  Values[1] = -1.0;
214  int* Indices = new int[2];
215  double two = 2.0;
216  int NumEntries;
217 
218  for (int i = 0; i < NumMyEquations; i++) {
219  if(MyGlobalElements[i] == 0) {
220  Indices[0] = 1;
221  NumEntries = 1;
222  }
223  else if (MyGlobalElements[i] == NumGlobalEquations-1) {
224  Indices[0] = NumGlobalEquations-2;
225  NumEntries = 1;
226  }
227  else {
228  Indices[0] = MyGlobalElements[i]-1;
229  Indices[1] = MyGlobalElements[i]+1;
230  NumEntries = 2;
231  }
232  A->InsertGlobalValues(MyGlobalElements[i], NumEntries, Values, Indices);
233  A->InsertGlobalValues(MyGlobalElements[i], 1, &two, MyGlobalElements+i);
234  }
235 
236  A->FillComplete();
237 
238  // Cleanup
239  delete [] MyGlobalElements;
240  delete [] NumNz;
241  delete [] Values;
242  delete [] Indices;
243 
244  }
245 }
246 
247 
248 void build_test_map(const Epetra_Map & oldMap, Epetra_Map *& newMap) {
249  int NumProc = oldMap.Comm().NumProc();
250  int MyPID = oldMap.Comm().MyPID();
251 
252  int num_global = oldMap.NumGlobalElements();
253  if(NumProc<3) {
254  // Dump everything onto -proc 0
255  int num_local = MyPID==0 ? num_global : 0;
256  newMap = new Epetra_Map(num_global,num_local,0,oldMap.Comm());
257  }
258  else {
259  // Split everything between procs 0 and 2 (leave proc 1 empty)
260  int num_local=0;
261  if(MyPID==0) num_local = num_global/2;
262  else if(MyPID==2) num_local = num_global - ((int)num_global/2);
263  newMap = new Epetra_Map(num_global,num_local,0,oldMap.Comm());
264  }
265 }
266 
267 
268 int main(int argc, char *argv[])
269 {
270  int total_err=0;
271 
272  // Initialize MPI
273 
274  MPI_Init(&argc,&argv);
275  int rank; // My process ID
276 
277  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
278  Epetra_MpiComm Comm( MPI_COMM_WORLD );
279 
280  bool verbose = false;
281 
282  // Check if we should print results to standard out
283  if (argc>1) if (argv[1][0]=='-' && argv[1][1]=='v') verbose = true;
284 
285  int verbose_int = verbose ? 1 : 0;
286  Comm.Broadcast(&verbose_int, 1, 0);
287  verbose = verbose_int==1 ? true : false;
288 
289  Comm.SetTracebackMode(0); // This should shut down any error traceback reporting
290  int MyPID = Comm.MyPID();
291  int NumProc = Comm.NumProc();
292 
293  if(verbose && MyPID==0)
294  cout << Epetra_Version() << std::endl << std::endl;
295 
296  if (verbose) cout << "Processor "<<MyPID<<" of "<< NumProc
297  << " is alive."<<endl;
298 
299  // Redefine verbose to only print on PE 0
300  if(verbose && rank!=0) verbose = false;
301 
302  // Matrix & Map pointers
303  Epetra_CrsMatrix *A, *B, *C;
304  Epetra_Map* Map1;
305  Epetra_Import* Import1;
306  Epetra_Export* Export1;
307  double diff_tol=1e-12;
308 
309 #define ENABLE_TEST_1
310 #define ENABLE_TEST_2
311 #define ENABLE_TEST_3
312 #define ENABLE_TEST_4
313 #define ENABLE_TEST_5
314 #define ENABLE_TEST_6
315 
317  // Test #1: Tridiagonal Matrix; Migrate to Proc 0
319 #ifdef ENABLE_TEST_1
320  {
321  double diff;
322  build_test_matrix(Comm,1,A);
323  int num_global = A->RowMap().NumGlobalElements();
324 
325  // New map with all on Proc1
326  if(MyPID==0) Map1=new Epetra_Map(num_global,num_global,0,Comm);
327  else Map1=new Epetra_Map(num_global,0,0,Comm);
328 
329  // Execute fused import constructor
330  Import1 = new Epetra_Import(*Map1,A->RowMap());
331  B=new Epetra_CrsMatrix(*A,*Import1,0,&A->RangeMap());
332 
333  diff=test_with_matvec(*A,*B);
334  if(diff > diff_tol){
335  if(MyPID==0) cout<<"FusedImport: Test #1 FAILED with norm diff = "<<diff<<"."<<endl;
336  total_err--;
337  }
338 
339  // Execute fused export constructor
340  delete B;
341  Export1 = new Epetra_Export(A->RowMap(),*Map1);
342  B=new Epetra_CrsMatrix(*A,*Export1,0,&A->RangeMap());
343 
344  diff=test_with_matvec(*A,*B);
345  if(diff > diff_tol){
346  if(MyPID==0) cout<<"FusedExport: Test #1 FAILED with norm diff = "<<diff<<"."<<endl;
347  total_err--;
348  }
349 
350  delete A; delete B; delete Map1; delete Import1; delete Export1;
351  }
352 #endif
353 
354 
356  // Test #2: Tridiagonal Matrix; Locally Reversed Map
358 #ifdef ENABLE_TEST_2
359  {
360  double diff;
361  build_test_matrix(Comm,1,A);
362  int num_local = A->RowMap().NumMyElements();
363 
364  std::vector<int> MyGIDS(num_local);
365  for(int i=0; i<num_local; i++)
366  MyGIDS[i] = A->RowMap().GID(num_local-i-1);
367 
368  // New map with all on Proc1
369  Map1=new Epetra_Map(-1,num_local,&MyGIDS[0],0,Comm);
370 
371  // Execute fused import constructor
372  Import1 = new Epetra_Import(*Map1,A->RowMap());
373  B=new Epetra_CrsMatrix(*A,*Import1,0,&A->RangeMap());
374 
375  diff=test_with_matvec(*A,*B);
376  if(diff > diff_tol){
377  if(MyPID==0) cout<<"FusedImport: Test #2 FAILED with norm diff = "<<diff<<"."<<endl;
378  total_err--;
379  }
380 
381  // Execute fused export constructor
382  delete B;
383  Export1 = new Epetra_Export(A->RowMap(),*Map1);
384  B=new Epetra_CrsMatrix(*A,*Export1,0,&A->RangeMap());
385 
386  diff=test_with_matvec(*A,*B);
387  if(diff > diff_tol){
388  if(MyPID==0) cout<<"FusedExport: Test #2 FAILED with norm diff = "<<diff<<"."<<endl;
389  total_err--;
390  }
391 
392  delete A; delete B; delete Map1; delete Import1; delete Export1;
393  }
394 #endif
395 
397  // Test #3: Tridiagonal Matrix; Globally Reversed Map
399 #ifdef ENABLE_TEST_3
400  {
401  double diff;
402  build_test_matrix(Comm,1,A);
403  int num_local = A->RowMap().NumMyElements();
404  int num_global = A->RowMap().NumGlobalElements();
405  int num_scansum = 0;
406 
407  Comm.ScanSum(&num_local,&num_scansum,1);
408 
409  // New Map
410  std::vector<int> MyGIDS(num_local);
411  for(int i=0; i<num_local; i++)
412  MyGIDS[i] = num_global - num_scansum + num_local - i - 1;
413  Map1=new Epetra_Map(-1,num_local,&MyGIDS[0],0,Comm);
414 
415 
416  // Execute fused import constructor
417  Import1 = new Epetra_Import(*Map1,A->RowMap());
418  B=new Epetra_CrsMatrix(*A,*Import1,0,&A->RangeMap());
419 
420  diff=test_with_matvec(*A,*B);
421  if(diff > diff_tol){
422  if(MyPID==0) cout<<"FusedImport: Test #3 FAILED with norm diff = "<<diff<<"."<<endl;
423  total_err--;
424  }
425 
426  // Execute fused export constructor
427  delete B;
428  Export1 = new Epetra_Export(A->RowMap(),*Map1);
429  B=new Epetra_CrsMatrix(*A,*Export1,0,&A->RangeMap());
430 
431  diff=test_with_matvec(*A,*B);
432  if(diff > diff_tol){
433  if(MyPID==0) cout<<"FusedExport: Test #3 FAILED with norm diff = "<<diff<<"."<<endl;
434  total_err--;
435  }
436 
437  delete A; delete B; delete Map1; delete Import1; delete Export1;
438  }
439 #endif
440 
441 
443  // Test #4: Tridiagonal Matrix; MMM style halo import
445 #ifdef ENABLE_TEST_4
446  {
447  double diff;
448  build_test_matrix(Comm,1,A);
449 
450  // Assume we always own the diagonal
451  int num_local = A->NumMyCols()-A->NumMyRows();
452  std::vector<int> MyGIDS(num_local);
453 
454  for(int i=0, idx=0; i<A->NumMyCols(); i++)
455  if(A->LRID(A->GCID(i)) == -1){
456  MyGIDS[idx] = A->GCID(i);
457  idx++;
458  }
459 
460  // New map
461  const int * MyGIDS_ptr = MyGIDS.size() ? &MyGIDS[0] : 0;
462  Map1=new Epetra_Map(-1,num_local,MyGIDS_ptr,0,Comm);
463 
464 
465  // Execute fused import constructor
466  Import1 = new Epetra_Import(*Map1,A->RowMap());
467  B=new Epetra_CrsMatrix(*A,*Import1,0,&A->RangeMap());
468 
469  // Build unfused matrix to compare
470  C=new Epetra_CrsMatrix(Copy,*Map1,0);
471  build_matrix_unfused(*A,*Import1,C);
472 
473  diff=test_with_matvec(*B,*C);
474  if(diff > diff_tol){
475  if(MyPID==0) cout<<"FusedImport: Test #4 FAILED with norm diff = "<<diff<<"."<<endl;
476  total_err--;
477  }
478 
479  // Execute fused export constructor
480  delete B;
481  Export1 = new Epetra_Export(A->RowMap(),*Map1);
482  B=new Epetra_CrsMatrix(*A,*Export1,0,&A->RangeMap());
483 
484  diff=test_with_matvec(*B,*C);
485  if(diff > diff_tol){
486  if(MyPID==0) cout<<"FusedExport: Test #4 FAILED with norm diff = "<<diff<<"."<<endl;
487  total_err--;
488  }
489 
490  delete A; delete B; delete C; delete Map1; delete Import1; delete Export1;
491  }
492 #endif
493 
494 
496  // Test 5: Tridiagonal Matrix; Migrate to Proc 0, Replace Maps
498 #ifdef ENABLE_TEST_5
499  {
500  double diff;
501  build_test_matrix(Comm,1,A);
502 
503  // New map with all on Procs 0 and 2
504  build_test_map(A->RowMap(),Map1);
505 
506  // Execute fused import constructor
507  Import1 = new Epetra_Import(*Map1,A->RowMap());
508  B=new Epetra_CrsMatrix(*A,*Import1,Map1,Map1);
509 
510  diff=test_with_matvec(*A,*B);
511  if(diff > diff_tol){
512  if(MyPID==0) cout<<"FusedImport: Test #5 FAILED with norm diff = "<<diff<<"."<<endl;
513  total_err--;
514  }
515 
516  // Execute fused export constructor
517  delete B;
518  Export1 = new Epetra_Export(A->RowMap(),*Map1);
519  B=new Epetra_CrsMatrix(*A,*Export1,Map1,Map1);
520 
521  diff=test_with_matvec(*A,*B);
522  if(diff > diff_tol){
523  if(MyPID==0) cout<<"FusedExport: Test #5 FAILED with norm diff = "<<diff<<"."<<endl;
524  total_err--;
525  }
526 
527  delete A; delete B; delete Map1; delete Import1; delete Export1;
528  }
529 #endif
530 
531 
533  // Test 6: Tridiagonal Matrix; Migrate to Proc 0, Replace Comm
535 #ifdef ENABLE_TEST_6
536  {
537  double diff;
538  build_test_matrix(Comm,1,A);
539 
540  // New map with all on Procs 0 and 2
541  build_test_map(A->RowMap(),Map1);
542 
543  // Execute fused import constructor
544  Import1 = new Epetra_Import(*Map1,A->RowMap());
545  B=new Epetra_CrsMatrix(*A,*Import1,Map1,Map1,true);
546 
547  diff=test_with_matvec_reduced_maps(*A,*B,*Map1);
548  if(diff > diff_tol){
549  if(MyPID==0) cout<<"FusedImport: Test #6 FAILED with norm diff = "<<diff<<"."<<endl;
550  total_err--;
551  }
552 
553  // Execute fused export constructor
554  delete B;
555  Export1 = new Epetra_Export(A->RowMap(),*Map1);
556  B=new Epetra_CrsMatrix(*A,*Export1,Map1,Map1,true);
557 
558  diff=test_with_matvec_reduced_maps(*A,*B,*Map1);
559  if(diff > diff_tol){
560  if(MyPID==0) cout<<"FusedExport: Test #6 FAILED with norm diff = "<<diff<<"."<<endl;
561  total_err--;
562  }
563 
564  delete A; delete B; delete Map1; delete Import1; delete Export1;
565  }
566 #endif
567 
568 
569  // Final output for OK
570  if(MyPID==0 && total_err==0)
571  cout<<"FusedImportExport: All tests PASSED."<<endl;
572 
573  // Cleanup
574  MPI_Finalize();
575 
576  return total_err ;
577 }
578 
579 
580 
581 #else
582 int main(){
583 
584  return 0;
585 }
586 #endif
int Norm2(double *Result) const
Compute 2-norm of each vector in multi-vector.
double * Values() const
Get pointer to MultiVector values.
int NumProc() const
Returns total number of processes.
int check(Epetra_CrsMatrix &A, int NumMyRows1, int NumGlobalRows1, int NumMyNonzeros1, int NumGlobalNonzeros1, int *MyGlobalElements, bool verbose)
int MyGlobalElements(int *MyGlobalElementList) const
Puts list of global elements on this processor into the user-provided array.
Epetra_Map: A class for partitioning vectors and matrices.
Definition: Epetra_Map.h:119
double test_with_matvec(const Epetra_CrsMatrix &A, const Epetra_CrsMatrix &B)
int check_graph_sharing(Epetra_Comm &Comm)
bool SameAs(const Epetra_BlockMap &Map) const
Returns true if this and Map are identical maps.
static void SetTracebackMode(int TracebackModeValue)
Set the value of the Epetra_Object error traceback report mode.
int power_method(bool TransA, Epetra_CrsMatrix &A, Epetra_Vector &q, Epetra_Vector &z, Epetra_Vector &resid, double *lambda, int niters, double tolerance, bool verbose)
int Broadcast(double *MyVals, int Count, int Root) const
Epetra_MpiComm Broadcast function.
double test_with_matvec_reduced_maps(const Epetra_CrsMatrix &A, const Epetra_CrsMatrix &B, const Epetra_Map &Bfullmap)
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements...
Definition: Epetra_Export.h:62
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
#define EPETRA_MIN(x, y)
Epetra_MpiComm: The Epetra MPI Communication Class.
std::string Epetra_Version()
Epetra_Import: This class builds an import object for efficient importing of off-processor elements...
Definition: Epetra_Import.h:63
virtual int MyPID() const =0
Return my process ID.
const Epetra_Map & RangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
int build_matrix_unfused(const Epetra_CrsMatrix &SourceMatrix, Epetra_Import &RowImporter, Epetra_CrsMatrix *&A)
Epetra_Comm: The Epetra Communication Abstract Base Class.
Definition: Epetra_Comm.h:73
void build_test_matrix(Epetra_MpiComm &Comm, int test_number, Epetra_CrsMatrix *&A)
int NumMyElements() const
Number of elements on the calling processor.
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
int main(int argc, char *argv[])
int MyPID() const
Return my process ID.
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
Update multi-vector values with scaled values of A, this = ScalarThis*this + ScalarA*A.
virtual int NumProc() const =0
Returns total number of processes.
Epetra_CrsMatrix: A class for constructing and using real-valued double-precision sparse compressed r...
int NumGlobalElements() const
Number of elements across all processors.
int Import(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
Imports an Epetra_DistObject using the Epetra_Import object.
const Epetra_Map & DomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator. ...
void build_test_map(const Epetra_Map &oldMap, Epetra_Map *&newMap)
int ScanSum(double *MyVals, double *ScanSums, int Count) const
Epetra_MpiComm Scan Sum function.