46 #ifndef XPETRA_EPETRACRSMATRIX_HPP
47 #define XPETRA_EPETRACRSMATRIX_HPP
51 #ifdef HAVE_XPETRA_TPETRA
52 #include <Kokkos_Core.hpp>
59 #include <Epetra_CrsMatrix.h>
60 #include <Epetra_Map.h>
67 #include "Xpetra_MapFactory.hpp"
75 template <
class EpetraGlobalOrdinal,
class Node>
77 :
public CrsMatrix<double, int, EpetraGlobalOrdinal, Node> {
82 #ifdef HAVE_XPETRA_TPETRA
90 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
94 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
103 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = Teuchos::null) {
105 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
111 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = Teuchos::null) {
113 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
120 const Teuchos::RCP<Teuchos::ParameterList> ¶ms) {
122 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
129 const Teuchos::RCP<Teuchos::ParameterList> ¶ms) {
131 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
133 #ifdef HAVE_XPETRA_TPETRA
137 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = null) {
139 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
147 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = null) {
149 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
160 void allocateAllValues(
size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind, ArrayRCP<Scalar> &values) {}
161 void setAllValues(
const ArrayRCP<size_t> &rowptr,
const ArrayRCP<LocalOrdinal> &colind,
const ArrayRCP<Scalar> &values) {}
162 void getAllValues(ArrayRCP<const size_t> &rowptr, ArrayRCP<const LocalOrdinal> &colind, ArrayRCP<const Scalar> &values)
const {}
169 const RCP<ParameterList> ¶ms = Teuchos::null) {}
175 const RCP<const Comm<int> >
getComm()
const {
return Teuchos::null; }
176 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getRowMap()
const {
return Teuchos::null; }
177 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getColMap()
const {
return Teuchos::null; }
178 RCP<const CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
getCrsGraph()
const {
return Teuchos::null; }
193 typename ScalarTraits<Scalar>::magnitudeType
getFrobeniusNorm()
const {
return ScalarTraits<Scalar>::magnitude(ScalarTraits<Scalar>::zero()); }
207 void apply(
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &X,
MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &Y, Teuchos::ETransp mode = Teuchos::NO_TRANS,
Scalar alpha = ScalarTraits<Scalar>::one(),
Scalar beta = ScalarTraits<Scalar>::zero())
const {}
208 void apply(
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &X,
MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &Y, Teuchos::ETransp mode,
Scalar alpha,
Scalar beta,
bool sumInterfaceValues,
const RCP<
Import<LocalOrdinal, GlobalOrdinal, Node> > ®ionInterfaceImporter,
const Teuchos::ArrayRCP<LocalOrdinal> ®ionInterfaceLIDs)
const {}
209 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getDomainMap()
const {
return Teuchos::null; }
210 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getRangeMap()
const {
return Teuchos::null; }
213 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default)
const {}
218 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
221 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getMap()
const {
return Teuchos::null; }
231 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
235 #ifdef HAVE_XPETRA_TPETRA
238 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
242 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
246 const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind,
247 const typename local_matrix_type::values_type &val) {
249 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
256 #warning "Xpetra Kokkos interface for CrsMatrix is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
263 Scalar one = Teuchos::ScalarTraits<Scalar>::one(), negone = -one;
270 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
273 :
public CrsMatrix<double, int, int, EpetraNode> {
280 #ifdef HAVE_XPETRA_TPETRA
292 , isFillResumed_(false) {}
297 , isFillResumed_(false) {}
301 : isFillResumed_(false) {
302 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
303 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
309 , isFillResumed_(false) {}
313 : isFillResumed_(false) {
314 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
315 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
321 , isFillResumed_(false) {}
328 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = Teuchos::null)
329 : isFillResumed_(false) {
333 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
334 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
337 bool restrictComm =
false;
338 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
339 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), myDomainMap, myRangeMap, restrictComm));
340 if (restrictComm && mtx_->NumMyRows() == 0)
341 mtx_ = Teuchos::null;
349 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = Teuchos::null)
350 : isFillResumed_(false) {
354 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
355 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
358 bool restrictComm =
false;
359 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
361 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), myDomainMap, myRangeMap, restrictComm));
369 const Teuchos::RCP<Teuchos::ParameterList> ¶ms)
370 : isFillResumed_(false) {
375 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
376 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
379 bool restrictComm =
false;
380 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
381 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), tdImporter->getEpetra_Import().get(), myDomainMap, myRangeMap, restrictComm));
382 if (restrictComm && mtx_->NumMyRows() == 0)
383 mtx_ = Teuchos::null;
391 const Teuchos::RCP<Teuchos::ParameterList> ¶ms)
392 : isFillResumed_(false) {
397 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
398 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
401 bool restrictComm =
false;
402 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
404 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), tdExporter->getEpetra_Export().get(), myDomainMap, myRangeMap, restrictComm));
407 #ifdef HAVE_XPETRA_TPETRA
434 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = null)
435 :
EpetraCrsMatrixT(lclMatrix, rowMap, colMap, Teuchos::null, Teuchos::null, params) {}
443 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = null) {
446 typedef typename local_matrix_type::value_type value_type;
447 typedef typename local_matrix_type::ordinal_type ordinal_type;
450 ordinal_type lclNumRows = lclMatrix.numRows();
451 ordinal_type lclNumCols = lclMatrix.numCols();
455 "Xpetra::EpetraCrsMatrixT: number of rows in local matrix and number of local entries in row map do not match!");
457 "Xpetra::EpetraCrsMatrixT: number of columns in local matrix and number of local entries in column map do not match!");
459 Teuchos::ArrayRCP<size_t> NumEntriesPerRowToAlloc(lclNumRows);
460 for (ordinal_type r = 0; r < lclNumRows; ++r) {
462 auto rowview = lclMatrix.row(r);
463 NumEntriesPerRowToAlloc[r] = rowview.length;
467 isFillResumed_ =
false;
468 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
469 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
472 for (ordinal_type r = 0; r < lclNumRows; ++r) {
474 auto rowview = lclMatrix.row(r);
477 Teuchos::ArrayRCP<ordinal_type> indout(rowview.length, Teuchos::ScalarTraits<ordinal_type>::zero());
478 Teuchos::ArrayRCP<value_type> valout(rowview.length, Teuchos::ScalarTraits<value_type>::zero());
480 for (ordinal_type c = 0; c < rowview.length; c++) {
481 value_type value = rowview.value(c);
482 ordinal_type colidx = rowview.colidx(c);
485 "Xpetra::EpetraCrsMatrixT: local matrix contains column elements which are not in the provided column map!");
490 insertLocalValues(r, indout.view(0, indout.size()), valout.view(0, valout.size()));
494 if (!domainMap.is_null() && !rangeMap.is_null())
512 XPETRA_ERR_CHECK(mtx_->InsertGlobalValues(globalRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
518 XPETRA_ERR_CHECK(mtx_->InsertMyValues(localRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
526 const std::string tfecfFuncName(
"replaceGlobalValues");
527 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!
isFillActive(), std::runtime_error,
528 ": Fill must be active in order to call this method. If you have already "
529 "called fillComplete(), you need to call resumeFill() before you can "
532 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
533 std::runtime_error,
": values.size() must equal indices.size().");
536 XPETRA_ERR_CHECK(mtx_->ReplaceGlobalValues(globalRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
544 const std::string tfecfFuncName(
"replaceLocalValues");
545 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!
isFillActive(), std::runtime_error,
546 ": Fill must be active in order to call this method. If you have already "
547 "called fillComplete(), you need to call resumeFill() before you can "
550 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
551 std::runtime_error,
": values.size() must equal indices.size().");
554 XPETRA_ERR_CHECK(mtx_->ReplaceMyValues(localRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
560 mtx_->PutScalar(alpha);
571 void allocateAllValues(
size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind, ArrayRCP<Scalar> &values) {
582 bool ownMemory =
false;
586 Epetra_IntSerialDenseVector &myColind = mtx_->ExpertExtractIndices();
587 myColind.Resize(numNonZeros);
588 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
592 double *&myValues = mtx_->ExpertExtractValues();
594 myValues =
new double[numNonZeros];
595 values = Teuchos::arcp(myValues, lowerOffset, numNonZeros, ownMemory);
599 void setAllValues(
const ArrayRCP<size_t> &rowptr,
const ArrayRCP<LocalOrdinal> &colind,
const ArrayRCP<Scalar> &values) {
604 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
606 "An exception is thrown to let you know that you mismatched your pointers.");
609 if (values.size() > 0) {
611 "An exception is thrown to let you know that you mismatched your pointers.");
613 "An exception is thrown to let you know that you mismatched your pointers.");
620 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
621 myRowptr.Resize(N + 1);
622 for (
size_t i = 0; i < N + 1; i++)
623 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
627 void getAllValues(ArrayRCP<const size_t> &rowptr, ArrayRCP<const LocalOrdinal> &colind, ArrayRCP<const Scalar> &values)
const {
631 bool ownMemory =
false;
638 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
639 rowptr.resize(n + 1);
640 for (
size_t i = 0; i < n + 1; i++)
641 (*const_cast<size_t *>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
644 colind = Teuchos::arcp(mtx_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
647 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
655 bool ownMemory =
false;
659 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
670 const RCP<ParameterList> & = Teuchos::null) {
674 isFillResumed_ =
false;
677 const Epetra_Import *myimport = 0;
678 const Epetra_Export *myexport = 0;
680 if (!importer.is_null()) {
682 myimport = eImporter.getEpetra_Import().getRawPtr();
684 if (!exporter.is_null()) {
686 myexport = eExporter.getEpetra_Export().getRawPtr();
689 rv = mtx_->ExpertStaticFillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), myimport, myexport);
691 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error,
"Xpetra::EpetraCrsMatrixT::expertStaticFillComplete FAILED!");
699 void resumeFill(
const RCP<ParameterList> & = Teuchos::null) {
703 isFillResumed_ =
true;
711 isFillResumed_ =
false;
713 bool doOptimizeStorage =
true;
714 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
715 mtx_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), doOptimizeStorage);
723 if (isFillResumed_ ==
true) {
724 isFillResumed_ =
false;
728 bool doOptimizeStorage =
true;
729 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
730 mtx_->FillComplete(doOptimizeStorage);
738 const RCP<const Epetra_Import> &myImport = eImporter.getEpetra_Import();
740 if (myImport == Teuchos::null)
741 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), 0);
743 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), &*myImport);
744 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error,
"Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter FAILED!");
759 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getRowMap()
const {
761 return toXpetra<GlobalOrdinal, Node>(mtx_->RowMap());
765 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getColMap()
const {
767 return toXpetra<GlobalOrdinal, Node>(mtx_->ColMap());
771 RCP<const CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
getCrsGraph()
const {
773 return toXpetra<GlobalOrdinal, Node>(mtx_->Graph());
779 return mtx_->NumGlobalRows64();
785 return mtx_->NumGlobalCols64();
791 return mtx_->NumMyRows();
797 return mtx_->NumMyCols();
803 return mtx_->NumGlobalNonzeros64();
809 return mtx_->NumMyNonzeros();
815 return mtx_->NumMyEntries(localRow);
821 return mtx_->NumGlobalEntries(globalRow);
827 return mtx_->GlobalMaxNumEntries();
833 return mtx_->MaxNumEntries();
839 return mtx_->IndicesAreLocal();
845 return mtx_->IndicesAreGlobal();
854 return mtx_->Filled();
866 return mtx_->NormFrobenius();
880 XPETRA_ERR_CHECK(mtx_->ExtractMyRowCopy(LocalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
881 NumEntries = numEntries;
889 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowCopy(GlobalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
890 NumEntries = numEntries;
901 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowView(GlobalRow, numEntries, eValues, eIndices));
902 if (numEntries == 0) {
907 indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
908 values = ArrayView<const double>(eValues, numEntries);
919 XPETRA_ERR_CHECK(mtx_->ExtractMyRowView(LocalRow, numEntries, eValues, eIndices));
920 if (numEntries == 0) {
925 indices = ArrayView<const int>(eIndices, numEntries);
926 values = ArrayView<const double>(eValues, numEntries);
932 XPETRA_ERR_CHECK(mtx_->ExtractDiagonalCopy(toEpetra<GlobalOrdinal, Node>(diag)));
952 mtx_->ReplaceDiagonalValues(toEpetra<GlobalOrdinal, Node>(diag));
968 void apply(
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &X,
MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &Y, Teuchos::ETransp mode = Teuchos::NO_TRANS,
Scalar alpha = ScalarTraits<Scalar>::one(),
Scalar beta = ScalarTraits<Scalar>::zero())
const {
976 TEUCHOS_TEST_FOR_EXCEPTION((mode != Teuchos::NO_TRANS) && (mode != Teuchos::TRANS),
Xpetra::Exceptions::NotImplemented,
"Xpetra::EpetraCrsMatrixT->apply() only accept mode == NO_TRANS or mode == TRANS");
980 TEUCHOS_TEST_FOR_EXCEPTION(mtx_->UseTranspose(),
Xpetra::Exceptions::NotImplemented,
"An exception is throw to let you know that Xpetra::EpetraCrsMatrixT->apply() do not take into account the UseTranspose() parameter of Epetra_CrsMatrix.");
982 RCP<Epetra_MultiVector> epY = eY.getEpetra_MultiVector();
985 RCP<Epetra_MultiVector> tmp = Teuchos::rcp(
new Epetra_MultiVector(*epY));
987 XPETRA_ERR_CHECK(mtx_->Multiply(eTrans, *eX.getEpetra_MultiVector(), *tmp));
994 void apply(
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &X,
MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &Y, Teuchos::ETransp mode,
Scalar alpha,
Scalar beta,
bool sumInterfaceValues,
const RCP<
Import<LocalOrdinal, GlobalOrdinal, Node> > ®ionInterfaceImporter,
const Teuchos::ArrayRCP<LocalOrdinal> ®ionInterfaceLIDs)
const {
999 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getDomainMap()
const {
1001 return toXpetra<GlobalOrdinal, Node>(mtx_->DomainMap());
1005 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getRangeMap()
const {
1007 return toXpetra<GlobalOrdinal, Node>(mtx_->RangeMap());
1020 std::ostringstream oss;
1023 oss <<
"{status = fill complete"
1029 oss <<
"{status = fill not complete"
1037 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default)
const {
1043 using Teuchos::VERB_DEFAULT;
1044 using Teuchos::VERB_EXTREME;
1045 using Teuchos::VERB_HIGH;
1046 using Teuchos::VERB_LOW;
1047 using Teuchos::VERB_MEDIUM;
1048 using Teuchos::VERB_NONE;
1049 Teuchos::EVerbosityLevel vl = verbLevel;
1050 if (vl == VERB_DEFAULT) vl = VERB_LOW;
1051 RCP<const Comm<int> > comm = this->
getComm();
1052 const int myImageID = comm->getRank(),
1053 numImages = comm->getSize();
1058 width = std::max<size_t>(width, 11) + 2;
1059 Teuchos::OSTab tab(out);
1067 if (vl != VERB_NONE) {
1068 if (myImageID == 0) out << this->
description() << std::endl;
1074 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
1075 if (myImageID == 0) out <<
"\nRow map: " << std::endl;
1080 if (myImageID == 0) out <<
"\nColumn map is row map.";
1082 if (myImageID == 0) out <<
"\nColumn map: " << std::endl;
1088 if (myImageID == 0) out <<
"\nDomain map is row map.";
1090 if (myImageID == 0) out <<
"\nDomain map is row map.";
1092 if (myImageID == 0) out <<
"\nDomain map: " << std::endl;
1098 if (myImageID == 0) out <<
"\nRange map is domain map." << std::endl;
1100 if (myImageID == 0) out <<
"\nRange map is row map." << std::endl;
1102 if (myImageID == 0) out <<
"\nRange map: " << std::endl;
1106 if (myImageID == 0) out << std::endl;
1109 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
1110 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1111 if (myImageID == imageCtr) {
1112 out <<
"Node ID = " << imageCtr << std::endl;
1134 if (vl == VERB_HIGH || vl == VERB_EXTREME) {
1135 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1136 if (myImageID == imageCtr) {
1137 out << std::setw(width) <<
"Node ID"
1138 << std::setw(width) <<
"Global Row"
1139 << std::setw(width) <<
"Num Entries";
1140 if (vl == VERB_EXTREME) {
1141 out << std::setw(width) <<
"(Index,Value)";
1147 out << std::setw(width) << myImageID
1148 << std::setw(width) << gid
1149 << std::setw(width) << nE;
1150 if (vl == VERB_EXTREME) {
1152 ArrayView<const GlobalOrdinal> rowinds;
1153 ArrayView<const Scalar> rowvals;
1155 for (
size_t j = 0; j < nE; ++j) {
1156 out <<
" (" << rowinds[j]
1157 <<
", " << rowvals[j]
1161 ArrayView<const LocalOrdinal> rowinds;
1162 ArrayView<const Scalar> rowvals;
1164 for (
size_t j = 0; j < nE; ++j) {
1165 out <<
" (" <<
getColMap()->getGlobalElement(rowinds[j])
1166 <<
", " << rowvals[j]
1183 Teuchos::LabeledObject::setObjectLabel(objectLabel);
1184 mtx_->SetLabel(objectLabel.c_str());
1190 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(*(matrix.mtx_))))
1191 , isFillResumed_(false) {}
1197 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getMap()
const {
1199 return toXpetra<GlobalOrdinal, Node>(mtx_->Map());
1210 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
1211 int err = mtx_->Import(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
1212 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
1223 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
1224 int err = mtx_->Export(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
1225 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
1236 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
1237 int err = mtx_->Import(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
1238 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
1249 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
1250 int err = mtx_->Export(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
1251 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Caught nonzero error code " + std::to_string(err) +
" returned by Epetra.");
1256 const Epetra_Map *newMapEpetra = (!newMap.is_null()) ? &toEpetra<GlobalOrdinal, Node>(newMap) : 0;
1257 int err = mtx_->RemoveEmptyProcessesInPlace(newMapEpetra);
1258 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Caught nonzero error code " + std::to_string(err) +
" returned by Epetra.");
1272 , isFillResumed_(false) {}
1280 #ifdef HAVE_XPETRA_TPETRA
1286 "Xpetra::EpetraCrsMatrx only available on host for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
1295 const int numRows = matrix->NumMyRows();
1296 const int numCols = matrix->NumMyCols();
1297 const int nnz = matrix->NumMyNonzeros();
1302 int rv = matrix->ExtractCrsDataPointers(rowptr, colind, vals);
1303 TEUCHOS_TEST_FOR_EXCEPTION(rv, std::runtime_error,
"Xpetra::CrsMatrix<>::getLocalMatrix: failed in ExtractCrsDataPointers");
1306 typename local_matrix_type::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing(
"local row map"), numRows + 1);
1307 for (
size_t i = 0; i < kokkosRowPtr.size(); i++)
1308 kokkosRowPtr(i) = Teuchos::asSafe<typename local_matrix_type::row_map_type::value_type>(rowptr[i]);
1311 typename local_matrix_type::index_type kokkosColind(colind, nnz);
1312 typename local_matrix_type::values_type kokkosVals(vals, nnz);
1320 const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind,
1321 const typename local_matrix_type::values_type &val) {
1324 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
1326 "An exception is thrown to let you know that you mismatched your pointers.");
1329 if (val.size() > 0) {
1330 std::cout << ind.data() <<
" " << mtx_->ExpertExtractIndices().Values() << std::endl;
1332 "An exception is thrown to let you know that you mismatched your pointers.");
1334 "An exception is thrown to let you know that you mismatched your pointers.");
1341 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
1342 myRowptr.Resize(N + 1);
1343 for (
size_t i = 0; i < N + 1; i++)
1344 myRowptr[i] = Teuchos::as<int>(ptr(i));
1352 #warning "Xpetra Kokkos interface for CrsMatrix is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
1360 Scalar one = Teuchos::ScalarTraits<Scalar>::one(), negone = -one;
1363 R.
update(one, B, negone);
1380 #endif //#ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
1382 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
1385 :
public CrsMatrix<double, int, long long, EpetraNode> {
1392 #ifdef HAVE_XPETRA_TPETRA
1404 , isFillResumed_(false) {}
1408 : isFillResumed_(false) {
1409 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
1410 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
1416 , isFillResumed_(false) {}
1420 : isFillResumed_(false) {
1421 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
1422 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
1428 , isFillResumed_(false) {}
1435 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = Teuchos::null)
1436 : isFillResumed_(false) {
1440 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1441 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1444 bool restrictComm =
false;
1445 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
1446 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), myDomainMap, myRangeMap, restrictComm));
1447 if (restrictComm && mtx_->NumMyRows() == 0)
1448 mtx_ = Teuchos::null;
1456 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = Teuchos::null)
1457 : isFillResumed_(false) {
1461 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1462 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1465 bool restrictComm =
false;
1466 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
1468 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), myDomainMap, myRangeMap, restrictComm));
1476 const Teuchos::RCP<Teuchos::ParameterList> ¶ms)
1477 : isFillResumed_(false) {
1482 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1483 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1486 bool restrictComm =
false;
1487 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
1488 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), tdImporter->getEpetra_Import().get(), myDomainMap, myRangeMap, restrictComm));
1489 if (restrictComm && mtx_->NumMyRows() == 0)
1490 mtx_ = Teuchos::null;
1498 const Teuchos::RCP<Teuchos::ParameterList> ¶ms)
1499 : isFillResumed_(false) {
1504 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1505 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1508 bool restrictComm =
false;
1509 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
1511 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), tdExporter->getEpetra_Export().get(), myDomainMap, myRangeMap, restrictComm));
1514 #ifdef HAVE_XPETRA_TPETRA
1538 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = null)
1539 :
EpetraCrsMatrixT(lclMatrix, rowMap, colMap, Teuchos::null, Teuchos::null, params) {}
1547 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = null) {
1550 typedef typename local_matrix_type::value_type value_type;
1551 typedef typename local_matrix_type::ordinal_type ordinal_type;
1554 ordinal_type lclNumRows = lclMatrix.numRows();
1555 ordinal_type lclNumCols = lclMatrix.numCols();
1559 "Xpetra::EpetraCrsMatrixT: number of rows in local matrix and number of local entries in row map do not match!");
1561 "Xpetra::EpetraCrsMatrixT: number of columns in local matrix and number of local entries in column map do not match!");
1563 Teuchos::ArrayRCP<size_t> NumEntriesPerRowToAlloc(lclNumRows);
1564 for (ordinal_type r = 0; r < lclNumRows; ++r) {
1566 auto rowview = lclMatrix.row(r);
1567 NumEntriesPerRowToAlloc[r] = rowview.length;
1571 isFillResumed_ =
false;
1572 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
1573 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
1576 for (ordinal_type r = 0; r < lclNumRows; ++r) {
1578 auto rowview = lclMatrix.row(r);
1581 Teuchos::ArrayRCP<ordinal_type> indout(rowview.length, Teuchos::ScalarTraits<ordinal_type>::zero());
1582 Teuchos::ArrayRCP<value_type> valout(rowview.length, Teuchos::ScalarTraits<value_type>::zero());
1584 for (ordinal_type c = 0; c < rowview.length; c++) {
1585 value_type value = rowview.value(c);
1586 ordinal_type colidx = rowview.colidx(c);
1588 TEUCHOS_TEST_FOR_EXCEPTION(colMap->isNodeLocalElement(colidx) ==
false,
Xpetra::Exceptions::RuntimeError,
"Xpetra::EpetraCrsMatrixT: local matrix contains column elements which are not in the provided column map!");
1593 insertLocalValues(r, indout.view(0, indout.size()), valout.view(0, valout.size()));
1597 if (!domainMap.is_null() && !rangeMap.is_null())
1615 XPETRA_ERR_CHECK(mtx_->InsertGlobalValues(globalRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
1621 XPETRA_ERR_CHECK(mtx_->InsertMyValues(localRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
1629 const std::string tfecfFuncName(
"replaceGlobalValues");
1630 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!
isFillActive(), std::runtime_error,
1631 ": Fill must be active in order to call this method. If you have already "
1632 "called fillComplete(), you need to call resumeFill() before you can "
1635 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
1636 std::runtime_error,
": values.size() must equal indices.size().");
1639 XPETRA_ERR_CHECK(mtx_->ReplaceGlobalValues(globalRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
1647 const std::string tfecfFuncName(
"replaceLocalValues");
1648 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!
isFillActive(), std::runtime_error,
1649 ": Fill must be active in order to call this method. If you have already "
1650 "called fillComplete(), you need to call resumeFill() before you can "
1653 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
1654 std::runtime_error,
": values.size() must equal indices.size().");
1657 XPETRA_ERR_CHECK(mtx_->ReplaceMyValues(localRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
1663 mtx_->PutScalar(alpha);
1674 void allocateAllValues(
size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind, ArrayRCP<Scalar> &values) {
1684 int lowerOffset = 0;
1685 bool ownMemory =
false;
1689 Epetra_IntSerialDenseVector &myColind = mtx_->ExpertExtractIndices();
1690 myColind.Resize(numNonZeros);
1691 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
1695 double *&myValues = mtx_->ExpertExtractValues();
1697 myValues =
new double[numNonZeros];
1698 values = Teuchos::arcp(myValues, lowerOffset, numNonZeros, ownMemory);
1702 void setAllValues(
const ArrayRCP<size_t> &rowptr,
const ArrayRCP<LocalOrdinal> &colind,
const ArrayRCP<Scalar> &values) {
1707 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
1709 "An exception is thrown to let you know that you mismatched your pointers.");
1712 if (values.size() > 0) {
1714 "An exception is thrown to let you know that you mismatched your pointers.");
1716 "An exception is thrown to let you know that you mismatched your pointers.");
1723 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
1724 myRowptr.Resize(N + 1);
1725 for (
size_t i = 0; i < N + 1; i++)
1726 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
1730 void getAllValues(ArrayRCP<const size_t> &rowptr, ArrayRCP<const LocalOrdinal> &colind, ArrayRCP<const Scalar> &values)
const {
1733 int lowerOffset = 0;
1734 bool ownMemory =
false;
1741 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
1742 rowptr.resize(n + 1);
1743 for (
size_t i = 0; i < n + 1; i++)
1744 (*const_cast<size_t *>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
1747 colind = Teuchos::arcp(mtx_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
1750 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
1757 int lowerOffset = 0;
1758 bool ownMemory =
false;
1762 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
1774 const RCP<ParameterList> & = Teuchos::null) {
1778 isFillResumed_ =
false;
1781 const Epetra_Import *myimport = 0;
1782 const Epetra_Export *myexport = 0;
1784 if (!importer.is_null()) {
1786 myimport = eImporter.getEpetra_Import().getRawPtr();
1788 if (!exporter.is_null()) {
1790 myexport = eExporter.getEpetra_Export().getRawPtr();
1793 rv = mtx_->ExpertStaticFillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), myimport, myexport);
1795 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error,
"Xpetra::EpetraCrsMatrixT::expertStaticFillComplete FAILED!");
1807 isFillResumed_ =
true;
1815 if (isFillResumed_ ==
true) {
1816 isFillResumed_ =
false;
1820 bool doOptimizeStorage =
true;
1821 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
1822 mtx_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), doOptimizeStorage);
1830 if (isFillResumed_ ==
true) {
1831 isFillResumed_ =
false;
1835 bool doOptimizeStorage =
true;
1836 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
1837 mtx_->FillComplete(doOptimizeStorage);
1845 const RCP<const Epetra_Import> &myImport = eImporter.getEpetra_Import();
1847 if (myImport == Teuchos::null)
1848 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), 0);
1850 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), &*myImport);
1851 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error,
"Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter FAILED!");
1866 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getRowMap()
const {
1868 return toXpetra<GlobalOrdinal, Node>(mtx_->RowMap());
1872 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getColMap()
const {
1874 return toXpetra<GlobalOrdinal, Node>(mtx_->ColMap());
1878 RCP<const CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
getCrsGraph()
const {
1880 return toXpetra<GlobalOrdinal, Node>(mtx_->Graph());
1886 return mtx_->NumGlobalRows64();
1892 return mtx_->NumGlobalCols64();
1898 return mtx_->NumMyRows();
1904 return mtx_->NumMyCols();
1910 return mtx_->NumGlobalNonzeros64();
1916 return mtx_->NumMyNonzeros();
1922 return mtx_->NumMyEntries(localRow);
1928 return mtx_->NumGlobalEntries(globalRow);
1934 return mtx_->GlobalMaxNumEntries();
1940 return mtx_->MaxNumEntries();
1946 return mtx_->IndicesAreLocal();
1952 return mtx_->IndicesAreGlobal();
1961 return mtx_->Filled();
1973 return mtx_->NormFrobenius();
1986 int numEntries = -1;
1987 XPETRA_ERR_CHECK(mtx_->ExtractMyRowCopy(LocalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
1988 NumEntries = numEntries;
1995 int numEntries = -1;
1996 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowCopy(GlobalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
1997 NumEntries = numEntries;
2008 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowView(GlobalRow, numEntries, eValues, eIndices));
2009 if (numEntries == 0) {
2014 indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
2015 values = ArrayView<const double>(eValues, numEntries);
2026 XPETRA_ERR_CHECK(mtx_->ExtractMyRowView(LocalRow, numEntries, eValues, eIndices));
2027 if (numEntries == 0) {
2032 indices = ArrayView<const int>(eIndices, numEntries);
2033 values = ArrayView<const double>(eValues, numEntries);
2039 mtx_->ExtractDiagonalCopy(toEpetra<GlobalOrdinal, Node>(diag));
2059 mtx_->ReplaceDiagonalValues(toEpetra<GlobalOrdinal, Node>(diag));
2075 void apply(
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &X,
MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &Y, Teuchos::ETransp mode = Teuchos::NO_TRANS,
Scalar alpha = ScalarTraits<Scalar>::one(),
Scalar beta = ScalarTraits<Scalar>::zero())
const {
2083 TEUCHOS_TEST_FOR_EXCEPTION((mode != Teuchos::NO_TRANS) && (mode != Teuchos::TRANS),
Xpetra::Exceptions::NotImplemented,
"Xpetra::EpetraCrsMatrixT->apply() only accept mode == NO_TRANS or mode == TRANS");
2087 TEUCHOS_TEST_FOR_EXCEPTION(mtx_->UseTranspose(),
Xpetra::Exceptions::NotImplemented,
"An exception is throw to let you know that Xpetra::EpetraCrsMatrixT->apply() do not take into account the UseTranspose() parameter of Epetra_CrsMatrix.");
2089 RCP<Epetra_MultiVector> epY = eY.getEpetra_MultiVector();
2092 RCP<Epetra_MultiVector> tmp = Teuchos::rcp(
new Epetra_MultiVector(*epY));
2093 tmp->PutScalar(0.0);
2094 XPETRA_ERR_CHECK(mtx_->Multiply(eTrans, *eX.getEpetra_MultiVector(), *tmp));
2100 void apply(
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &X,
MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &Y, Teuchos::ETransp mode,
Scalar alpha,
Scalar beta,
bool sumInterfaceValues,
const RCP<
Import<LocalOrdinal, GlobalOrdinal, Node> > ®ionInterfaceImporter,
const Teuchos::ArrayRCP<LocalOrdinal> ®ionInterfaceLIDs)
const {
2105 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getDomainMap()
const {
2107 return toXpetra<GlobalOrdinal, Node>(mtx_->DomainMap());
2111 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getRangeMap()
const {
2113 return toXpetra<GlobalOrdinal, Node>(mtx_->RangeMap());
2126 std::ostringstream oss;
2129 oss <<
"{status = fill complete"
2135 oss <<
"{status = fill not complete"
2143 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default)
const {
2149 using Teuchos::VERB_DEFAULT;
2150 using Teuchos::VERB_EXTREME;
2151 using Teuchos::VERB_HIGH;
2152 using Teuchos::VERB_LOW;
2153 using Teuchos::VERB_MEDIUM;
2154 using Teuchos::VERB_NONE;
2155 Teuchos::EVerbosityLevel vl = verbLevel;
2156 if (vl == VERB_DEFAULT) vl = VERB_LOW;
2157 RCP<const Comm<int> > comm = this->
getComm();
2158 const int myImageID = comm->getRank(),
2159 numImages = comm->getSize();
2164 width = std::max<size_t>(width, 11) + 2;
2165 Teuchos::OSTab tab(out);
2173 if (vl != VERB_NONE) {
2174 if (myImageID == 0) out << this->
description() << std::endl;
2180 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
2181 if (myImageID == 0) out <<
"\nRow map: " << std::endl;
2186 if (myImageID == 0) out <<
"\nColumn map is row map.";
2188 if (myImageID == 0) out <<
"\nColumn map: " << std::endl;
2194 if (myImageID == 0) out <<
"\nDomain map is row map.";
2196 if (myImageID == 0) out <<
"\nDomain map is row map.";
2198 if (myImageID == 0) out <<
"\nDomain map: " << std::endl;
2204 if (myImageID == 0) out <<
"\nRange map is domain map." << std::endl;
2206 if (myImageID == 0) out <<
"\nRange map is row map." << std::endl;
2208 if (myImageID == 0) out <<
"\nRange map: " << std::endl;
2212 if (myImageID == 0) out << std::endl;
2215 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
2216 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
2217 if (myImageID == imageCtr) {
2218 out <<
"Node ID = " << imageCtr << std::endl;
2240 if (vl == VERB_HIGH || vl == VERB_EXTREME) {
2241 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
2242 if (myImageID == imageCtr) {
2243 out << std::setw(width) <<
"Node ID"
2244 << std::setw(width) <<
"Global Row"
2245 << std::setw(width) <<
"Num Entries";
2246 if (vl == VERB_EXTREME) {
2247 out << std::setw(width) <<
"(Index,Value)";
2253 out << std::setw(width) << myImageID
2254 << std::setw(width) << gid
2255 << std::setw(width) << nE;
2256 if (vl == VERB_EXTREME) {
2258 ArrayView<const GlobalOrdinal> rowinds;
2259 ArrayView<const Scalar> rowvals;
2261 for (
size_t j = 0; j < nE; ++j) {
2262 out <<
" (" << rowinds[j]
2263 <<
", " << rowvals[j]
2267 ArrayView<const LocalOrdinal> rowinds;
2268 ArrayView<const Scalar> rowvals;
2270 for (
size_t j = 0; j < nE; ++j) {
2271 out <<
" (" <<
getColMap()->getGlobalElement(rowinds[j])
2272 <<
", " << rowvals[j]
2289 Teuchos::LabeledObject::setObjectLabel(objectLabel);
2290 mtx_->SetLabel(objectLabel.c_str());
2296 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(*(matrix.mtx_))))
2297 , isFillResumed_(false) {}
2303 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getMap()
const {
2305 return toXpetra<GlobalOrdinal, Node>(mtx_->Map());
2316 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
2317 int err = mtx_->Import(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
2318 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
2329 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
2330 int err = mtx_->Export(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
2331 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
2342 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
2343 int err = mtx_->Import(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
2344 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
2355 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
2356 int err = mtx_->Export(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
2357 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
2362 const Epetra_Map *newMapEpetra = (!newMap.is_null()) ? &toEpetra<GlobalOrdinal, Node>(newMap) : 0;
2363 int err = mtx_->RemoveEmptyProcessesInPlace(newMapEpetra);
2364 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Caught nonzero error code " + std::to_string(err) +
" returned by Epetra.");
2378 , isFillResumed_(false) {}
2386 #ifdef HAVE_XPETRA_TPETRA
2391 const int numRows = matrix->NumMyRows();
2392 const int numCols = matrix->NumMyCols();
2393 const int nnz = matrix->NumMyNonzeros();
2398 int rv = matrix->ExtractCrsDataPointers(rowptr, colind, vals);
2399 TEUCHOS_TEST_FOR_EXCEPTION(rv, std::runtime_error,
"Xpetra::CrsMatrix<>::getLocalMatrix: failed in ExtractCrsDataPointers");
2402 typename local_matrix_type::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing(
"local row map"), numRows + 1);
2403 for (
size_t i = 0; i < kokkosRowPtr.size(); i++)
2404 kokkosRowPtr(i) = Teuchos::asSafe<typename local_matrix_type::row_map_type::value_type>(rowptr[i]);
2407 typename local_matrix_type::index_type kokkosColind(colind, nnz);
2408 typename local_matrix_type::values_type kokkosVals(vals, nnz);
2416 const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind,
2417 const typename local_matrix_type::values_type &val) {
2420 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
2422 "An exception is thrown to let you know that you mismatched your pointers.");
2425 if (val.size() > 0) {
2427 "An exception is thrown to let you know that you mismatched your pointers.");
2429 "An exception is thrown to let you know that you mismatched your pointers.");
2436 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
2437 myRowptr.Resize(N + 1);
2438 for (
size_t i = 0; i < N + 1; i++)
2439 myRowptr[i] = Teuchos::as<int>(ptr(i));
2447 #warning "Xpetra Kokkos interface for CrsMatrix is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
2456 Scalar one = Teuchos::ScalarTraits<Scalar>::one(), negone = -one;
2458 R.
update(one, B, negone);
2468 #endif // #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
2472 #define XPETRA_EPETRACRSMATRIX_SHORT
2473 #endif // XPETRA_EPETRACRSMATRIX_HPP
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
size_t getLocalNumCols() const
Returns the number of columns connected to the locally owned rows of this matrix. ...
void setObjectLabel(const std::string &objectLabel)
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Kokkos::View< const size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged > &offsets) const
void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values) const
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &RowExporter, const Teuchos::RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > DomainExporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &RowImporter, const Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > DomainImporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
Get the underlying Epetra matrix.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying row and column Maps and number of entries in each row.
size_t getLocalNumEntries() const
Returns the local number of entries in this matrix.
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
virtual ~EpetraCrsMatrixT()
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor for a fused import.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
void getAllValues(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind, ArrayRCP< const Scalar > &values) const
Gets the 1D pointer arrays of the graph.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
EpetraCrsMatrixT(const Teuchos::RCP< Epetra_CrsMatrix > &mtx)
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
size_t getLocalNumRows() const
Returns the number of matrix rows owned on the calling node.
size_t getLocalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values) const
Extract a const, non-persisting view of local indices in a specified row of the matrix.
CrsMatrix< double, int, GlobalOrdinal, Node >::local_ordinal_type LocalOrdinal
void allocateAllValues(size_t numNonZeros, ArrayRCP< size_t > &rowptr, ArrayRCP< LocalOrdinal > &colind, ArrayRCP< Scalar > &values)
Allocates and returns ArrayRCPs of the Crs arrays — This is an Xpetra-only routine.
void residual(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R) const
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
void setAllValues(const typename local_matrix_type::row_map_type &ptr, const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind, const typename local_matrix_type::values_type &val)
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
CrsMatrix< double, int, GlobalOrdinal, Node >::local_ordinal_type LocalOrdinal
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &RowImporter, const Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > DomainImporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying column Map and number of entries in each row.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
Sets the 1D pointer arrays of the graph.
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
void resumeFill(const RCP< ParameterList > ¶ms=null)
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
void getAllValues(ArrayRCP< Scalar > &values)
void expertStaticFillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &importer=Teuchos::null, const RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > &exporter=Teuchos::null, const RCP< ParameterList > &=Teuchos::null)
Expert static fill complete.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
void allocateAllValues(size_t numNonZeros, ArrayRCP< size_t > &rowptr, ArrayRCP< LocalOrdinal > &colind, ArrayRCP< Scalar > &values)
void replaceDiag(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag)
bool hasMatrix() const
Does this have an underlying matrix.
RCP< Epetra_CrsMatrix > mtx_
The underlying actual matrix object.
void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView< LocalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
Extract a list of entries in a specified local row of the matrix. Put into storage allocated by calli...
void fillComplete(const RCP< ParameterList > ¶ms=Teuchos::null)
Signal that data entry is complete.
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
EpetraCrsMatrixT(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalarThis.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor for a fused export.
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::node_type node_type
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
size_t getLocalNumRows() const
Returns the number of matrix rows owned on the calling node.
LocalOrdinal GetStorageBlockSize() const
Returns the block size of the storage mechanism, which is usually 1, except for Tpetra::BlockCrsMatri...
std::string description() const
A simple one-line description of this object.
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::node_type node_type
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Kokkos::View< const size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged > &) const
Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets...
local_matrix_type getLocalMatrixDevice() const
Compatibility layer for accessing the matrix data through a Kokkos interface.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified (locally owned) global row...
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
Exception throws to report errors in the internal logical of the program.
LocalOrdinal local_ordinal_type
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
size_t getLocalNumRows() const
Returns the number of matrix rows owned on the calling node.
EpetraCrsMatrixT(const EpetraCrsMatrixT &matrix)
virtual ~EpetraCrsMatrixT()
Destructor.
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::node_type node_type
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_type local_matrix_type
EpetraCrsMatrixT(const EpetraCrsMatrixT &matrix)
Deep copy constructor.
void replaceDomainMapAndImporter(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newDomainMap, Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &newImporter)
Replaces the current domainMap and importer with the user-specified objects.
size_t getLocalNumCols() const
Returns the number of columns connected to the locally owned rows of this matrix. ...
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
Returns the Map associated with the domain of this operator. This will be null until fillComplete() i...
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying fixed number of entries for each row.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
std::string description() const
A simple one-line description of this object.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Teuchos::ArrayView< const size_t > &) const
Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets...
EpetraCrsMatrixT(const local_matrix_type &lclMatrix, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=null)
virtual void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)=0
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
const RCP< const Comm< int > > getComm() const
Returns the communicator.
void fillComplete(const RCP< ParameterList > ¶ms=Teuchos::null)
Signal that data entry is complete.
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using local IDs.
void resumeFill(const RCP< ParameterList > &=Teuchos::null)
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Kokkos::View< const size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged > &) const
Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets...
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using global IDs.
void replaceDomainMapAndImporter(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newDomainMap, Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &newImporter)
Replaces the current domainMap and importer with the user-specified objects.
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const
Extract a const, non-persisting view of global indices in a specified row of the matrix.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const local_matrix_type &lclMatrix, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=null)
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
Get the underlying Epetra matrix.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
void setAllToScalar(const Scalar &alpha)
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying (possibly different) number of entries in each row.
bool hasMatrix() const
Does this have an underlying matrix.
void expertStaticFillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &importer=Teuchos::null, const RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > &exporter=Teuchos::null, const RCP< ParameterList > &=Teuchos::null)
Expert static fill complete.
size_t getLocalNumEntries() const
Returns the local number of entries in this matrix.
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
Computes the sparse matrix-multivector multiplication.
virtual ~EpetraCrsMatrixT()
Destructor.
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalarThis.
std::string description() const
A simple one-line description of this object.
size_t getLocalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
#define XPETRA_ERR_CHECK(arg)
void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView< GlobalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
Extract a list of entries in a specified global row of this matrix. Put into pre-allocated storage...
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
Returns the Map associated with the range of this operator, which must be compatible with Y...
size_t getLocalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values) const
Extract a const, non-persisting view of local indices in a specified row of the matrix.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying fixed number of entries for each row.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified (locally owned) global row...
const RCP< const Comm< int > > getComm() const
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &) const
Get offsets of the diagonal entries in the matrix.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
LocalOrdinal GetStorageBlockSize() const
Returns the block size of the storage mechanism, which is usually 1, except for Tpetra::BlockCrsMatri...
void getAllValues(ArrayRCP< Scalar > &values)
Gets the 1D pointer arrays of the graph.
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
Get the underlying Epetra matrix.
local_matrix_type::HostMirror getLocalMatrixHost() const
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &RowImporter, const Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > DomainImporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
bool isFillActive() const
Returns true if the matrix is in edit mode.
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
Get the underlying Epetra matrix.
EpetraCrsMatrixT(const local_matrix_type &lclMatrix, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=null)
EpetraCrsMatrixT(const EpetraCrsMatrixT &matrix)
Deep copy constructor.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &RowExporter, const Teuchos::RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > DomainExporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
void getAllValues(ArrayRCP< Scalar > &values)
Gets the 1D pointer arrays of the graph.
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
void replaceDiag(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag)
Replace the diagonal entries of the matrix.
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode, Scalar alpha, Scalar beta, bool sumInterfaceValues, const RCP< Import< LocalOrdinal, GlobalOrdinal, Node > > ®ionInterfaceImporter, const Teuchos::ArrayRCP< LocalOrdinal > ®ionInterfaceLIDs) const
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying (possibly different) number of entries in each row.
void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView< GlobalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
void allocateAllValues(size_t numNonZeros, ArrayRCP< size_t > &rowptr, ArrayRCP< LocalOrdinal > &colind, ArrayRCP< Scalar > &values)
Allocates and returns ArrayRCPs of the Crs arrays — This is an Xpetra-only routine.
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
void getAllValues(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind, ArrayRCP< const Scalar > &values) const
Gets the 1D pointer arrays of the graph.
void residual(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R) const
void replaceDiag(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag)
Replace the diagonal entries of the matrix.
Exception throws when you call an unimplemented method of Xpetra.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
The Map describing the parallel distribution of this object.
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
size_t getLocalNumCols() const
Returns the number of matrix columns owned on the calling node.
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const
Extract a const, non-persisting view of global indices in a specified row of the matrix.
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
#define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
Sets the 1D pointer arrays of the graph.
size_t global_size_t
Global size_t object.
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_type local_matrix_type
void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView< GlobalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
Extract a list of entries in a specified global row of this matrix. Put into pre-allocated storage...
void expertStaticFillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &importer=Teuchos::null, const RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > &exporter=Teuchos::null, const RCP< ParameterList > ¶ms=Teuchos::null)
EpetraCrsMatrixT(const Teuchos::RCP< Epetra_CrsMatrix > &mtx)
EpetraCrsMatrixT constructor to wrap a Epetra_CrsMatrix object.
LocalOrdinal GetStorageBlockSize() const
Returns the block size of the storage mechanism, which is usually 1, except for Tpetra::BlockCrsMatri...
const RCP< const Comm< int > > getComm() const
Returns the communicator.
local_matrix_type getLocalMatrixDevice() const
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
void fillComplete(const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete.
size_t getLocalNumEntries() const
Returns the local number of entries in this matrix.
#define XPETRA_RCP_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor for a fused import.
void setObjectLabel(const std::string &objectLabel)
void scale(const Scalar &alpha)
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &RowExporter, const Teuchos::RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > DomainExporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_type local_matrix_type
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using global IDs.
bool hasMatrix() const
Does this have an underlying matrix.
void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView< LocalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
Extract a list of entries in a specified local row of the matrix. Put into storage allocated by calli...
bool isFillActive() const
Returns true if the matrix is in edit mode.
EpetraCrsMatrixT(const Teuchos::RCP< Epetra_CrsMatrix > &mtx)
EpetraCrsMatrixT constructor to wrap a Epetra_CrsMatrix object.
void residual(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R) const
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=null)
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
Returns the Map associated with the domain of this operator. This will be null until fillComplete() i...
EpetraCrsMatrixT(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying a previously constructed graph.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying a previously constructed graph.
bool isFillActive() const
Returns true if the matrix is in edit mode.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
CombineMode
Xpetra::Combine Mode enumerable type.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
Returns the Map associated with the range of this operator, which must be compatible with Y...
#define XPETRA_MONITOR(funcName)
void setAllValues(const typename local_matrix_type::row_map_type &ptr, const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind, const typename local_matrix_type::values_type &val)
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
void setAllValues(const typename local_matrix_type::row_map_type &ptr, const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind, const typename local_matrix_type::values_type &val)
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &) const
Get offsets of the diagonal entries in the matrix.
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
Computes the sparse matrix-multivector multiplication.
RCP< Epetra_CrsMatrix > mtx_
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap)
Constructor for empty DynamicProfile matrix (no space is preallocated).
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode, Scalar alpha, Scalar beta, bool sumInterfaceValues, const RCP< Import< LocalOrdinal, GlobalOrdinal, Node > > ®ionInterfaceImporter, const Teuchos::ArrayRCP< LocalOrdinal > ®ionInterfaceLIDs) const
KokkosSparse::CrsMatrix< impl_scalar_type, LocalOrdinal, execution_space, void, typename local_graph_type::size_type > local_matrix_type
The specialization of Kokkos::CrsMatrix that represents the part of the sparse matrix on each MPI pro...
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Teuchos::ArrayView< const size_t > &) const
Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets...
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Teuchos::ArrayView< const size_t > &offsets) const
CrsMatrix< double, int, GlobalOrdinal, Node >::local_ordinal_type LocalOrdinal
local_matrix_type::HostMirror getLocalMatrixHost() const
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries in the specified global row.
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=Teuchos::null)
Signal that data entry is complete, specifying domain and range maps.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode, Scalar alpha, Scalar beta, bool sumInterfaceValues, const RCP< Import< LocalOrdinal, GlobalOrdinal, Node > > ®ionInterfaceImporter, const Teuchos::ArrayRCP< LocalOrdinal > ®ionInterfaceLIDs) const
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying column Map and fixed number of entries for each row.
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=Teuchos::null)
Signal that data entry is complete, specifying domain and range maps.
void getAllValues(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind, ArrayRCP< const Scalar > &values) const
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying column Map and fixed number of entries for each row.
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
bool isFillResumed_
Flag to keep track of fill status.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor for a fused export.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
Returns the Map associated with the domain of this operator. This will be null until fillComplete() i...
void setObjectLabel(const std::string &objectLabel)
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView< LocalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const local_matrix_type &lclMatrix, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=null)
Constructor specifying column Map and a local matrix, which the resulting CrsMatrix views...
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
Returns the Map associated with the range of this operator, which must be compatible with Y...
EpetraGlobalOrdinal GlobalOrdinal
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using local IDs.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
EpetraCrsMatrixT(const local_matrix_type &lclMatrix, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=null)
void resumeFill(const RCP< ParameterList > &=Teuchos::null)
void replaceDomainMapAndImporter(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newDomainMap, Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &newImporter)