EpetraExt  Development
EpetraExt_MatrixMatrix.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 #ifndef EPETRAEXT_MATRIXMATRIX_H
42 #define EPETRAEXT_MATRIXMATRIX_H
43 
44 #include <EpetraExt_ConfigDefs.h>
45 
46 class Epetra_CrsMatrix;
47 class Epetra_Map;
48 class Epetra_Vector;
49 
50 #ifdef HAVE_VECTOR
51 #include <vector>
52 #endif
53 
54 namespace EpetraExt {
55  class CrsMatrixStruct;
56 
57 
63 class MatrixMatrix {
64 
65  public:
67  virtual ~MatrixMatrix(){}
68 
94  static int Multiply(const Epetra_CrsMatrix& A,
95  bool transposeA,
96  const Epetra_CrsMatrix& B,
97  bool transposeB,
98  Epetra_CrsMatrix& C,
99  bool call_FillComplete_on_result=true);
100 
116  static int Add(const Epetra_CrsMatrix& A,
117  bool transposeA,
118  double scalarA,
119  Epetra_CrsMatrix& B,
120  double scalarB);
121 
143  static int Add(const Epetra_CrsMatrix& A,
144  bool transposeA,
145  double scalarA,
146  const Epetra_CrsMatrix & B,
147  bool transposeB,
148  double scalarB,
149  Epetra_CrsMatrix * & C);
150 
151 
177  static int Jacobi(double omega,
178  const Epetra_Vector & Dinv,
179  const Epetra_CrsMatrix& A,
180  const Epetra_CrsMatrix& B,
181  Epetra_CrsMatrix& C,
182  bool call_FillComplete_on_result=true);
183 
184  private:
185  template<typename int_type>
186  static int Tmult_A_B(const Epetra_CrsMatrix & A,
187  CrsMatrixStruct & Aview,
188  const Epetra_CrsMatrix & B,
189  CrsMatrixStruct& Bview,
190  Epetra_CrsMatrix& C,
191  bool call_FillComplete_on_result);
192 
193  static int mult_A_B(const Epetra_CrsMatrix & A,
194  CrsMatrixStruct & Aview,
195  const Epetra_CrsMatrix & B,
196  CrsMatrixStruct& Bview,
197  Epetra_CrsMatrix& C,
198  bool call_FillComplete_on_result);
199 
200  template<typename int_type>
201  static int Tmult_AT_B_newmatrix(const CrsMatrixStruct & Atransview,
202  const CrsMatrixStruct & Bview,
203  Epetra_CrsMatrix & C);
204 
205  static int mult_AT_B_newmatrix(const CrsMatrixStruct & Atransview,
206  const CrsMatrixStruct & Bview,
207  Epetra_CrsMatrix & C);
208 
209  template<typename int_type>
210  static int TMultiply(const Epetra_CrsMatrix& A,
211  bool transposeA,
212  const Epetra_CrsMatrix& B,
213  bool transposeB,
214  Epetra_CrsMatrix& C,
215  bool call_FillComplete_on_result);
216 
217  template<typename int_type>
218  static int TAdd(const Epetra_CrsMatrix& A,
219  bool transposeA,
220  double scalarA,
221  Epetra_CrsMatrix& B,
222  double scalarB);
223 
224  template<typename int_type>
225  static int TAdd(const Epetra_CrsMatrix& A,
226  bool transposeA,
227  double scalarA,
228  const Epetra_CrsMatrix & B,
229  bool transposeB,
230  double scalarB,
231  Epetra_CrsMatrix * & C);
232 
233  template<typename int_type>
234  static int Tjacobi_A_B(double omega,
235  const Epetra_Vector & Dinv,
236  const Epetra_CrsMatrix & A,
237  CrsMatrixStruct & Aview,
238  const Epetra_CrsMatrix & B,
239  CrsMatrixStruct& Bview,
240  Epetra_CrsMatrix& C,
241  bool call_FillComplete_on_result);
242 
243  static int jacobi_A_B(double omega,
244  const Epetra_Vector & Dinv,
245  const Epetra_CrsMatrix & A,
246  CrsMatrixStruct & Aview,
247  const Epetra_CrsMatrix & B,
248  CrsMatrixStruct& Bview,
249  Epetra_CrsMatrix& C,
250  bool call_FillComplete_on_result);
251 
252  template<typename int_type>
253  static int TJacobi(double omega,
254  const Epetra_Vector & Dinv,
255  const Epetra_CrsMatrix& A,
256  const Epetra_CrsMatrix& B,
257  Epetra_CrsMatrix& C,
258  bool call_FillComplete_on_result);
259 
260 
261 };//class MatrixMatrix
262 
263 
269  template<typename int_type>
270  double sparsedot(double* u, int_type* u_ind, int u_len,
271  double* v, int_type* v_ind, int v_len);
272 }//namespace EpetraExt
273 
274 #endif
275 
static int Multiply(const Epetra_CrsMatrix &A, bool transposeA, const Epetra_CrsMatrix &B, bool transposeB, Epetra_CrsMatrix &C, bool call_FillComplete_on_result=true)
Given Epetra_CrsMatrix objects A, B and C, form the product C = A*B.
virtual ~MatrixMatrix()
destructor
EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.
Collection of matrix-matrix operations.
static int Add(const Epetra_CrsMatrix &A, bool transposeA, double scalarA, Epetra_CrsMatrix &B, double scalarB)
Given Epetra_CrsMatrix objects A and B, form the sum B = a*A + b*B.
double sparsedot(double *u, int_type *u_ind, int u_len, double *v, int_type *v_ind, int v_len)
Method for internal use...
static int Jacobi(double omega, const Epetra_Vector &Dinv, const Epetra_CrsMatrix &A, const Epetra_CrsMatrix &B, Epetra_CrsMatrix &C, bool call_FillComplete_on_result=true)
Given Epetra_CrsMatrix objects A, B and C, and Epetra_Vector Dinv, form the product C = (I-omega * Di...