Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_JadMatrix.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_JADMATRIX_H
45 #define EPETRA_JADMATRIX_H
46 
47 #if defined(Epetra_SHOW_DEPRECATED_WARNINGS)
48 #ifdef __GNUC__
49 #warning "The Epetra package is deprecated"
50 #endif
51 #endif
52 
53 
54 
55 #include "Epetra_BasicRowMatrix.h"
56 #include "Epetra_Map.h"
57 #include "Epetra_Comm.h"
60 
61 
62 class Epetra_Vector;
63 class Epetra_MultiVector;
64 class Epetra_Import;
65 class Epetra_Export;
66 
68 
76 class EPETRA_LIB_DLL_EXPORT Epetra_JadMatrix: public Epetra_BasicRowMatrix {
77 
78  public:
79 
81 
82  /* The constructor for this class requires a fully constructed instance of an Epetra_RowMatrix
84  object.
85  \param Matrix (In) An existing Epetra_RowMatrix.
86  \pre Matrix must have Matrix.Filled()==true.
87  */
88  Epetra_JadMatrix(const Epetra_RowMatrix & Matrix);
89 
91  virtual ~Epetra_JadMatrix();
93 
95 
96  /* Updates the values only using a matrix that has exactly the same structure as
98  the matrix used to construct this Epetra_JadMatrix object. Once the constructor
99  is called, the Matrix argument is no longer needed.
100  \param Matrix (In) An existing Epetra_RowMatrix with \e identical structure to
101  the matrix used to create this Epetra_JadMatrix.
102  \param CheckStructure (In) Optional argument, by default is false. If set to true,
103  the method will check to see if the structure of Matrix is compatible with
104  the structure of matrix used to create this Epetra_JadMatrix. Performing
105  this check has signficant overhead, so it should only be turned on for debugging.
106  \pre Matrix must have Matrix.Filled()==true.
107  */
108  int UpdateValues(const Epetra_RowMatrix & Matrix, bool CheckStructure = false);
110 
112 
113 
115 
124  int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
125 
127 
135  int ExtractMyEntryView(int CurEntry, double * &Value, int & RowIndex, int & ColIndex) {
136  if (CurEntry>=NumMyNonzeros_) EPETRA_CHK_ERR(-1);
137  Value = &Values_[CurEntry];
138  ColIndex = Indices_[CurEntry];
139  for (int j=0; j<NumJaggedDiagonals_; j++) if (CurEntry<IndexOffset_[j+1]) {RowIndex = RowPerm_[CurEntry-IndexOffset_[j]]; break;}
140  return(0);
141  }
142 
144 
152  int ExtractMyEntryView(int CurEntry, double const * & Value, int & RowIndex, int & ColIndex) const {
153  if (CurEntry>=NumMyNonzeros_) EPETRA_CHK_ERR(-1);
154  Value = &Values_[CurEntry];
155  ColIndex = Indices_[CurEntry];
156  for (int j=0; j<NumJaggedDiagonals_; j++) if (CurEntry<IndexOffset_[j+1]) {RowIndex = RowPerm_[CurEntry-IndexOffset_[j]]; break;}
157  return(0);
158  }
159 
161 
170  int NumMyRowEntries(int MyRow, int & NumEntries) const;
171 
173 
175 
176 
178 
188  int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
189 
191 
205  int Solve(bool Upper, bool Trans, bool UnitDiagonal,
206  const Epetra_MultiVector& X,
207  Epetra_MultiVector& Y) const
208  {
209  (void)Upper;
210  (void)Trans;
211  (void)UnitDiagonal;
212  (void)X;
213  (void)Y;
214  return(-1);
215  }
217 
218 
219 
220  protected:
221 
222  void GeneralMV(bool TransA, double * x, double * y) const;
223  void GeneralMM(bool TransA, double ** X, int LDX, double ** Y, int LDY, int NumVectors) const;
224  void GeneralMM3RHS(bool TransA, double ** X, int LDX, double ** Y, int LDY, int NumVectors) const;
225  void GeneralMM2RHS(bool TransA, double * x, int ldx, double * y, int ldy) const;
226  void Allocate(const Epetra_RowMatrix & Matrix);
227 
235 
236 };
237 #endif /* EPETRA_JADMATRIX_H */
Epetra_MultiVector: A class for constructing and using dense multi-vectors, vectors and matrices in p...
Epetra_IntSerialDenseVector: A class for constructing and using dense vectors.
#define EPETRA_CHK_ERR(a)
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements...
Definition: Epetra_Export.h:70
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
Epetra_Import: This class builds an import object for efficient importing of off-processor elements...
Definition: Epetra_Import.h:71
virtual int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const =0
Returns a copy of the specified local row in user-provided arrays.
Epetra_JadMatrix: A class for constructing matrix objects optimized for common kernels.
Epetra_IntSerialDenseVector Indices_
int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_JadMatrix solve with a Epetra_MultiVector X in Y (not implemented)...
Epetra_SerialDenseVector: A class for constructing and using dense vectors.
virtual int NumMyRowEntries(int MyRow, int &NumEntries) const =0
Return the current number of values stored for the specified local row.
Epetra_IntSerialDenseVector Profile_
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...
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_BasicRowMatrix multiplied by a Epetra_MultiVector X in Y...
Epetra_IntSerialDenseVector IndexOffset_
Epetra_SerialDenseVector Values_
Epetra_BasicRowMatrix: A class for simplifying the development of Epetra_RowMatrix adapters...
Epetra_IntSerialDenseVector InvRowPerm_
Epetra_IntSerialDenseVector RowPerm_
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...
Epetra_RowMatrix: A pure virtual class for using real-valued double-precision row matrices...