217 const Matrix& A,
bool transposeA,
218 const Matrix& P,
bool transposeP,
220 bool call_FillComplete_on_result =
true,
221 bool doOptimizeStorage =
true,
222 const std::string& label = std::string(),
225 Exceptions::RuntimeError,
"XpetraExt::TripleMatrixMultiply::MultiplyRAP: row map of Ac is not same as row map of R");
227 Exceptions::RuntimeError,
"XpetraExt::TripleMatrixMultiply::MultiplyRAP: row map of Ac is not same as domain map of R");
233 bool haveMultiplyDoFillComplete = call_FillComplete_on_result && doOptimizeStorage;
238#ifdef HAVE_XPETRA_TPETRA
239#if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || \
240 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
243 using helpers = Xpetra::Helpers<SC, LO, GO, NO>;
244 if (helpers::isTpetraCrs(R) && helpers::isTpetraCrs(A) && helpers::isTpetraCrs(P)) {
246 const Tpetra::CrsMatrix<SC, LO, GO, NO>& tpR = Xpetra::Helpers<SC, LO, GO, NO>::Op2TpetraCrs(R);
247 const Tpetra::CrsMatrix<SC, LO, GO, NO>& tpA = Xpetra::Helpers<SC, LO, GO, NO>::Op2TpetraCrs(A);
248 const Tpetra::CrsMatrix<SC, LO, GO, NO>& tpP = Xpetra::Helpers<SC, LO, GO, NO>::Op2TpetraCrs(P);
249 Tpetra::CrsMatrix<SC, LO, GO, NO>& tpAc = Xpetra::Helpers<SC, LO, GO, NO>::Op2NonConstTpetraCrs(Ac);
253 Tpetra::TripleMatrixMultiply::MultiplyRAP(tpR, transposeR, tpA, transposeA, tpP, transposeP, tpAc, haveMultiplyDoFillComplete, label, params);
254 }
else if (helpers::isTpetraBlockCrs(R) && helpers::isTpetraBlockCrs(A) && helpers::isTpetraBlockCrs(P)) {
258 if (!A.
getRowMap()->getComm()->getRank())
259 std::cout <<
"WARNING: Using inefficient BlockCrs Multiply Placeholder" << std::endl;
261 const Tpetra::BlockCrsMatrix<SC, LO, GO, NO>& tpR = Xpetra::Helpers<SC, LO, GO, NO>::Op2TpetraBlockCrs(R);
262 const Tpetra::BlockCrsMatrix<SC, LO, GO, NO>& tpA = Xpetra::Helpers<SC, LO, GO, NO>::Op2TpetraBlockCrs(A);
263 const Tpetra::BlockCrsMatrix<SC, LO, GO, NO>& tpP = Xpetra::Helpers<SC, LO, GO, NO>::Op2TpetraBlockCrs(P);
266 using CRS = Tpetra::CrsMatrix<SC, LO, GO, NO>;
274 const bool do_fill_complete =
true;
275 Tpetra::TripleMatrixMultiply::MultiplyRAP(*Rcrs, transposeR, *Acrs, transposeA, *Pcrs, transposeP, *Accrs, do_fill_complete, label, params);
284 Ac_w->replaceCrsMatrix(Ac_p);
292 throw(Xpetra::Exceptions::RuntimeError(
"Xpetra must be compiled with Tpetra."));
294 if (call_FillComplete_on_result && !haveMultiplyDoFillComplete) {
295 RCP<Teuchos::ParameterList> fillParams =
rcp(
new Teuchos::ParameterList());
296 fillParams->set(
"Optimize Storage", doOptimizeStorage);
303 RCP<const Map> domainMap = Teuchos::null;
304 RCP<const Map> rangeMap = Teuchos::null;
306 const std::string stridedViewLabel(
"stridedMaps");
307 const size_t blkSize = 1;
308 std::vector<size_t> stridingInfo(1, blkSize);
309 LocalOrdinal stridedBlockId = -1;
311 if (R.
IsView(stridedViewLabel)) {
312 rangeMap = transposeR ? R.
getColMap(stridedViewLabel) : R.
getRowMap(stridedViewLabel);
318 if (P.
IsView(stridedViewLabel)) {
319 domainMap = transposeP ? P.
getRowMap(stridedViewLabel) : P.
getColMap(stridedViewLabel);
324 Ac.
CreateView(stridedViewLabel, rangeMap, domainMap);