Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_VbrRowMatrix.h
Go to the documentation of this file.
1 /*
2 //@HEADER
3 // ************************************************************************
4 //
5 // Epetra: Linear Algebra Services Package
6 // Copyright 2011 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 */
43 
44 #ifndef EPETRA_VBRROWMATRIX_H
45 #define EPETRA_VBRROWMATRIX_H
46 
47 #include "Epetra_BasicRowMatrix.h"
48 #include "Epetra_VbrMatrix.h"
49 #include "Epetra_Map.h"
50 #include "Epetra_Comm.h"
51 #include "Epetra_Vector.h"
52 #include "Epetra_MultiVector.h"
53 
55 
69 
70  public:
71 
73 
74  /* The constructor for this class requires a pointer to a fully constructed instance of an Epetra_VbrMatrix
76  object.
77  \param Matrix (In) Pointer to an existing Epetra_VbrMatrix. The input matrix must be retained by the user
78  throughout the existance of the dependent Epetra_VbrRowmatrix object.
79  \pre Matrix must have Matrix->Filled()==true.
80  */
82  if (Matrix==0) throw Matrix->RowMatrixRowMap().ReportError("Input matrix must have called FillComplete()", -1);
83  SetMaps(Matrix->RowMatrixRowMap(), Matrix->RowMatrixColMap(), Matrix->OperatorDomainMap(), Matrix->OperatorRangeMap());
84  if (!Matrix->Filled()) throw Matrix->RowMatrixRowMap().ReportError("Input matrix must have called FillComplete()", -1);
85  SetLabel("Epetra::VbrRowMatrix");
86 }
87 
91 
93 
94  /* Updates the matrix that the Epetra_VbrRowMatrix will use to satisfy the Epetra_RowMatrix functionality.
96  \param Matrix (In) A pointer to an existing, fully constructed Epetra_VbrMatrix.
97  \pre Matrix must have Matrix->Filled()==true.
98  */
100  if (Matrix ==0) {
101  EPETRA_CHK_ERR(-1);
102  }
103  else matrix_ = Matrix;
104  return(0);
105  }
107 
109 
110 
112 
121  int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const {
122 
123  EPETRA_CHK_ERR(matrix_->ExtractMyRowCopy(MyRow, Length, NumEntries, Values, Indices));
124  return(0);
125  }
126 
128 
136  int ExtractMyEntryView(int CurEntry, double * &Value, int & RowIndex, int & ColIndex) {
137  return(-1);
138  }
139 
141 
149  int ExtractMyEntryView(int CurEntry, double const * & Value, int & RowIndex, int & ColIndex) const {
150  return(-1);
151  }
152 
154 
163  int NumMyRowEntries(int MyRow, int & NumEntries) const {
164  EPETRA_CHK_ERR(matrix_->NumMyRowEntries(MyRow, NumEntries));
165  return(0);
166  }
167 
169 
171 
172 
174 
181  int RightScale(const Epetra_Vector& x){
182  HaveNumericConstants_ = false;
185  return(0);
186  }
187 
189 
196  int LeftScale(const Epetra_Vector& x){
197  HaveNumericConstants_ = false;
200  return(0);
201  }
202 
204 
214  int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const{
215  EPETRA_CHK_ERR(matrix_->Multiply(TransA, X, Y));
216  return(0);
217  }
218 
220 
234  int Solve(bool Upper, bool Trans, bool UnitDiagonal,
235  const Epetra_MultiVector& X,
236  Epetra_MultiVector& Y) const {
237  EPETRA_CHK_ERR(matrix_->Solve(Upper, Trans, UnitDiagonal, X, Y));
238  return(0);
239  } //@}
240 
241 
242 
243  private:
244 
246 
247 };
248 #endif /* EPETRA_VBRROWMATRIX_H */
int ExtractMyEntryView(int CurEntry, double const *&Value, int &RowIndex, int &ColIndex) const
Returns a const reference to the ith entry in the matrix, along with its row and column index...
Epetra_MultiVector: A class for constructing and using dense multi-vectors, vectors and matrices in p...
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.
Epetra_VbrMatrix * matrix_
int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_VbrMatrix multiplied by a Epetra_MultiVector X in Y.
void SetMaps(const Epetra_Map &RowMap, const Epetra_Map &ColMap)
Set maps (Version 1); call this function or the next, but not both.
const Epetra_Map & RowMatrixColMap() const
Returns the Epetra_Map object associated with columns of this matrix.
int RightScale(const Epetra_Vector &x)
Scales the Epetra_VbrMatrix on the right with a Epetra_Vector x.
int NumMyRowEntries(int MyRow, int &NumEntries) const
Return the current number of values stored for the specified local row.
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this matrix.
virtual void SetLabel(const char *const Label)
Epetra_Object Label definition using char *.
#define EPETRA_CHK_ERR(a)
virtual int NumGlobalNonzeros() const
Returns the number of nonzero entries in the global matrix.
Epetra_VbrMatrix: A class for the construction and use of real-valued double-precision variable block...
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
bool Filled() const
If FillComplete() has been called, this query returns true, otherwise it returns false.
Epetra_VbrRowMatrix: A class for using an existing Epetra_VbrMatrix object as an Epetra_RowMatrix obj...
int UpdateMatrix(Epetra_VbrMatrix *Matrix)
Update the matrix to which this object points.
int RightScale(const Epetra_Vector &x)
Scales the Epetra_VbrMatrix on the right with a Epetra_Vector x.
int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_Vector &x, Epetra_Vector &y) const
Returns the result of a solve using the Epetra_VbrMatrix on a Epetra_Vector x in y.
int ExtractMyEntryView(int CurEntry, double *&Value, int &RowIndex, int &ColIndex)
Returns a reference to the ith entry in the matrix, along with its row and column index...
int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_VbrRowMatrix solve with a Epetra_MultiVector X in Y (not implemented)...
Epetra_BasicRowMatrix: A class for simplifying the development of Epetra_RowMatrix adapters...
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
const Epetra_Map & RowMatrixRowMap() const
Returns the EpetraMap object associated with the rows of this matrix.
int NumMyRowEntries(int MyRow, int &NumEntries) const
Return the current number of values stored for the specified local row.
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator. ...
int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_VbrRowMatrix multiplied by a Epetra_MultiVector X in Y...
virtual ~Epetra_VbrRowMatrix()
Epetra_VbrRowMatrix Destructor.
virtual int ReportError(const std::string Message, int ErrorCode) const
Error reporting method.
Epetra_VbrRowMatrix(Epetra_VbrMatrix *Matrix)
Epetra_VbrRowMatrix constuctor.
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 LeftScale(const Epetra_Vector &x)
Scales the Epetra_VbrMatrix on the left with a Epetra_Vector x.
int LeftScale(const Epetra_Vector &x)
Scales the Epetra_VbrMatrix on the left with a Epetra_Vector x.
void UpdateFlops(int Flops_in) const
Increment Flop count for this object.