Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TpetraExt_TripleMatrixMultiply_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Tpetra: Templated Linear Algebra Services Package
5 // Copyright (2008) 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 
42 #ifndef TPETRA_TRIPLEMATRIXMULTIPLY_DECL_HPP
43 #define TPETRA_TRIPLEMATRIXMULTIPLY_DECL_HPP
44 
45 #include <string>
46 #include <Teuchos_RCP.hpp>
47 #include <Teuchos_Array.hpp>
48 #include "Tpetra_ConfigDefs.hpp"
49 #include "Tpetra_CrsMatrix.hpp"
50 #include "Tpetra_Vector.hpp"
51 #include "TpetraExt_MMHelpers.hpp"
52 
53 
59 namespace Tpetra {
60 
61  namespace TripleMatrixMultiply {
62 
95  template <class Scalar,
96  class LocalOrdinal,
97  class GlobalOrdinal,
98  class Node>
99  void MultiplyRAP(
100  const CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& R,
101  bool transposeR,
102  const CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
103  bool transposeA,
104  const CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& P,
105  bool transposeP,
106  CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Ac,
107  bool call_FillComplete_on_result = true,
108  const std::string& label = std::string(),
109  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
110 
111 
112  } // namespace TripleMatrixMultiply
113 
114  namespace MMdetails{
115 
116  template<class Scalar,
117  class LocalOrdinal,
118  class GlobalOrdinal,
119  class Node>
120  void mult_R_A_P_newmatrix(
121  CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Rview,
122  CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Aview,
123  CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Pview,
124  CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Ac,
125  const std::string& label = std::string(),
126  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
127 
128  template<class Scalar,
129  class LocalOrdinal,
130  class GlobalOrdinal,
131  class Node>
132  void mult_R_A_P_reuse(
133  CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Rview,
134  CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Aview,
135  CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Pview,
136  CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Ac,
137  const std::string& label = std::string(),
138  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
139 
140  template<class Scalar,
141  class LocalOrdinal,
142  class GlobalOrdinal,
143  class Node>
144  void mult_PT_A_P_newmatrix(
145  CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Aview,
146  CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Pview,
147  CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Ac,
148  const std::string& label = std::string(),
149  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
150 
151  template<class Scalar,
152  class LocalOrdinal,
153  class GlobalOrdinal,
154  class Node>
155  void mult_PT_A_P_reuse(
156  CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Aview,
157  CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Pview,
158  CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Ac,
159  const std::string& label = std::string(),
160  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
161 
162 
163 
164  // Kernel wrappers struct (for non-specialized kernels)
165  // Because C++ doesn't support partial template specialization of functions.
166  template<class Scalar,
167  class LocalOrdinal,
168  class GlobalOrdinal,
169  class Node>
170  struct KernelWrappers3MMM {
171 
172  static inline void mult_PT_A_P_newmatrix_kernel_wrapper_2pass(CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Aview,
173  CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Pview,
174  const Teuchos::Array<LocalOrdinal> & Acol2PRow,
175  const Teuchos::Array<LocalOrdinal> & Acol2PRowImport,
176  const Teuchos::Array<LocalOrdinal> & Pcol2Accol,
177  const Teuchos::Array<LocalOrdinal> & PIcol2Accol,
178  CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Ac,
179  Teuchos::RCP<const Import<LocalOrdinal,GlobalOrdinal,Node> > Acimport,
180  const std::string& label = std::string(),
181  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
182  };
183 
184  }//end namespace MMdetails
185 
186 } // end of Tpetra namespace
187 
188 #endif // TPETRA_TRIPLEMATRIXMULTIPLY_DECL_HPP
void MultiplyRAP(const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R, bool transposeR, const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, bool transposeA, const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &P, bool transposeP, CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Ac, bool call_FillComplete_on_result=true, const std::string &label=std::string(), const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Sparse matrix-matrix multiply.