EpetraExt  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EpetraExt_PETScAIJMatrix.cpp
Go to the documentation of this file.
1 //@HEADER
2 // ***********************************************************************
3 //
4 // EpetraExt: Epetra Extended - 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 # CVS File Information
44 # Current revision: $Revision$
45 # Last modified: $Date$
46 # Modified by: $Author$
47 #############################################################################*/
48 
49 #include "EpetraExt_ConfigDefs.h"
50 #ifdef HAVE_PETSC
51 
52 #include "Epetra_Import.h"
53 #include "Epetra_Export.h"
54 #include "Epetra_Vector.h"
55 #include "Epetra_MultiVector.h"
57 
58 //==============================================================================
60  : Epetra_Object("Epetra::PETScAIJMatrix"),
61  Amat_(Amat),
62  Values_(0),
63  Indices_(0),
64  MaxNumEntries_(-1),
65  ImportVector_(0),
66  NormInf_(-1.0),
67  NormOne_(-1.0)
68 {
69 #ifdef HAVE_MPI
70  MPI_Comm comm;
71  PetscObjectGetComm( (PetscObject)Amat, &comm);
72  Comm_ = new Epetra_MpiComm(comm);
73 #else
74  Comm_ = new Epetra_SerialComm();
75 #endif
76  int ierr;
77  char errMsg[80];
78  MatGetType(Amat, &MatType_);
79  if ( strcmp(MatType_,MATSEQAIJ) != 0 && strcmp(MatType_,MATMPIAIJ) != 0 ) {
80  sprintf(errMsg,"PETSc matrix must be either seqaij or mpiaij (but it is %s)",MatType_);
81  throw Comm_->ReportError(errMsg,-1);
82  }
83  petscMatrixType mt;
84  Mat_MPIAIJ* aij=0;
85  if (strcmp(MatType_,MATMPIAIJ) == 0) {
86  mt = PETSC_MPI_AIJ;
87  aij = (Mat_MPIAIJ*)Amat->data;
88  }
89  else if (strcmp(MatType_,MATSEQAIJ) == 0) {
90  mt = PETSC_SEQ_AIJ;
91  }
92  int numLocalRows, numLocalCols;
93  ierr = MatGetLocalSize(Amat,&numLocalRows,&numLocalCols);
94  if (ierr) {
95  sprintf(errMsg,"EpetraExt_PETScAIJMatrix.cpp, line %d, MatGetLocalSize() returned error code %d",__LINE__,ierr);
96  throw Comm_->ReportError(errMsg,-1);
97  }
98  NumMyRows_ = numLocalRows;
99  NumMyCols_ = numLocalCols; //numLocalCols is the total # of unique columns in the local matrix (the diagonal block)
100  //TODO what happens if some columns are empty?
101  if (mt == PETSC_MPI_AIJ)
102  NumMyCols_ += aij->B->cmap->n;
103  MatInfo info;
104  ierr = MatGetInfo(Amat,MAT_LOCAL,&info);
105  if (ierr) {
106  sprintf(errMsg,"EpetraExt_PETScAIJMatrix.cpp, line %d, MatGetInfo() returned error code %d",__LINE__,ierr);
107  throw Comm_->ReportError(errMsg,-1);
108  }
109  NumMyNonzeros_ = (int) info.nz_used; //PETSc stores nnz as double
110  Comm_->SumAll(&(info.nz_used), &NumGlobalNonzeros_, 1);
111 
112  //The PETSc documentation warns that this may not be robust.
113  //In particular, this will break if the ordering is not contiguous!
114  int rowStart, rowEnd;
115  ierr = MatGetOwnershipRange(Amat,&rowStart,&rowEnd);
116  if (ierr) {
117  sprintf(errMsg,"EpetraExt_PETScAIJMatrix.cpp, line %d, MatGetOwnershipRange() returned error code %d",__LINE__,ierr);
118  throw Comm_->ReportError(errMsg,-1);
119  }
120 
121  PetscRowStart_ = rowStart;
122  PetscRowEnd_ = rowEnd;
123 
124  int* MyGlobalElements = new int[rowEnd-rowStart];
125  for (int i=0; i<rowEnd-rowStart; i++)
126  MyGlobalElements[i] = rowStart+i;
127 
128  ierr = MatGetInfo(Amat,MAT_GLOBAL_SUM,&info);
129  if (ierr) {
130  sprintf(errMsg,"EpetraExt_PETScAIJMatrix.cpp, line %d, MatGetInfo() returned error code %d",__LINE__,ierr);
131  throw Comm_->ReportError(errMsg,-1);
132  }
133  int tmp;
134  ierr = MatGetSize(Amat,&NumGlobalRows_,&tmp);
135 
136  DomainMap_ = new Epetra_Map(NumGlobalRows_, NumMyRows_, MyGlobalElements, 0, *Comm_);
137 
138  // get the GIDs of the non-local columns
139  //FIXME what if the matrix is sequential?
140 
141  int * ColGIDs = new int[NumMyCols_];
142  for (int i=0; i<numLocalCols; i++) ColGIDs[i] = MyGlobalElements[i];
143  for (int i=numLocalCols; i<NumMyCols_; i++) ColGIDs[i] = aij->garray[i-numLocalCols];
144 
145  ColMap_ = new Epetra_Map(-1, NumMyCols_, ColGIDs, 0, *Comm_);
146 
147  Importer_ = new Epetra_Import(*ColMap_, *DomainMap_);
148 
149  delete [] MyGlobalElements;
150  delete [] ColGIDs;
151 } //Epetra_PETScAIJMatrix(Mat Amat)
152 
153 //==============================================================================
154 
156  if (ImportVector_!=0) delete ImportVector_;
157  delete Importer_;
158  delete ColMap_;
159  delete DomainMap_;
160  delete Comm_;
161 
162  if (Values_!=0) {delete [] Values_; Values_=0;}
163  if (Indices_!=0) {delete [] Indices_; Indices_=0;}
164 } //Epetra_PETScAIJMatrix dtor
165 
166 //==========================================================================
167 
168 extern "C" {
169  PetscErrorCode CreateColmap_MPIAIJ_Private(Mat);
170 }
171 
172 int Epetra_PETScAIJMatrix::ExtractMyRowCopy(int Row, int Length, int & NumEntries, double * Values,
173  int * Indices) const
174 {
175  int nz;
176  PetscInt *gcols, *lcols, ierr;
177  PetscScalar *vals;
178  bool alloc=false;
179 
180  // PETSc assumes the row number is global, whereas Trilinos assumes it's local.
181  int globalRow = PetscRowStart_ + Row;
182  assert(globalRow < PetscRowEnd_);
183  ierr=MatGetRow(Amat_, globalRow, &nz, (const PetscInt**) &gcols, (const PetscScalar **) &vals);CHKERRQ(ierr);
184 
185  // I ripped this bit of code from PETSc's MatSetValues_MPIAIJ() in mpiaij.c. The PETSc getrow returns everything in
186  // global numbering, so we must convert to local numbering.
187  if (strcmp(MatType_,MATMPIAIJ) == 0) {
188  Mat_MPIAIJ *aij = (Mat_MPIAIJ*)Amat_->data;
189  lcols = (PetscInt *) malloc(nz * sizeof(int));
190  alloc=true;
191  if (!aij->colmap) {
192  ierr = CreateColmap_MPIAIJ_Private(Amat_);CHKERRQ(ierr);
193  }
194  /*
195  A PETSc parallel aij matrix uses two matrices to represent the local rows.
196  The first matrix, A, is square and contains all local columns.
197  The second matrix, B, is rectangular and contains all non-local columns.
198 
199  Matrix A:
200  Local column ID's are mapped to global column id's by adding cmap.rstart.
201  Given the global ID of a local column, the local ID is found by
202  subtracting cmap.rstart.
203 
204  Matrix B:
205  Non-local column ID's are mapped to global column id's by the local-to-
206  global map garray. Given the global ID of a local column, the local ID is
207  found by the global-to-local map colmap. colmap is either an array or
208  hash table, the latter being the case when PETSC_USE_CTABLE is defined.
209  */
210  int offset = Amat_->cmap->n-1; //offset for non-local column indices
211 
212  for (int i=0; i<nz; i++) {
213  if (gcols[i] >= Amat_->cmap->rstart && gcols[i] < Amat_->cmap->rend) {
214  lcols[i] = gcols[i] - Amat_->cmap->rstart;
215  } else {
216 # ifdef PETSC_USE_CTABLE
217  ierr = PetscTableFind(aij->colmap,gcols[i]+1,lcols+i);CHKERRQ(ierr);
218  lcols[i] = lcols[i] + offset;
219 # else
220  lcols[i] = aij->colmap[gcols[i]] + offset;
221 # endif
222  }
223 
224  } //for i=0; i<nz; i++)
225  }
226  else lcols = gcols;
227 
228  NumEntries = nz;
229  if (NumEntries > Length) return(-1);
230  for (int i=0; i<NumEntries; i++) {
231  Indices[i] = lcols[i];
232  Values[i] = vals[i];
233  }
234  if (alloc) free(lcols);
235  MatRestoreRow(Amat_,globalRow,&nz,(const PetscInt**) &gcols, (const PetscScalar **) &vals);
236  return(0);
237 } //ExtractMyRowCopy()
238 
239 //==========================================================================
240 
241 int Epetra_PETScAIJMatrix::NumMyRowEntries(int Row, int & NumEntries) const
242 {
243  int globalRow = PetscRowStart_ + Row;
244  MatGetRow(Amat_, globalRow, &NumEntries, PETSC_NULL, PETSC_NULL);
245  MatRestoreRow(Amat_,globalRow,&NumEntries, PETSC_NULL, PETSC_NULL);
246  return(0);
247 }
248 
249 //==============================================================================
250 
251 int Epetra_PETScAIJMatrix::ExtractDiagonalCopy(Epetra_Vector & Diagonal) const
252 {
253 
254  //TODO optimization: only get this diagonal once
255  Vec petscDiag;
256  double *vals=0;
257  int length;
258 
259  int ierr=VecCreate(Comm_->Comm(),&petscDiag);CHKERRQ(ierr);
260  VecSetSizes(petscDiag,NumMyRows_,NumGlobalRows_);
261 # ifdef HAVE_MPI
262  ierr = VecSetType(petscDiag,VECMPI);CHKERRQ(ierr);
263 # else //TODO untested!!
264  VecSetType(petscDiag,VECSEQ);
265 # endif
266 
267  MatGetDiagonal(Amat_, petscDiag);
268  VecGetArray(petscDiag,&vals);
269  VecGetLocalSize(petscDiag,&length);
270  for (int i=0; i<length; i++) Diagonal[i] = vals[i];
271  VecRestoreArray(petscDiag,&vals);
272  VecDestroy(petscDiag);
273  return(0);
274 }
275 
276 //=============================================================================
277 
278 int Epetra_PETScAIJMatrix::Multiply(bool TransA,
279  const Epetra_MultiVector& X,
280  Epetra_MultiVector& Y) const
281 {
282  (void)TransA;
283  int NumVectors = X.NumVectors();
284  if (NumVectors!=Y.NumVectors()) EPETRA_CHK_ERR(-1); // X and Y must have same number of vectors
285 
286  double ** xptrs;
287  double ** yptrs;
288  X.ExtractView(&xptrs);
289  Y.ExtractView(&yptrs);
290  if (RowMatrixImporter()!=0) {
291  if (ImportVector_!=0) {
292  if (ImportVector_->NumVectors()!=NumVectors) { delete ImportVector_; ImportVector_= 0;}
293  }
294  if (ImportVector_==0) ImportVector_ = new Epetra_MultiVector(RowMatrixColMap(),NumVectors);
295  ImportVector_->Import(X, *RowMatrixImporter(), Insert);
296  ImportVector_->ExtractView(&xptrs);
297  }
298 
299  double *vals=0;
300  int length;
301  Vec petscX, petscY;
302  int ierr;
303  for (int i=0; i<NumVectors; i++) {
304 # ifdef HAVE_MPI
305  ierr=VecCreateMPIWithArray(Comm_->Comm(),X.MyLength(),X.GlobalLength(),xptrs[i],&petscX); CHKERRQ(ierr);
306  ierr=VecCreateMPIWithArray(Comm_->Comm(),Y.MyLength(),Y.GlobalLength(),yptrs[i],&petscY); CHKERRQ(ierr);
307 # else //FIXME untested
308  ierr=VecCreateSeqWithArray(Comm_->Comm(),X.MyLength(),X.GlobalLength(),xptrs[i],&petscX); CHKERRQ(ierr);
309  ierr=VecCreateSeqWithArray(Comm_->Comm(),Y.MyLength(),Y.GlobalLength(),yptrs[i],&petscY); CHKERRQ(ierr);
310 # endif
311 
312  ierr = MatMult(Amat_,petscX,petscY);CHKERRQ(ierr);
313 
314  ierr = VecGetArray(petscY,&vals);CHKERRQ(ierr);
315  ierr = VecGetLocalSize(petscY,&length);CHKERRQ(ierr);
316  for (int j=0; j<length; j++) yptrs[i][j] = vals[j];
317  ierr = VecRestoreArray(petscY,&vals);CHKERRQ(ierr);
318  }
319 
320  VecDestroy(petscX); VecDestroy(petscY);
321 
322  double flops = NumGlobalNonzeros();
323  flops *= 2.0;
324  flops *= (double) NumVectors;
325  UpdateFlops(flops);
326  return(0);
327 } //Multiply()
328 
329 //=============================================================================
330 
331 int Epetra_PETScAIJMatrix::Solve(bool Upper, bool Trans, bool UnitDiagonal,
332  const Epetra_MultiVector& X,
333  Epetra_MultiVector& Y) const
334 {
335  (void)Upper;
336  (void)Trans;
337  (void)UnitDiagonal;
338  (void)X;
339  (void)Y;
340  return(-1); // Not implemented
341 }
342 
343 //=============================================================================
344 // Utility routine to get the specified row and put it into Values_ and Indices_ arrays
346  int NumEntries;
347 
348  if (MaxNumEntries_==-1) {
349  for (int i=0; i < NumMyRows_; i++) {
350  NumMyRowEntries(i, NumEntries);
351  if (NumEntries>MaxNumEntries_) MaxNumEntries_ = NumEntries;
352  }
353  }
354  return(MaxNumEntries_);
355 }
356 
357 //=============================================================================
358 // Utility routine to get the specified row and put it into Values_ and Indices_ arrays
359 int Epetra_PETScAIJMatrix::GetRow(int Row) const {
360 
361  int NumEntries;
362  int MaxNumEntries = Epetra_PETScAIJMatrix::MaxNumEntries();
363 
364  if (MaxNumEntries>0) {
365  if (Values_==0) Values_ = new double[MaxNumEntries];
366  if (Indices_==0) Indices_ = new int[MaxNumEntries];
367  }
368  Epetra_PETScAIJMatrix::ExtractMyRowCopy(Row, MaxNumEntries, NumEntries, Values_, Indices_);
369 
370  return(NumEntries);
371 }
372 
373 //=============================================================================
374 int Epetra_PETScAIJMatrix::InvRowSums(Epetra_Vector& x) const {
375 //
376 // Put inverse of the sum of absolute values of the ith row of A in x[i].
377 //
378 
379  if (!OperatorRangeMap().SameAs(x.Map())) EPETRA_CHK_ERR(-2); // x must have the same distribution as the range of A
380 
381  int ierr = 0;
382  int i, j;
383  for (i=0; i < NumMyRows_; i++) {
384  int NumEntries = GetRow(i); // Copies ith row of matrix into Values_ and Indices_
385  double scale = 0.0;
386  for (j=0; j < NumEntries; j++) scale += fabs(Values_[j]);
387  if (scale<Epetra_MinDouble) {
388  if (scale==0.0) ierr = 1; // Set error to 1 to signal that zero rowsum found (supercedes ierr = 2)
389  else if (ierr!=1) ierr = 2;
390  x[i] = Epetra_MaxDouble;
391  }
392  else
393  x[i] = 1.0/scale;
394  }
395  UpdateFlops(NumGlobalNonzeros());
396  EPETRA_CHK_ERR(ierr);
397  return(0);
398 }
399 
400 //=============================================================================
401 int Epetra_PETScAIJMatrix::InvColSums(Epetra_Vector& x) const {
402 //
403 // Put inverse of the sum of absolute values of the jth column of A in x[j].
404 //
405 
406  if (!Filled()) EPETRA_CHK_ERR(-1); // Matrix must be filled.
407  if (!OperatorDomainMap().SameAs(x.Map())) EPETRA_CHK_ERR(-2); // x must have the same distribution as the domain of A
408 
409 
410  Epetra_Vector * xp = 0;
411  Epetra_Vector * x_tmp = 0;
412 
413 
414  // If we have a non-trivial importer, we must export elements that are permuted or belong to other processors
415  if (RowMatrixImporter()!=0) {
416  x_tmp = new Epetra_Vector(RowMatrixColMap()); // Create import vector if needed
417  xp = x_tmp;
418  }
419  int ierr = 0;
420  int i, j;
421 
422  for (i=0; i < NumMyCols_; i++) (*xp)[i] = 0.0;
423 
424  for (i=0; i < NumMyRows_; i++) {
425  int NumEntries = GetRow(i);// Copies ith row of matrix into Values_ and Indices_
426  for (j=0; j < NumEntries; j++) (*xp)[Indices_[j]] += fabs(Values_[j]);
427  }
428 
429  if (RowMatrixImporter()!=0){
430  x.Export(*x_tmp, *RowMatrixImporter(), Add); // Fill x with Values from import vector
431  delete x_tmp;
432  xp = &x;
433  }
434  // Invert values, don't allow them to get too large
435  for (i=0; i < NumMyRows_; i++) {
436  double scale = (*xp)[i];
437  if (scale<Epetra_MinDouble) {
438  if (scale==0.0) ierr = 1; // Set error to 1 to signal that zero rowsum found (supercedes ierr = 2)
439  else if (ierr!=1) ierr = 2;
440  (*xp)[i] = Epetra_MaxDouble;
441  }
442  else
443  (*xp)[i] = 1.0/scale;
444  }
445  UpdateFlops(NumGlobalNonzeros());
446  EPETRA_CHK_ERR(ierr);
447  return(0);
448 }
449 
450 //=============================================================================
451 int Epetra_PETScAIJMatrix::LeftScale(const Epetra_Vector& X) {
452 //
453 // This function scales the ith row of A by x[i].
454 //
455  double *xptr;
456  X.ExtractView(&xptr);
457  Vec petscX;
458 # ifdef HAVE_MPI
459  int ierr=VecCreateMPIWithArray(Comm_->Comm(),X.MyLength(),X.GlobalLength(),xptr,&petscX); CHKERRQ(ierr);
460 # else //FIXME untested
461  int ierr=VecCreateSeqWithArray(Comm_->Comm(),X.MyLength(),X.GlobalLength(),xptr,&petscX); CHKERRQ(ierr);
462 # endif
463 
464  MatDiagonalScale(Amat_, petscX, PETSC_NULL);
465 
466  ierr=VecDestroy(petscX); CHKERRQ(ierr);
467  return(0);
468 } //LeftScale()
469 
470 //=============================================================================
471 int Epetra_PETScAIJMatrix::RightScale(const Epetra_Vector& X) {
472 //
473 // This function scales the jth row of A by x[j].
474 //
475  double *xptr;
476  X.ExtractView(&xptr);
477  Vec petscX;
478 # ifdef HAVE_MPI
479  int ierr=VecCreateMPIWithArray(Comm_->Comm(),X.MyLength(),X.GlobalLength(),xptr,&petscX); CHKERRQ(ierr);
480 # else //FIXME untested
481  int ierr=VecCreateSeqWithArray(Comm_->Comm(),X.MyLength(),X.GlobalLength(),xptr,&petscX); CHKERRQ(ierr);
482 # endif
483 
484  MatDiagonalScale(Amat_, PETSC_NULL, petscX);
485 
486  ierr=VecDestroy(petscX); CHKERRQ(ierr);
487  return(0);
488 } //RightScale()
489 
490 //=============================================================================
491 
492 double Epetra_PETScAIJMatrix::NormInf() const {
493 
494  if (NormInf_>-1.0) return(NormInf_);
495 
496  MatNorm(Amat_, NORM_INFINITY,&NormInf_);
497  UpdateFlops(NumGlobalNonzeros());
498 
499  return(NormInf_);
500 }
501 
502 //=============================================================================
503 
504 double Epetra_PETScAIJMatrix::NormOne() const {
505 
506  if (NormOne_>-1.0) return(NormOne_);
507  if (!Filled()) EPETRA_CHK_ERR(-1); // Matrix must be filled.
508 
509  MatNorm(Amat_, NORM_1,&NormOne_);
510  UpdateFlops(NumGlobalNonzeros());
511 
512  return(NormOne_);
513 }
514 
515 //=============================================================================
516 
517 void Epetra_PETScAIJMatrix::Print(ostream& os) const {
518  return;
519 }
520 
521 #endif /*HAVE_PETSC*/
int ExtractDiagonalCopy(Epetra_Vector &Diagonal) const
Returns a copy of the main diagonal in a user-provided vector.
int NumMyRowEntries(int MyRow, int &NumEntries) const
Return the current number of values stored for the specified local row.
Epetra_PETScAIJMatrix(Mat Amat)
Epetra_PETScAIJMatrix constructor.
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.
int InvRowSums(Epetra_Vector &x) const
Computes the sum of absolute values of the rows of the Epetra_PETScAIJMatrix, results returned in x...
int RightScale(const Epetra_Vector &x)
Scales the Epetra_PETScAIJMatrix on the right with a Epetra_Vector x.
virtual ~Epetra_PETScAIJMatrix()
Epetra_PETScAIJMatrix Destructor.
double NormOne() const
Returns the one norm of the global matrix.
int LeftScale(const Epetra_Vector &x)
Scales the Epetra_PETScAIJMatrix on the left with a Epetra_Vector x.
int InvColSums(Epetra_Vector &x) const
Computes the sum of absolute values of the columns of the Epetra_PETScAIJMatrix, results returned in ...
int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_PETScAIJMatrix multiplied by a Epetra_MultiVector X in Y...
int MaxNumEntries() const
Returns the maximum of NumMyRowEntries() over all rows.
virtual void Print(ostream &os) const
Print method.
int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_PETScAIJMatrix multiplied by a Epetra_MultiVector X in Y...
double NormInf() const
Returns the infinity norm of the global matrix.