EpetraExt  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
101  static int Multiply(const Epetra_CrsMatrix& A,
102  bool transposeA,
103  const Epetra_CrsMatrix& B,
104  bool transposeB,
105  Epetra_CrsMatrix& C,
106  bool call_FillComplete_on_result=true,
107  bool keep_all_hard_zeros=false);
108 
124  static int Add(const Epetra_CrsMatrix& A,
125  bool transposeA,
126  double scalarA,
127  Epetra_CrsMatrix& B,
128  double scalarB);
129 
151  static int Add(const Epetra_CrsMatrix& A,
152  bool transposeA,
153  double scalarA,
154  const Epetra_CrsMatrix & B,
155  bool transposeB,
156  double scalarB,
157  Epetra_CrsMatrix * & C);
158 
159 
185  static int Jacobi(double omega,
186  const Epetra_Vector & Dinv,
187  const Epetra_CrsMatrix& A,
188  const Epetra_CrsMatrix& B,
189  Epetra_CrsMatrix& C,
190  bool call_FillComplete_on_result=true);
191 
192  private:
193  template<typename int_type>
194  static int Tmult_A_B(const Epetra_CrsMatrix & A,
195  CrsMatrixStruct & Aview,
196  const Epetra_CrsMatrix & B,
197  CrsMatrixStruct& Bview,
198  Epetra_CrsMatrix& C,
199  bool call_FillComplete_on_result,
200  bool keep_all_hard_zeros);
201 
202  static int mult_A_B(const Epetra_CrsMatrix & A,
203  CrsMatrixStruct & Aview,
204  const Epetra_CrsMatrix & B,
205  CrsMatrixStruct& Bview,
206  Epetra_CrsMatrix& C,
207  bool call_FillComplete_on_result,
208  bool keep_all_hard_zeros);
209 
210  template<typename int_type>
211  static int Tmult_AT_B_newmatrix(const CrsMatrixStruct & Atransview,
212  const CrsMatrixStruct & Bview,
213  Epetra_CrsMatrix & C,
214  bool keep_all_hard_zeros);
215 
216  static int mult_AT_B_newmatrix(const CrsMatrixStruct & Atransview,
217  const CrsMatrixStruct & Bview,
218  Epetra_CrsMatrix & C,
219  bool keep_all_hard_zeros);
220 
221  template<typename int_type>
222  static int TMultiply(const Epetra_CrsMatrix& A,
223  bool transposeA,
224  const Epetra_CrsMatrix& B,
225  bool transposeB,
226  Epetra_CrsMatrix& C,
227  bool call_FillComplete_on_result,
228  bool keep_all_hard_zeros);
229 
230  template<typename int_type>
231  static int TAdd(const Epetra_CrsMatrix& A,
232  bool transposeA,
233  double scalarA,
234  Epetra_CrsMatrix& B,
235  double scalarB);
236 
237  template<typename int_type>
238  static int TAdd(const Epetra_CrsMatrix& A,
239  bool transposeA,
240  double scalarA,
241  const Epetra_CrsMatrix & B,
242  bool transposeB,
243  double scalarB,
244  Epetra_CrsMatrix * & C);
245 
246  template<typename int_type>
247  static int Tjacobi_A_B(double omega,
248  const Epetra_Vector & Dinv,
249  const Epetra_CrsMatrix & A,
250  CrsMatrixStruct & Aview,
251  const Epetra_CrsMatrix & B,
252  CrsMatrixStruct& Bview,
253  Epetra_CrsMatrix& C,
254  bool call_FillComplete_on_result);
255 
256  static int jacobi_A_B(double omega,
257  const Epetra_Vector & Dinv,
258  const Epetra_CrsMatrix & A,
259  CrsMatrixStruct & Aview,
260  const Epetra_CrsMatrix & B,
261  CrsMatrixStruct& Bview,
262  Epetra_CrsMatrix& C,
263  bool call_FillComplete_on_result);
264 
265  template<typename int_type>
266  static int TJacobi(double omega,
267  const Epetra_Vector & Dinv,
268  const Epetra_CrsMatrix& A,
269  const Epetra_CrsMatrix& B,
270  Epetra_CrsMatrix& C,
271  bool call_FillComplete_on_result);
272 
273 
274 };//class MatrixMatrix
275 
276 
282  template<typename int_type>
283  double sparsedot(double* u, int_type* u_ind, int u_len,
284  double* v, int_type* v_ind, int v_len);
285 }//namespace EpetraExt
286 
287 #endif
288 
static int Multiply(const Epetra_CrsMatrix &A, bool transposeA, const Epetra_CrsMatrix &B, bool transposeB, Epetra_CrsMatrix &C, bool call_FillComplete_on_result=true, bool keep_all_hard_zeros=false)
Given Epetra_CrsMatrix objects A, B and C, form the product C = A*B.
virtual ~MatrixMatrix()
destructor
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...