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,
100 #ifdef HAVE_XPETRA_EPETRA 105 if (crsOp == Teuchos::null)
109 if (tmp_ECrsMtx == Teuchos::null)
119 if (crsOp == Teuchos::null)
123 if (tmp_ECrsMtx == Teuchos::null)
136 if (tmp_ECrsMtx == Teuchos::null)
152 if (tmp_ECrsMtx == Teuchos::null)
154 A = Teuchos::rcp_const_cast<Epetra_CrsMatrix>(tmp_ECrsMtx->getEpetra_CrsMatrix());
160 #endif // HAVE_XPETRA_EPETRA 162 #ifdef HAVE_XPETRA_TPETRA 167 if (crsOp == Teuchos::null)
171 if (tmp_ECrsMtx == Teuchos::null)
173 A = tmp_ECrsMtx->getTpetra_CrsMatrix();
181 if (crsOp == Teuchos::null)
185 if (tmp_ECrsMtx == Teuchos::null)
187 A = tmp_ECrsMtx->getTpetra_CrsMatrixNonConst();
198 if (tmp_TCrsMtx == Teuchos::null)
200 A = tmp_TCrsMtx->getTpetra_CrsMatrix();
214 if (tmp_TCrsMtx == Teuchos::null)
216 A = Teuchos::rcp_const_cast<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >(tmp_TCrsMtx->getTpetra_CrsMatrix());
223 #endif // HAVE_XPETRA_TPETRA 227 template <
class Scalar,
228 class LocalOrdinal = int,
229 class GlobalOrdinal = LocalOrdinal,
234 #undef XPETRA_MATRIXMATRIX_SHORT 269 bool call_FillComplete_on_result =
true,
270 bool doOptimizeStorage =
true,
271 const std::string & label = std::string()) {
274 std::string msg =
"XpetraExt::MatrixMatrix::Multiply: row map of C is not same as row map of A";
278 std::string msg =
"XpetraExt::MatrixMatrix::Multiply: row map of C is not same as domain map of A";
288 bool haveMultiplyDoFillComplete = call_FillComplete_on_result && doOptimizeStorage;
291 # ifndef HAVE_XPETRA_EPETRAEXT 298 int i = EpetraExt::MatrixMatrix::Multiply(epA,transposeA,epB,transposeB,epC,haveMultiplyDoFillComplete);
299 if (haveMultiplyDoFillComplete) {
310 std::ostringstream buf;
312 std::string msg =
"EpetraExt::MatrixMatrix::Multiply return value of " + buf.str();
318 #ifdef HAVE_XPETRA_TPETRA 325 Tpetra::MatrixMatrix::Multiply(tpA,transposeA,tpB,transposeB,tpC,haveMultiplyDoFillComplete,label);
331 if(call_FillComplete_on_result && !haveMultiplyDoFillComplete) {
333 params->
set(
"Optimize Storage",doOptimizeStorage);
342 C.
CreateView(
"stridedMaps", rcpA, transposeA, rcpB, transposeB);
368 const Matrix& B,
bool transposeB,
371 bool doFillComplete =
true,
372 bool doOptimizeStorage =
true,
373 const std::string & label = std::string()) {
381 if (C == Teuchos::null) {
382 double nnzPerRow = Teuchos::as<double>(0);
390 nnzPerRow *= nnzPerRow;
393 if (totalNnz < minNnz)
397 fos <<
"Matrix product nnz per row estimate = " << Teuchos::as<LO>(nnzPerRow) << std::endl;
405 fos <<
"Reuse C pattern" << std::endl;
408 Multiply(A, transposeA, B, transposeB, *C, doFillComplete, doOptimizeStorage,label);
428 bool callFillCompleteOnResult =
true,
429 bool doOptimizeStorage =
true,
430 const std::string & label = std::string()){
431 return Multiply(A, transposeA, B, transposeB, Teuchos::null, fos, callFillCompleteOnResult, doOptimizeStorage,label);
434 #ifdef HAVE_XPETRA_EPETRAEXT 437 const Epetra_CrsMatrix& epB,
440 return Teuchos::null;
442 #endif //ifdef HAVE_XPETRA_EPETRAEXT 457 bool doFillComplete =
true,
458 bool doOptimizeStorage =
true) {
459 if (transposeA || transposeB)
460 throw Exceptions::RuntimeError(
"TwoMatrixMultiply for BlockedCrsMatrix not implemented for transposeA==true or transposeB==true");
473 for (
size_t i = 0; i < A.
Rows(); ++i) {
474 for (
size_t j = 0; j < B.
Cols(); ++j) {
477 for (
size_t l = 0; l < B.
Rows(); ++l) {
488 RCP<Matrix> temp = Multiply (*crop1,
false, *crop2,
false, fos);
497 if (Cij->isFillComplete())
503 "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));
688 bool call_FillComplete_on_result =
true,
689 bool doOptimizeStorage =
true,
690 const std::string & label = std::string()) {
692 std::string msg =
"XpetraExt::MatrixMatrix::Multiply: row map of C is not same as row map of A";
696 std::string msg =
"XpetraExt::MatrixMatrix::Multiply: row map of C is not same as domain map of A";
706 bool haveMultiplyDoFillComplete = call_FillComplete_on_result && doOptimizeStorage;
709 # ifndef 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();
736 #ifdef HAVE_XPETRA_TPETRA 743 Tpetra::MatrixMatrix::Multiply(tpA,transposeA,tpB,transposeB,tpC,haveMultiplyDoFillComplete,label);
749 if(call_FillComplete_on_result && !haveMultiplyDoFillComplete) {
751 params->
set(
"Optimize Storage",doOptimizeStorage);
760 C.
CreateView(
"stridedMaps", rcpA, transposeA, rcpB, transposeB);
786 const Matrix& B,
bool transposeB,
789 bool doFillComplete =
true,
790 bool doOptimizeStorage =
true,
791 const std::string & label = std::string()) {
798 #if defined(HAVE_XPETRA_EPETRA) && defined(HAVE_XPETRA_EPETRAEXT) && defined(HAVE_XPETRA_ML_MMM) 804 RCP<Matrix> C = Convert_Epetra_CrsMatrix_ToXpetra_CrsMatrixWrap<SC,LO,GO,NO> (epC);
805 if (doFillComplete) {
807 params->
set(
"Optimize Storage", doOptimizeStorage);
814 C->CreateView(
"stridedMaps", rcpFromRef(A), transposeA, rcpFromRef(B), transposeB);
818 #endif // EPETRA + EPETRAEXT + ML 823 if (C == Teuchos::null) {
824 double nnzPerRow = Teuchos::as<double>(0);
832 nnzPerRow *= nnzPerRow;
835 if (totalNnz < minNnz)
839 fos <<
"Matrix product nnz per row estimate = " << Teuchos::as<LO>(nnzPerRow) << std::endl;
847 fos <<
"Reuse C pattern" << std::endl;
850 Multiply(A, transposeA, B, transposeB, *C, doFillComplete, doOptimizeStorage,label);
870 bool callFillCompleteOnResult =
true,
871 bool doOptimizeStorage =
true,
872 const std::string & label = std::string()){
873 return Multiply(A, transposeA, B, transposeB, Teuchos::null, fos, callFillCompleteOnResult, doOptimizeStorage,label);
876 #ifdef HAVE_XPETRA_EPETRAEXT 879 const Epetra_CrsMatrix& epB,
881 #if defined(HAVE_XPETRA_ML_MMM) // Note: this is currently not supported 883 ML_Comm_Create(&comm);
884 fos <<
"****** USING ML's MATRIX MATRIX MULTIPLY ******" << std::endl;
887 const Epetra_MpiComm * Mcomm =
dynamic_cast<const Epetra_MpiComm*
>(&(epA.Comm()));
889 ML_Comm_Set_UsrComm(comm,Mcomm->GetMpiComm());
892 EpetraExt::CrsMatrix_SolverMap Atransform;
893 EpetraExt::CrsMatrix_SolverMap Btransform;
894 const Epetra_CrsMatrix& A = Atransform(const_cast<Epetra_CrsMatrix&>(epA));
895 const Epetra_CrsMatrix& B = Btransform(const_cast<Epetra_CrsMatrix&>(epB));
901 ML_Operator* ml_As = ML_Operator_Create(comm);
902 ML_Operator* ml_Bs = ML_Operator_Create(comm);
903 ML_Operator_WrapEpetraCrsMatrix(const_cast<Epetra_CrsMatrix*>(&A),ml_As);
904 ML_Operator_WrapEpetraCrsMatrix(const_cast<Epetra_CrsMatrix*>(&B),ml_Bs);
905 ML_Operator* ml_AtimesB = ML_Operator_Create(comm);
908 ML_2matmult(ml_As,ml_Bs,ml_AtimesB,ML_CSR_MATRIX);
910 ML_Operator_Destroy(&ml_As);
911 ML_Operator_Destroy(&ml_Bs);
916 int N_local = ml_AtimesB->invec_leng;
917 ML_CommInfoOP* getrow_comm = ml_AtimesB->getrow->pre_comm;
919 ML_Comm* comm_AB = ml_AtimesB->comm;
920 if (N_local != B.DomainMap().NumMyElements())
925 for (
int i = 0; i < getrow_comm->N_neighbors; i++) {
926 N_rcvd += (getrow_comm->neighbors)[i].N_rcv;
927 N_send += (getrow_comm->neighbors)[i].N_send;
928 if ( ((getrow_comm->neighbors)[i].N_rcv != 0) &&
929 ((getrow_comm->neighbors)[i].rcv_list != NULL) ) flag = 1;
933 std::vector<double> dtemp(N_local + N_rcvd + 1);
934 std::vector<int> cmap (N_local + N_rcvd + 1);
935 for (
int i = 0; i < N_local; ++i) {
936 cmap[i] = B.DomainMap().GID(i);
937 dtemp[i] = (double) cmap[i];
939 ML_cheap_exchange_bdry(&dtemp[0],getrow_comm,N_local,N_send,comm_AB);
942 const int neighbors = getrow_comm->N_neighbors;
943 for (
int i = 0; i < neighbors; i++) {
944 const int nrcv = getrow_comm->neighbors[i].N_rcv;
945 for (
int j = 0; j < nrcv; j++)
946 cmap[getrow_comm->neighbors[i].rcv_list[j]] = (
int) dtemp[count++];
949 for (
int i = 0; i < N_local+N_rcvd; ++i)
950 cmap[i] = (
int)dtemp[i];
955 Epetra_Map gcmap(-1, N_local+N_rcvd, &cmap[0], B.ColMap().IndexBase(), A.Comm());
962 const int myrowlength = A.RowMap().NumMyElements();
963 const Epetra_Map& rowmap = A.RowMap();
968 int educatedguess = 0;
969 for (
int i = 0; i < myrowlength; ++i) {
971 ML_get_matrix_row(ml_AtimesB, 1, &i, &allocated, &bindx, &val, &rowlength, 0);
972 if (rowlength>educatedguess)
973 educatedguess = rowlength;
979 std::vector<int> gcid(educatedguess);
980 for (
int i = 0; i < myrowlength; ++i) {
981 const int grid = rowmap.GID(i);
983 ML_get_matrix_row(ml_AtimesB, 1, &i, &allocated, &bindx, &val, &rowlength, 0);
984 if (!rowlength)
continue;
985 if ((
int)gcid.size() < rowlength) gcid.resize(rowlength);
986 for (
int j = 0; j < rowlength; ++j) {
987 gcid[j] = gcmap.GID(bindx[j]);
991 int err = result->InsertGlobalValues(grid, rowlength, val, &gcid[0]);
992 if (err != 0 && err != 1) {
993 std::ostringstream errStr;
994 errStr <<
"Epetra_CrsMatrix::InsertGlobalValues returned err=" << err;
999 if (bindx) ML_free(bindx);
1000 if (val) ML_free(val);
1001 ML_Operator_Destroy(&ml_AtimesB);
1002 ML_Comm_Destroy(&comm);
1005 #else // no MUELU_ML 1007 "No ML multiplication available. This feature is currently not supported by Xpetra.");
1008 return Teuchos::null;
1011 #endif //ifdef HAVE_XPETRA_EPETRAEXT 1026 bool doFillComplete =
true,
1027 bool doOptimizeStorage =
true) {
1028 if (transposeA || transposeB)
1029 throw Exceptions::RuntimeError(
"TwoMatrixMultiply for BlockedCrsMatrix not implemented for transposeA==true or transposeB==true");
1043 for (
size_t i = 0; i < A.
Rows(); ++i) {
1044 for (
size_t j = 0; j < B.
Cols(); ++j) {
1047 for (
size_t l = 0; l < B.
Rows(); ++l) {
1067 if (Cij->isFillComplete())
1073 "MatrixFactory failed in generating a CrsMatrixWrap." );
1076 C->setMatrix(i, j, crsMatCij);
1079 C->setMatrix(i, j, Teuchos::null);
1102 static void TwoMatrixAdd(
const Xpetra::Matrix<SC,LO,GO,NO>& A,
bool transposeA, SC alpha,
Xpetra::Matrix<SC,LO,GO,NO>& B, SC beta) {
1107 #if defined(HAVE_XPETRA_EPETRA) && defined(HAVE_XPETRA_EPETRAEXT) 1112 int rv = EpetraExt::MatrixMatrix::Add(epA, transposeA, alpha, epB, beta);
1116 std::ostringstream buf;
1121 #ifdef HAVE_XPETRA_TPETRA 1125 Tpetra::MatrixMatrix::Add(tpA, transposeA, alpha, tpB, beta);
1151 if (C == Teuchos::null) {
1159 if (maxNzInA == 1 || maxNzInB == 1 || AHasFixedNnzPerRow) {
1164 if ((maxNzInA == 1 && maxNzInB > 1) || AHasFixedNnzPerRow) {
1165 for (
size_t i = 0; i < numLocalRows; ++i)
1169 for (
size_t i = 0; i < numLocalRows; ++i)
1173 fos <<
"MatrixMatrix::TwoMatrixAdd : special case detected (one matrix has a fixed nnz per row)" 1174 <<
", using static profiling" << std::endl;
1181 LO nnzToAllocate = Teuchos::as<LO>( (nnzPerRowInA + nnzPerRowInB) * 1.5) + Teuchos::as<LO>(1);
1188 fos <<
"nnzPerRowInA = " << nnzPerRowInA <<
", nnzPerRowInB = " << nnzPerRowInB << std::endl;
1189 fos <<
"MatrixMatrix::TwoMatrixAdd : space allocated per row = " << nnzToAllocate
1190 <<
", max possible nnz per row in sum = " << maxPossible
1196 fos <<
"MatrixMatrix::TwoMatrixAdd : ** WARNING ** estimate could be badly wrong because second summand is transposed" << std::endl;
1200 #if defined(HAVE_XPETRA_EPETRA) && defined(HAVE_XPETRA_EPETRAEXT) 1204 Epetra_CrsMatrix* ref2epC = &*epC;
1207 int rv = EpetraExt::MatrixMatrix::Add(epA, transposeA, alpha, epB, transposeB, beta, ref2epC);
1215 #ifdef HAVE_XPETRA_TPETRA 1216 const Tpetra::CrsMatrix<SC,LO,GO,NO>& tpA =
1218 const Tpetra::CrsMatrix<SC,LO,GO,NO>& tpB =
1223 Tpetra::MatrixMatrix::Add(tpA, transposeA, alpha, tpB, transposeB, beta, tpC);
1239 #define XPETRA_MATRIXMATRIX_SHORT virtual size_t getNodeNumRows() const =0
Returns the number of matrix rows owned on the calling node.
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 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".
RCP< CrsMatrix > getCrsMatrix() const
Xpetra::MultiVector< double, int, int, NO > MultiVector
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...
KokkosClassic::DefaultNode::DefaultNodeType NO
Teuchos::RCP< CrsMatrix > getMatrix(size_t r, size_t c) const
return block (r,c)
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())
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.
Xpetra::Matrix< double, int, int, NO > Matrix
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 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.
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.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool IsView(const viewLabel_t viewLabel) const
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.
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. ...
virtual size_t Cols() const
number of column blocks
void CreateView(viewLabel_t viewLabel, const RCP< const Map > &rowMap, const RCP< const Map > &colMap)
static RCP< Epetra_CrsMatrix > MLTwoMatrixMultiply(const Epetra_CrsMatrix &epA, const Epetra_CrsMatrix &epB, Teuchos::FancyOStream &fos)
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
Get the underlying Epetra matrix.
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 RCP< const Epetra_CrsMatrix > Op2EpetraCrs(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op)
Xpetra::Map< int, int, NO > Map
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
Get the underlying Epetra matrix.
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< 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)
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)