48 #ifndef PACKAGES_XPETRA_SUP_UTILS_XPETRA_MATRIXMATRIX_HPP_ 49 #define PACKAGES_XPETRA_SUP_UTILS_XPETRA_MATRIXMATRIX_HPP_ 63 #ifdef HAVE_XPETRA_EPETRA 67 #ifdef HAVE_XPETRA_EPETRAEXT 68 #include <EpetraExt_MatrixMatrix.h> 69 #include <EpetraExt_RowMatrixOut.h> 70 #include <Epetra_RowMatrixTransposer.h> 71 #endif // HAVE_XPETRA_EPETRAEXT 73 #ifdef HAVE_XPETRA_TPETRA 74 #include <TpetraExt_MatrixMatrix.hpp> 75 #include <MatrixMarket_Tpetra.hpp> 79 #endif // HAVE_XPETRA_TPETRA 89 template <
class Scalar,
90 class LocalOrdinal = int,
91 class GlobalOrdinal = LocalOrdinal,
98 #ifdef HAVE_XPETRA_EPETRA 103 if (crsOp == Teuchos::null)
107 if (tmp_ECrsMtx == Teuchos::null)
109 A = tmp_ECrsMtx->getEpetra_CrsMatrix();
117 if (crsOp == Teuchos::null)
121 if (tmp_ECrsMtx == Teuchos::null)
123 A = tmp_ECrsMtx->getEpetra_CrsMatrixNonConst();
134 if (tmp_ECrsMtx == Teuchos::null)
136 A = tmp_ECrsMtx->getEpetra_CrsMatrix();
150 if (tmp_ECrsMtx == Teuchos::null)
152 A = Teuchos::rcp_const_cast<Epetra_CrsMatrix>(tmp_ECrsMtx->getEpetra_CrsMatrix());
158 #endif // HAVE_XPETRA_EPETRA 160 #ifdef HAVE_XPETRA_TPETRA 165 if (crsOp == Teuchos::null)
169 if (tmp_ECrsMtx == Teuchos::null)
171 A = tmp_ECrsMtx->getTpetra_CrsMatrix();
179 if (crsOp == Teuchos::null)
183 if (tmp_ECrsMtx == Teuchos::null)
185 A = tmp_ECrsMtx->getTpetra_CrsMatrixNonConst();
196 if (tmp_TCrsMtx == Teuchos::null)
198 A = tmp_TCrsMtx->getTpetra_CrsMatrix();
212 if (tmp_TCrsMtx == Teuchos::null)
214 A = Teuchos::rcp_const_cast<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >(tmp_TCrsMtx->getTpetra_CrsMatrix());
221 #endif // HAVE_XPETRA_TPETRA 225 template <
class Scalar,
227 class GlobalOrdinal ,
230 #undef XPETRA_MATRIXMATRIX_SHORT 265 bool call_FillComplete_on_result =
true,
266 bool doOptimizeStorage =
true,
267 const std::string & label = std::string()) {
270 std::string msg =
"XpetraExt::MatrixMatrix::Multiply: row map of C is not same as row map of A";
274 std::string msg =
"XpetraExt::MatrixMatrix::Multiply: row map of C is not same as domain map of A";
284 bool haveMultiplyDoFillComplete = call_FillComplete_on_result && doOptimizeStorage;
287 #if defined(HAVE_XPETRA_EPETRA) && defined(HAVE_XPETRA_EPETRAEXT) 292 int i = EpetraExt::MatrixMatrix::Multiply(epA,transposeA,epB,transposeB,epC,haveMultiplyDoFillComplete);
293 if (haveMultiplyDoFillComplete) {
304 std::ostringstream buf;
306 std::string msg =
"EpetraExt::MatrixMatrix::Multiply return value of " + buf.str();
314 #ifdef HAVE_XPETRA_TPETRA 321 Tpetra::MatrixMatrix::Multiply(tpA,transposeA,tpB,transposeB,tpC,haveMultiplyDoFillComplete,label);
327 if(call_FillComplete_on_result && !haveMultiplyDoFillComplete) {
329 params->
set(
"Optimize Storage",doOptimizeStorage);
338 C.
CreateView(
"stridedMaps", rcpA, transposeA, rcpB, transposeB);
364 const Matrix& B,
bool transposeB,
367 bool doFillComplete =
true,
368 bool doOptimizeStorage =
true,
369 const std::string & label = std::string()) {
377 if (C == Teuchos::null) {
378 double nnzPerRow = Teuchos::as<double>(0);
386 nnzPerRow *= nnzPerRow;
389 if (totalNnz < minNnz)
393 fos <<
"Matrix product nnz per row estimate = " << Teuchos::as<LO>(nnzPerRow) << std::endl;
401 fos <<
"Reuse C pattern" << std::endl;
404 Multiply(A, transposeA, B, transposeB, *C, doFillComplete, doOptimizeStorage,label);
424 bool callFillCompleteOnResult =
true,
425 bool doOptimizeStorage =
true,
426 const std::string & label = std::string()){
427 return Multiply(A, transposeA, B, transposeB, Teuchos::null, fos, callFillCompleteOnResult, doOptimizeStorage,label);
430 #ifdef HAVE_XPETRA_EPETRAEXT 433 const Epetra_CrsMatrix& epB,
436 return Teuchos::null;
438 #endif //ifdef HAVE_XPETRA_EPETRAEXT 453 bool doFillComplete =
true,
454 bool doOptimizeStorage =
true) {
455 if (transposeA || transposeB)
456 throw Exceptions::RuntimeError(
"TwoMatrixMultiply for BlockedCrsMatrix not implemented for transposeA==true or transposeB==true");
469 for (
size_t i = 0; i < A.
Rows(); ++i) {
470 for (
size_t j = 0; j < B.
Cols(); ++j) {
473 for (
size_t l = 0; l < B.
Rows(); ++l) {
484 RCP<Matrix> temp = Multiply (*crop1,
false, *crop2,
false, fos);
490 Xpetra::MatrixMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::TwoMatrixAdd (*temp,
false, 1.0, *Cij,
false, 1.0, addRes, fos);
496 if (Cij->isFillComplete())
502 "MatrixFactory failed in generating a CrsMatrixWrap." );
506 C->setMatrix(i, j, crsMatCij);
509 C->setMatrix(i, j, Teuchos::null);
537 throw Exceptions::RuntimeError(
"TwoMatrixAdd for Epetra matrices needs <double,int,int> for Scalar, LocalOrdinal and GlobalOrdinal.");
539 #ifdef HAVE_XPETRA_TPETRA 543 Tpetra::MatrixMatrix::Add(tpA, transposeA, alpha, tpB, beta);
564 const Matrix& B,
bool transposeB,
const SC& beta,
569 if (C == Teuchos::null) {
577 if (maxNzInA == 1 || maxNzInB == 1 || AHasFixedNnzPerRow) {
582 if ((maxNzInA == 1 && maxNzInB > 1) || AHasFixedNnzPerRow) {
583 for (
size_t i = 0; i < numLocalRows; ++i)
587 for (
size_t i = 0; i < numLocalRows; ++i)
591 fos <<
"MatrixMatrix::TwoMatrixAdd : special case detected (one matrix has a fixed nnz per row)" 592 <<
", using static profiling" << std::endl;
599 LO nnzToAllocate = Teuchos::as<LO>( (nnzPerRowInA + nnzPerRowInB) * 1.5) + Teuchos::as<LO>(1);
606 fos <<
"nnzPerRowInA = " << nnzPerRowInA <<
", nnzPerRowInB = " << nnzPerRowInB << std::endl;
607 fos <<
"MatrixMatrix::TwoMatrixAdd : space allocated per row = " << nnzToAllocate
608 <<
", max possible nnz per row in sum = " << maxPossible
614 fos <<
"MatrixMatrix::TwoMatrixAdd : ** WARNING ** estimate could be badly wrong because second summand is transposed" << std::endl;
620 #ifdef HAVE_XPETRA_TPETRA 621 const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& tpA =
623 const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& tpB =
628 Tpetra::MatrixMatrix::Add(tpA, transposeA, alpha, tpB, transposeB, beta, tpC);
635 if (A.
IsView(
"stridedMaps")) C->CreateView(
"stridedMaps", rcpFromRef(A));
636 if (B.
IsView(
"stridedMaps")) C->CreateView(
"stridedMaps", rcpFromRef(B));
645 #ifdef HAVE_XPETRA_EPETRA 690 bool call_FillComplete_on_result =
true,
691 bool doOptimizeStorage =
true,
692 const std::string & label = std::string()) {
694 std::string msg =
"XpetraExt::MatrixMatrix::Multiply: row map of C is not same as row map of A";
698 std::string msg =
"XpetraExt::MatrixMatrix::Multiply: row map of C is not same as domain map of A";
708 bool haveMultiplyDoFillComplete = call_FillComplete_on_result && doOptimizeStorage;
711 #if defined(HAVE_XPETRA_EPETRA) && defined(HAVE_XPETRA_EPETRAEXT) 716 int i = EpetraExt::MatrixMatrix::Multiply(epA,transposeA,epB,transposeB,epC,haveMultiplyDoFillComplete);
717 if (haveMultiplyDoFillComplete) {
728 std::ostringstream buf;
730 std::string msg =
"EpetraExt::MatrixMatrix::Multiply return value of " + buf.str();
738 #ifdef HAVE_XPETRA_TPETRA 739 # if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \ 740 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT)))) 749 Tpetra::MatrixMatrix::Multiply(tpA,transposeA,tpB,transposeB,tpC,haveMultiplyDoFillComplete,label);
756 if(call_FillComplete_on_result && !haveMultiplyDoFillComplete) {
758 params->
set(
"Optimize Storage",doOptimizeStorage);
767 C.
CreateView(
"stridedMaps", rcpA, transposeA, rcpB, transposeB);
793 const Matrix& B,
bool transposeB,
796 bool doFillComplete =
true,
797 bool doOptimizeStorage =
true,
798 const std::string & label = std::string()) {
805 #if defined(HAVE_XPETRA_EPETRA) && defined(HAVE_XPETRA_EPETRAEXT) && defined(HAVE_XPETRA_ML_MMM) 811 RCP<Matrix> C = Convert_Epetra_CrsMatrix_ToXpetra_CrsMatrixWrap<SC,LO,GO,NO> (epC);
812 if (doFillComplete) {
814 params->
set(
"Optimize Storage", doOptimizeStorage);
821 C->CreateView(
"stridedMaps", rcpFromRef(A), transposeA, rcpFromRef(B), transposeB);
825 #endif // EPETRA + EPETRAEXT + ML 830 if (C == Teuchos::null) {
831 double nnzPerRow = Teuchos::as<double>(0);
839 nnzPerRow *= nnzPerRow;
842 if (totalNnz < minNnz)
846 fos <<
"Matrix product nnz per row estimate = " << Teuchos::as<LO>(nnzPerRow) << std::endl;
854 fos <<
"Reuse C pattern" << std::endl;
857 Multiply(A, transposeA, B, transposeB, *C, doFillComplete, doOptimizeStorage,label);
877 bool callFillCompleteOnResult =
true,
878 bool doOptimizeStorage =
true,
879 const std::string & label = std::string()){
880 return Multiply(A, transposeA, B, transposeB, Teuchos::null, fos, callFillCompleteOnResult, doOptimizeStorage,label);
883 #if defined(HAVE_XPETRA_EPETRA) && defined(HAVE_XPETRA_EPETRAEXT) 886 const Epetra_CrsMatrix& epB,
888 #if defined(HAVE_XPETRA_ML_MMM) // Note: this is currently not supported 890 ML_Comm_Create(&comm);
891 fos <<
"****** USING ML's MATRIX MATRIX MULTIPLY ******" << std::endl;
894 const Epetra_MpiComm * Mcomm =
dynamic_cast<const Epetra_MpiComm*
>(&(epA.Comm()));
896 ML_Comm_Set_UsrComm(comm,Mcomm->GetMpiComm());
899 EpetraExt::CrsMatrix_SolverMap Atransform;
900 EpetraExt::CrsMatrix_SolverMap Btransform;
901 const Epetra_CrsMatrix& A = Atransform(const_cast<Epetra_CrsMatrix&>(epA));
902 const Epetra_CrsMatrix& B = Btransform(const_cast<Epetra_CrsMatrix&>(epB));
908 ML_Operator* ml_As = ML_Operator_Create(comm);
909 ML_Operator* ml_Bs = ML_Operator_Create(comm);
910 ML_Operator_WrapEpetraCrsMatrix(const_cast<Epetra_CrsMatrix*>(&A),ml_As);
911 ML_Operator_WrapEpetraCrsMatrix(const_cast<Epetra_CrsMatrix*>(&B),ml_Bs);
912 ML_Operator* ml_AtimesB = ML_Operator_Create(comm);
915 ML_2matmult(ml_As,ml_Bs,ml_AtimesB,ML_CSR_MATRIX);
917 ML_Operator_Destroy(&ml_As);
918 ML_Operator_Destroy(&ml_Bs);
923 int N_local = ml_AtimesB->invec_leng;
924 ML_CommInfoOP* getrow_comm = ml_AtimesB->getrow->pre_comm;
926 ML_Comm* comm_AB = ml_AtimesB->comm;
927 if (N_local != B.DomainMap().NumMyElements())
932 for (
int i = 0; i < getrow_comm->N_neighbors; i++) {
933 N_rcvd += (getrow_comm->neighbors)[i].N_rcv;
934 N_send += (getrow_comm->neighbors)[i].N_send;
935 if ( ((getrow_comm->neighbors)[i].N_rcv != 0) &&
936 ((getrow_comm->neighbors)[i].rcv_list != NULL) ) flag = 1;
940 std::vector<double> dtemp(N_local + N_rcvd + 1);
941 std::vector<int> cmap (N_local + N_rcvd + 1);
942 for (
int i = 0; i < N_local; ++i) {
943 cmap[i] = B.DomainMap().GID(i);
944 dtemp[i] = (double) cmap[i];
946 ML_cheap_exchange_bdry(&dtemp[0],getrow_comm,N_local,N_send,comm_AB);
949 const int neighbors = getrow_comm->N_neighbors;
950 for (
int i = 0; i < neighbors; i++) {
951 const int nrcv = getrow_comm->neighbors[i].N_rcv;
952 for (
int j = 0; j < nrcv; j++)
953 cmap[getrow_comm->neighbors[i].rcv_list[j]] = (
int) dtemp[count++];
956 for (
int i = 0; i < N_local+N_rcvd; ++i)
957 cmap[i] = (
int)dtemp[i];
962 Epetra_Map gcmap(-1, N_local+N_rcvd, &cmap[0], B.ColMap().IndexBase(), A.Comm());
969 const int myrowlength = A.RowMap().NumMyElements();
970 const Epetra_Map& rowmap = A.RowMap();
975 int educatedguess = 0;
976 for (
int i = 0; i < myrowlength; ++i) {
978 ML_get_matrix_row(ml_AtimesB, 1, &i, &allocated, &bindx, &val, &rowlength, 0);
979 if (rowlength>educatedguess)
980 educatedguess = rowlength;
986 std::vector<int> gcid(educatedguess);
987 for (
int i = 0; i < myrowlength; ++i) {
988 const int grid = rowmap.GID(i);
990 ML_get_matrix_row(ml_AtimesB, 1, &i, &allocated, &bindx, &val, &rowlength, 0);
991 if (!rowlength)
continue;
992 if ((
int)gcid.size() < rowlength) gcid.resize(rowlength);
993 for (
int j = 0; j < rowlength; ++j) {
994 gcid[j] = gcmap.GID(bindx[j]);
998 int err = result->InsertGlobalValues(grid, rowlength, val, &gcid[0]);
999 if (err != 0 && err != 1) {
1000 std::ostringstream errStr;
1001 errStr <<
"Epetra_CrsMatrix::InsertGlobalValues returned err=" << err;
1006 if (bindx) ML_free(bindx);
1007 if (val) ML_free(val);
1008 ML_Operator_Destroy(&ml_AtimesB);
1009 ML_Comm_Destroy(&comm);
1012 #else // no MUELU_ML 1014 "No ML multiplication available. This feature is currently not supported by Xpetra.");
1015 return Teuchos::null;
1018 #endif //ifdef HAVE_XPETRA_EPETRAEXT 1033 bool doFillComplete =
true,
1034 bool doOptimizeStorage =
true) {
1035 if (transposeA || transposeB)
1036 throw Exceptions::RuntimeError(
"TwoMatrixMultiply for BlockedCrsMatrix not implemented for transposeA==true or transposeB==true");
1050 for (
size_t i = 0; i < A.
Rows(); ++i) {
1051 for (
size_t j = 0; j < B.
Cols(); ++j) {
1054 for (
size_t l = 0; l < B.
Rows(); ++l) {
1071 Xpetra::MatrixMatrix<SC,LO,GO,NO>::TwoMatrixAdd (*temp,
false, 1.0, *Cij,
false, 1.0, addRes, fos);
1077 if (Cij->isFillComplete())
1083 "MatrixFactory failed in generating a CrsMatrixWrap." );
1087 C->setMatrix(i, j, crsMatCij);
1090 C->setMatrix(i, j, Teuchos::null);
1113 static void TwoMatrixAdd(
const Xpetra::Matrix<SC,LO,GO,NO>& A,
bool transposeA, SC alpha,
Xpetra::Matrix<SC,LO,GO,NO>& B, SC beta) {
1118 #if defined(HAVE_XPETRA_EPETRA) && defined(HAVE_XPETRA_EPETRAEXT) 1123 int rv = EpetraExt::MatrixMatrix::Add(epA, transposeA, alpha, epB, beta);
1127 std::ostringstream buf;
1132 #ifdef HAVE_XPETRA_TPETRA 1133 # if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \ 1134 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT)))) 1140 Tpetra::MatrixMatrix::Add(tpA, transposeA, alpha, tpB, beta);
1167 if (C == Teuchos::null) {
1175 if (maxNzInA == 1 || maxNzInB == 1 || AHasFixedNnzPerRow) {
1180 if ((maxNzInA == 1 && maxNzInB > 1) || AHasFixedNnzPerRow) {
1181 for (
size_t i = 0; i < numLocalRows; ++i)
1185 for (
size_t i = 0; i < numLocalRows; ++i)
1189 fos <<
"MatrixMatrix::TwoMatrixAdd : special case detected (one matrix has a fixed nnz per row)" 1190 <<
", using static profiling" << std::endl;
1197 LO nnzToAllocate = Teuchos::as<LO>( (nnzPerRowInA + nnzPerRowInB) * 1.5) + Teuchos::as<LO>(1);
1204 fos <<
"nnzPerRowInA = " << nnzPerRowInA <<
", nnzPerRowInB = " << nnzPerRowInB << std::endl;
1205 fos <<
"MatrixMatrix::TwoMatrixAdd : space allocated per row = " << nnzToAllocate
1206 <<
", max possible nnz per row in sum = " << maxPossible
1212 fos <<
"MatrixMatrix::TwoMatrixAdd : ** WARNING ** estimate could be badly wrong because second summand is transposed" << std::endl;
1216 #if defined(HAVE_XPETRA_EPETRA) && defined(HAVE_XPETRA_EPETRAEXT) 1220 Epetra_CrsMatrix* ref2epC = &*epC;
1223 int rv = EpetraExt::MatrixMatrix::Add(epA, transposeA, alpha, epB, transposeB, beta, ref2epC);
1231 #ifdef HAVE_XPETRA_TPETRA 1232 # if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \ 1233 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT)))) 1236 const Tpetra::CrsMatrix<SC,LO,GO,NO>& tpA =
1238 const Tpetra::CrsMatrix<SC,LO,GO,NO>& tpB =
1243 Tpetra::MatrixMatrix::Add(tpA, transposeA, alpha, tpB, transposeB, beta, tpC);
1257 #endif // HAVE_XPETRA_EPETRA 1261 #define XPETRA_MATRIXMATRIX_SHORT virtual size_t getNodeNumRows() const =0
Returns the number of matrix rows owned on the calling node.
Xpetra::MultiVector< double, int, int, NO > MultiVector
RCP< const MapExtractor > getRangeMapExtractor()
Returns map extractor class for range map.
static void TwoMatrixAdd(const Matrix &A, bool transposeA, const SC &alpha, const Matrix &B, bool transposeB, const SC &beta, RCP< Matrix > &C, Teuchos::FancyOStream &fos, bool AHasFixedNnzPerRow=false)
Helper function to calculate C = alpha*A + beta*B.
static void Multiply(const Xpetra::Matrix< SC, LO, GO, NO > &A, bool transposeA, const Xpetra::Matrix< SC, LO, GO, NO > &B, bool transposeB, Xpetra::Matrix< SC, LO, GO, NO > &C, bool call_FillComplete_on_result=true, bool doOptimizeStorage=true, const std::string &label=std::string())
RCP< CrsMatrix > getCrsMatrix() const
virtual global_size_t getGlobalNumRows() const =0
Returns the number of global rows in this matrix.
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Multiply(const Matrix &A, bool transposeA, const Matrix &B, bool transposeB, Teuchos::FancyOStream &fos, bool callFillCompleteOnResult=true, bool doOptimizeStorage=true, const std::string &label=std::string())
Helper function to do matrix-matrix multiply.
bool isFillComplete() const
Returns true if fillComplete() has been called and the matrix is in compute mode. ...
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
static const Epetra_CrsMatrix & Op2EpetraCrs(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op)
RCP< const Map > getRangeMap() const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Xpetra utility class containing transformation routines between Xpetra::Matrix and Epetra/Tpetra obje...
Teuchos::RCP< CrsMatrix > getMatrix(size_t r, size_t c) const
return block (r,c)
static Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > & Op2NonConstTpetraCrs(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op)
Exception throws to report errors in the internal logical of the program.
virtual size_t getGlobalMaxNumRowEntries() const =0
Returns the maximum number of entries across all rows/columns on all nodes.
static void Multiply(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, bool transposeA, const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, bool transposeB, Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &C, bool call_FillComplete_on_result=true, bool doOptimizeStorage=true, const std::string &label=std::string())
static RCP< Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2NonConstTpetraCrs(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op)
static Epetra_CrsMatrix & Op2NonConstEpetraCrs(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op)
static RCP< Xpetra::Matrix< SC, LO, GO, NO > > Multiply(const Matrix &A, bool transposeA, const Matrix &B, bool transposeB, Teuchos::FancyOStream &fos, bool callFillCompleteOnResult=true, bool doOptimizeStorage=true, const std::string &label=std::string())
Helper function to do matrix-matrix multiply.
static RCP< Time > getNewTimer(const std::string &name)
Exception indicating invalid cast attempted.
static RCP< BlockedCrsMatrix > TwoMatrixMultiplyBlock(BlockedCrsMatrix &A, bool transposeA, BlockedCrsMatrix &B, bool transposeB, Teuchos::FancyOStream &fos, bool doFillComplete=true, bool doOptimizeStorage=true)
Helper function to do matrix-matrix multiply "in-place".
virtual void fillComplete(const RCP< const Map > &domainMap, const RCP< const Map > &rangeMap, const RCP< ParameterList > ¶ms=null)=0
Signal that data entry is complete, specifying domain and range maps.
Xpetra::Map< int, int, NO > Map
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool IsView(const viewLabel_t viewLabel) const
RCP< const MapExtractor > getDomainMapExtractor()
Returns map extractor for domain map.
virtual bool isFillComplete() const =0
Returns true if fillComplete() has been called and the matrix is in compute mode. ...
Xpetra::Matrix< double, int, int, NO > Matrix
virtual size_t Cols() const
number of column blocks
void CreateView(viewLabel_t viewLabel, const RCP< const Map > &rowMap, const RCP< const Map > &colMap)
virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const =0
Returns the current number of entries on this node in the specified local row.
static void TwoMatrixAdd(const Matrix &A, bool transposeA, SC alpha, Matrix &B, SC beta)
Helper function to calculate B = alpha*A + beta*B.
static void TwoMatrixAdd(const Xpetra::Matrix< SC, LO, GO, NO > &A, bool transposeA, SC alpha, Xpetra::Matrix< SC, LO, GO, NO > &B, SC beta)
Helper function to calculate B = alpha*A + beta*B.
static RCP< const Epetra_CrsMatrix > Op2EpetraCrs(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op)
static RCP< Xpetra::BlockedCrsMatrix< SC, LO, GO, NO > > TwoMatrixMultiplyBlock(Xpetra::BlockedCrsMatrix< SC, LO, GO, NO > &A, bool transposeA, Xpetra::BlockedCrsMatrix< SC, LO, GO, NO > &B, bool transposeB, Teuchos::FancyOStream &fos, bool doFillComplete=true, bool doOptimizeStorage=true)
Helper function to do matrix-matrix multiply "in-place".
static void TwoMatrixAdd(const Xpetra::Matrix< SC, LO, GO, NO > &A, bool transposeA, const SC &alpha, const Xpetra::Matrix< SC, LO, GO, NO > &B, bool transposeB, const SC &beta, RCP< Xpetra::Matrix< SC, LO, GO, NO > > &C, Teuchos::FancyOStream &fos, bool AHasFixedNnzPerRow=false)
Helper function to calculate C = alpha*A + beta*B.
Exception throws to report incompatible objects (like maps).
RCP< const Map > getDomainMap() const
Returns the Map associated with the full domain of this operator. This will be null until fillComplet...
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Multiply(const Matrix &A, bool transposeA, const Matrix &B, bool transposeB, RCP< Matrix > C_in, Teuchos::FancyOStream &fos, bool doFillComplete=true, bool doOptimizeStorage=true, const std::string &label=std::string())
Helper function to do matrix-matrix multiply.
static RCP< Epetra_CrsMatrix > Op2NonConstEpetraCrs(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op)
virtual global_size_t getGlobalNumEntries() const =0
Returns the global number of entries in this matrix.
Concrete implementation of Xpetra::Matrix.
virtual Teuchos::RCP< const Map > getRangeMap() const =0
The Map associated with the range of this operator, which must be compatible with Y...
virtual size_t Rows() const
number of row blocks
static RCP< Epetra_CrsMatrix > MLTwoMatrixMultiply(const Epetra_CrsMatrix &epA, const Epetra_CrsMatrix &epB, Teuchos::FancyOStream &fos)
static RCP< Matrix > Build(const RCP< const Map > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying the number of non-zeros for all rows.
static RCP< const Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2TpetraCrs(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op)
virtual const RCP< const Map > & getRowMap() const
Returns the Map that describes the row distribution in this matrix.
static RCP< Epetra_CrsMatrix > MLTwoMatrixMultiply(const Epetra_CrsMatrix &epA, const Epetra_CrsMatrix &epB, Teuchos::FancyOStream &fos)
static RCP< Xpetra::Matrix< SC, LO, GO, NO > > Multiply(const Matrix &A, bool transposeA, const Matrix &B, bool transposeB, RCP< Matrix > C_in, Teuchos::FancyOStream &fos, bool doFillComplete=true, bool doOptimizeStorage=true, const std::string &label=std::string())
Helper function to do matrix-matrix multiply.
virtual Teuchos::RCP< const Map > getDomainMap() const =0
The Map associated with the domain of this operator, which must be compatible with X...
static const Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > & Op2TpetraCrs(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op)
Xpetra-specific matrix class.
std::string toString(const T &t)