EpetraExt Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EpetraExt_PETScAIJMatrix.h
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 #ifndef _EPETRAEXT_PETSCAIJMATRIX_H_
50 #define _EPETRAEXT_PETSCAIJMATRIX_H_
51 
52 #include "Epetra_Object.h"
53 #include "Epetra_CompObject.h"
54 #include "Epetra_RowMatrix.h"
55 #include "Epetra_Map.h"
56 #ifdef HAVE_MPI
57 #include "Epetra_MpiComm.h"
58 #else
59 #include "Epetra_SerialComm.h"
60 #endif
61 //Petsc headers.
62 //Note: Petsc internally hard-codes paths to headers, relative to the PETSC home
63 // directory. This means that --with-incdirs must contain the full path(s)
64 // to the header below plus the PETSc home directory.
65 #include "src/mat/impls/aij/mpi/mpiaij.h"
66 
67 class Epetra_Import;
68 class Epetra_Export;
69 class Epetra_Vector;
70 class Epetra_MultiVector;
71 
73 
82 
83  public:
84 
86 
87 
94 
96  virtual ~Epetra_PETScAIJMatrix();
98 
100 
101 
103 
117  int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
118 
120 
126  int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
128 
130 
131 
133 
143  int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
144 
146 
160  int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
161 
163 
173  int InvRowSums(Epetra_Vector& x) const;
174 
176 
183  int LeftScale(const Epetra_Vector& x);
184 
186 
196  int InvColSums(Epetra_Vector& x) const;
197 
199 
206  int RightScale(const Epetra_Vector& x);
208 
210 
211 
212 
214  bool Filled() const {return(true);};
215 
217  bool LowerTriangular() const {return(false);};
218 
220  bool UpperTriangular() const {return(false);};
221 
223 
225 
226 
228  Mat Amat() const {return(Amat_);};
229 
231  /* Returns the quantity \f$ \| A \|_\infty\f$ such that
232  \f[\| A \|_\infty = \max_{1\lei\lem} \sum_{j=1}^n |a_{ij}| \f].
233  */
234  double NormInf() const;
235 
237  /* Returns the quantity \f$ \| A \|_1\f$ such that
238  \f[\| A \|_1= \max_{1\lej\len} \sum_{i=1}^m |a_{ij}| \f].
239  */
240  double NormOne() const;
241 
242 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
243  int NumGlobalNonzeros() const {return(NumGlobalNonzeros_);};
245 
247  int NumGlobalRows() const {return(OperatorRangeMap().NumGlobalPoints());};
248 
250  int NumGlobalCols() const {return(OperatorDomainMap().NumGlobalPoints());};
251 
253  int NumGlobalDiagonals() const{return(OperatorDomainMap().NumGlobalPoints());};
254 #endif
255  long long NumGlobalNonzeros64() const {return(NumGlobalNonzeros_);};
257 
259  long long NumGlobalRows64() const {return(OperatorRangeMap().NumGlobalPoints64());};
260 
262  long long NumGlobalCols64() const {return(OperatorDomainMap().NumGlobalPoints64());};
263 
265  long long NumGlobalDiagonals64() const{return(OperatorDomainMap().NumGlobalPoints64());};
266 
268  int NumMyNonzeros() const {return(NumMyNonzeros_);};
269 
271  int NumMyRows() const {return(OperatorRangeMap().NumMyPoints());};
272 
274  int NumMyCols() const {return(RowMatrixColMap().NumMyPoints());};
275 
277  int NumMyDiagonals() const {return(OperatorRangeMap().NumMyPoints());};
278 
280  const Epetra_Map & OperatorDomainMap() const {return(*DomainMap_);};
281 
283  const Epetra_Map & OperatorRangeMap() const {return(*DomainMap_);};
284 
286  const Epetra_BlockMap& Map() const {return(RowMatrixRowMap());}
287 
289  const Epetra_Map & RowMatrixRowMap() const {return(OperatorRangeMap());};
290 
292  const Epetra_Map & RowMatrixColMap() const {return(*ColMap_);};
293 
295  virtual const Epetra_Import * RowMatrixImporter() const {return(Importer_);};
296 
298  const Epetra_Comm & Comm() const {return(*Comm_);};
300 
301 
303 
304 
306  virtual void Print(std::ostream & os) const;
308 
310 
311 
313  const char * Label() const {return(Epetra_Object::Label());};
314 
316 
326  {(void)UseTranspose; return(-1);}
327 
329 
337  int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const {
339 
341 
355  Epetra_MultiVector& Y) const
356  {(void)X; (void)Y; return(-1);}
357 
359  virtual bool HasNormInf() const {return(true);}
360 
362  virtual bool UseTranspose() const {return(false);}
363 
365 
367 
369 
378  int NumMyRowEntries(int MyRow, int & NumEntries) const;
379 
381  int MaxNumEntries() const;
383 
384  private:
385 
386  int GetRow(int Row) const;
387  Mat Amat_; //general PETSc matrix type
388  mutable double * Values_;
389  mutable int * Indices_;
390  mutable int MaxNumEntries_;
391 
392 #ifdef HAVE_MPI
394 #else
396 #endif
401 
410  MatType MatType_; //really const char*
411  mutable double NormInf_;
412  mutable double NormOne_;
413 
414 
416  //FIXME we need a copy ctor
417  //Epetra_PETScAIJMatrix(const Epetra_PETScAIJMatrix & Matrix) {(void)Matrix;}
418 };
419 #endif /* _EPETRAEXT_PETSCAIJMATRIX_H_ */
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.
int NumMyNonzeros() const
Returns the number of nonzero entries in the calling processor's portion of the matrix.
Epetra_PETScAIJMatrix(Mat Amat)
Epetra_PETScAIJMatrix constructor.
const int MatType
virtual const Epetra_Import * RowMatrixImporter() const
Returns the Epetra_Import object that contains the import operations for distributed operations...
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
const Epetra_BlockMap & Map() const
Implement the Epetra_SrcDistObjec::Map() function.
long long NumGlobalDiagonals64() const
Returns the number of global nonzero diagonal entries.
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.
Epetra_MultiVector * ImportVector_
const char * Label() const
Returns a character string describing the operator.
int SetUseTranspose(bool UseTranspose)
If set true, transpose of this operator will be applied.
int NumGlobalRows() const
Returns the number of global matrix rows.
int LeftScale(const Epetra_Vector &x)
Scales the Epetra_PETScAIJMatrix on the left with a Epetra_Vector x.
int NumGlobalDiagonals() const
Returns the number of global nonzero diagonal entries.
int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_Operator inverse applied to an Epetra_MultiVector X in Y...
bool Filled() const
If FillComplete() has been called, this query returns true, otherwise it returns false.
virtual void Print(std::ostream &os) const
Print method.
int NumGlobalCols() const
Returns the number of global matrix columns.
int NumMyCols() const
Returns the number of matrix columns owned by the calling processor.
int NumMyDiagonals() const
Returns the number of local nonzero diagonal entries.
int InvColSums(Epetra_Vector &x) const
Computes the sum of absolute values of the columns of the Epetra_PETScAIJMatrix, results returned in ...
int NumGlobalNonzeros() const
Returns the number of nonzero entries in the global matrix.
long long NumGlobalNonzeros64() const
Returns the number of nonzero entries in the global matrix.
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this matrix.
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...
Mat Amat() const
Returns a pointer to the PETSc matrix used to create this object.
const Epetra_Map & RowMatrixRowMap() const
Returns the Row Map object needed for implementing Epetra_RowMatrix.
bool LowerTriangular() const
If matrix is lower triangular, this query returns true, otherwise it returns false.
const Epetra_Map & RowMatrixColMap() const
Returns the Column Map object needed for implementing Epetra_RowMatrix.
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator (same as domain)...
int GetRow(int Row) const
int MaxNumEntries() const
Returns the maximum of NumMyRowEntries() over all rows.
Epetra_PETScAIJMatrix: A class for constructing and using real-valued sparse compressed row matrices...
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
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...
long long NumGlobalRows64() const
Returns the number of global matrix rows.
int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_Operator applied to a Epetra_MultiVector X in Y.
virtual bool HasNormInf() const
Returns true because this class can compute an Inf-norm.
double NormInf() const
Returns the infinity norm of the global matrix.
bool UpperTriangular() const
If matrix is upper triangular, this query returns true, otherwise it returns false.
long long NumGlobalCols64() const
Returns the number of global matrix columns.
int NumMyRows() const
Returns the number of matrix rows owned by the calling processor.