Epetra Package Browser (Single Doxygen Collection) Development
Loading...
Searching...
No Matches
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
48#include "Epetra_Map.h"
49#include "Epetra_Comm.h"
52
53
54class Epetra_Vector;
56class Epetra_Import;
57class Epetra_Export;
58
60
68class EPETRA_LIB_DLL_EXPORT Epetra_JadMatrix: public Epetra_BasicRowMatrix {
69
70 public:
71
73
74
75 /* The constructor for this class requires a fully constructed instance of an Epetra_RowMatrix
76 object.
77 \param Matrix (In) An existing Epetra_RowMatrix.
78 \pre Matrix must have Matrix.Filled()==true.
79 */
80 Epetra_JadMatrix(const Epetra_RowMatrix & Matrix);
81
83 virtual ~Epetra_JadMatrix();
85
87
88
89 /* Updates the values only using a matrix that has exactly the same structure as
90 the matrix used to construct this Epetra_JadMatrix object. Once the constructor
91 is called, the Matrix argument is no longer needed.
92 \param Matrix (In) An existing Epetra_RowMatrix with \e identical structure to
93 the matrix used to create this Epetra_JadMatrix.
94 \param CheckStructure (In) Optional argument, by default is false. If set to true,
95 the method will check to see if the structure of Matrix is compatible with
96 the structure of matrix used to create this Epetra_JadMatrix. Performing
97 this check has signficant overhead, so it should only be turned on for debugging.
98 \pre Matrix must have Matrix.Filled()==true.
99 */
100 int UpdateValues(const Epetra_RowMatrix & Matrix, bool CheckStructure = false);
102
104
105
107
116 int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
117
119
127 int ExtractMyEntryView(int CurEntry, double * &Value, int & RowIndex, int & ColIndex) {
128 if (CurEntry>=NumMyNonzeros_) EPETRA_CHK_ERR(-1);
129 Value = &Values_[CurEntry];
130 ColIndex = Indices_[CurEntry];
131 for (int j=0; j<NumJaggedDiagonals_; j++) if (CurEntry<IndexOffset_[j+1]) {RowIndex = RowPerm_[CurEntry-IndexOffset_[j]]; break;}
132 return(0);
133 }
134
136
144 int ExtractMyEntryView(int CurEntry, double const * & Value, int & RowIndex, int & ColIndex) const {
145 if (CurEntry>=NumMyNonzeros_) EPETRA_CHK_ERR(-1);
146 Value = &Values_[CurEntry];
147 ColIndex = Indices_[CurEntry];
148 for (int j=0; j<NumJaggedDiagonals_; j++) if (CurEntry<IndexOffset_[j+1]) {RowIndex = RowPerm_[CurEntry-IndexOffset_[j]]; break;}
149 return(0);
150 }
151
153
162 int NumMyRowEntries(int MyRow, int & NumEntries) const;
163
165
167
168
170
180 int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
181
183
197 int Solve(bool Upper, bool Trans, bool UnitDiagonal,
198 const Epetra_MultiVector& X,
199 Epetra_MultiVector& Y) const
200 {
201 (void)Upper;
202 (void)Trans;
203 (void)UnitDiagonal;
204 (void)X;
205 (void)Y;
206 return(-1);
207 }
209
210
211
212 protected:
213
214 void GeneralMV(bool TransA, double * x, double * y) const;
215 void GeneralMM(bool TransA, double ** X, int LDX, double ** Y, int LDY, int NumVectors) const;
216 void GeneralMM3RHS(bool TransA, double ** X, int LDX, double ** Y, int LDY, int NumVectors) const;
217 void GeneralMM2RHS(bool TransA, double * x, int ldx, double * y, int ldy) const;
218 void Allocate(const Epetra_RowMatrix & Matrix);
219
227
228};
229#endif /* EPETRA_JADMATRIX_H */
#define EPETRA_CHK_ERR(a)
Epetra_BasicRowMatrix: A class for simplifying the development of Epetra_RowMatrix adapters.
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.
virtual int NumMyRowEntries(int MyRow, int &NumEntries) const =0
Return the current number of values stored for the specified local row.
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_Export: This class builds an export object for efficient exporting of off-processor elements.
Definition: Epetra_Export.h:62
Epetra_Import: This class builds an import object for efficient importing of off-processor elements.
Definition: Epetra_Import.h:63
Epetra_IntSerialDenseVector: A class for constructing and using dense vectors.
Epetra_JadMatrix: A class for constructing matrix objects optimized for common kernels.
Epetra_IntSerialDenseVector IndexOffset_
Epetra_IntSerialDenseVector InvRowPerm_
Epetra_IntSerialDenseVector Profile_
Epetra_IntSerialDenseVector RowPerm_
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).
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_IntSerialDenseVector Indices_
Epetra_SerialDenseVector Values_
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...
Epetra_RowMatrix: A pure virtual class for using real-valued double-precision row matrices.
Epetra_SerialDenseVector: A class for constructing and using dense vectors.
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.