10 #ifndef XPETRA_EPETRACRSMATRIX_HPP
11 #define XPETRA_EPETRACRSMATRIX_HPP
15 #ifdef HAVE_XPETRA_TPETRA
16 #include <Kokkos_Core.hpp>
23 #include <Epetra_CrsMatrix.h>
24 #include <Epetra_Map.h>
31 #include "Xpetra_MapFactory.hpp"
36 #if defined(XPETRA_ENABLE_DEPRECATED_CODE)
38 #if defined(Xpetra_SHOW_DEPRECATED_WARNINGS)
39 #warning "The header file Trilinos/packages/xpetra/src/CrsMatrix/Xpetra_EpetraCrsMatrix.hpp is deprecated."
43 #error "The header file Trilinos/packages/xpetra/src/CrsMatrix/Xpetra_EpetraCrsMatrix.hpp is deprecated."
49 template <
class EpetraGlobalOrdinal,
class Node>
51 :
public CrsMatrix<double, int, EpetraGlobalOrdinal, Node> {
56 #ifdef HAVE_XPETRA_TPETRA
64 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
68 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
77 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = Teuchos::null) {
79 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
85 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = Teuchos::null) {
87 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
94 const Teuchos::RCP<Teuchos::ParameterList> ¶ms) {
96 "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) {
105 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
107 #ifdef HAVE_XPETRA_TPETRA
111 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = null) {
113 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
121 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = null) {
123 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
134 void allocateAllValues(
size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind, ArrayRCP<Scalar> &values) {}
135 void setAllValues(
const ArrayRCP<size_t> &rowptr,
const ArrayRCP<LocalOrdinal> &colind,
const ArrayRCP<Scalar> &values) {}
136 void getAllValues(ArrayRCP<const size_t> &rowptr, ArrayRCP<const LocalOrdinal> &colind, ArrayRCP<const Scalar> &values)
const {}
143 const RCP<ParameterList> ¶ms = Teuchos::null) {}
149 const RCP<const Comm<int> >
getComm()
const {
return Teuchos::null; }
150 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getRowMap()
const {
return Teuchos::null; }
151 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getColMap()
const {
return Teuchos::null; }
152 RCP<const CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
getCrsGraph()
const {
return Teuchos::null; }
167 typename ScalarTraits<Scalar>::magnitudeType
getFrobeniusNorm()
const {
return ScalarTraits<Scalar>::magnitude(ScalarTraits<Scalar>::zero()); }
181 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 {}
182 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 {}
183 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getDomainMap()
const {
return Teuchos::null; }
184 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getRangeMap()
const {
return Teuchos::null; }
187 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default)
const {}
192 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
195 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getMap()
const {
return Teuchos::null; }
205 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
209 #ifdef HAVE_XPETRA_TPETRA
212 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
216 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
220 const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind,
221 const typename local_matrix_type::values_type &val) {
223 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
230 #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."
237 Scalar one = Teuchos::ScalarTraits<Scalar>::one(), negone = -one;
244 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
247 :
public CrsMatrix<double, int, int, EpetraNode> {
254 #ifdef HAVE_XPETRA_TPETRA
266 , isFillResumed_(false) {}
271 , isFillResumed_(false) {}
275 : isFillResumed_(false) {
276 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
277 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
283 , isFillResumed_(false) {}
287 : isFillResumed_(false) {
288 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
289 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
295 , isFillResumed_(false) {}
302 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = Teuchos::null)
303 : isFillResumed_(false) {
307 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
308 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
311 bool restrictComm =
false;
312 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
313 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), myDomainMap, myRangeMap, restrictComm));
314 if (restrictComm && mtx_->NumMyRows() == 0)
315 mtx_ = Teuchos::null;
323 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = Teuchos::null)
324 : isFillResumed_(false) {
328 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
329 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
332 bool restrictComm =
false;
333 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
335 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), myDomainMap, myRangeMap, restrictComm));
343 const Teuchos::RCP<Teuchos::ParameterList> ¶ms)
344 : isFillResumed_(false) {
349 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
350 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
353 bool restrictComm =
false;
354 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
355 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), tdImporter->getEpetra_Import().get(), myDomainMap, myRangeMap, restrictComm));
356 if (restrictComm && mtx_->NumMyRows() == 0)
357 mtx_ = Teuchos::null;
365 const Teuchos::RCP<Teuchos::ParameterList> ¶ms)
366 : isFillResumed_(false) {
371 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
372 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
375 bool restrictComm =
false;
376 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
378 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), tdExporter->getEpetra_Export().get(), myDomainMap, myRangeMap, restrictComm));
381 #ifdef HAVE_XPETRA_TPETRA
408 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = null)
409 :
EpetraCrsMatrixT(lclMatrix, rowMap, colMap, Teuchos::null, Teuchos::null, params) {}
417 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = null) {
420 typedef typename local_matrix_type::value_type value_type;
421 typedef typename local_matrix_type::ordinal_type ordinal_type;
424 ordinal_type lclNumRows = lclMatrix.numRows();
425 ordinal_type lclNumCols = lclMatrix.numCols();
429 "Xpetra::EpetraCrsMatrixT: number of rows in local matrix and number of local entries in row map do not match!");
431 "Xpetra::EpetraCrsMatrixT: number of columns in local matrix and number of local entries in column map do not match!");
433 Teuchos::ArrayRCP<size_t> NumEntriesPerRowToAlloc(lclNumRows);
434 for (ordinal_type r = 0; r < lclNumRows; ++r) {
436 auto rowview = lclMatrix.row(r);
437 NumEntriesPerRowToAlloc[r] = rowview.length;
441 isFillResumed_ =
false;
442 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
443 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
446 for (ordinal_type r = 0; r < lclNumRows; ++r) {
448 auto rowview = lclMatrix.row(r);
451 Teuchos::ArrayRCP<ordinal_type> indout(rowview.length, Teuchos::ScalarTraits<ordinal_type>::zero());
452 Teuchos::ArrayRCP<value_type> valout(rowview.length, Teuchos::ScalarTraits<value_type>::zero());
454 for (ordinal_type c = 0; c < rowview.length; c++) {
455 value_type value = rowview.value(c);
456 ordinal_type colidx = rowview.colidx(c);
459 "Xpetra::EpetraCrsMatrixT: local matrix contains column elements which are not in the provided column map!");
464 insertLocalValues(r, indout.view(0, indout.size()), valout.view(0, valout.size()));
468 if (!domainMap.is_null() && !rangeMap.is_null())
486 XPETRA_ERR_CHECK(mtx_->InsertGlobalValues(globalRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
492 XPETRA_ERR_CHECK(mtx_->InsertMyValues(localRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
500 const std::string tfecfFuncName(
"replaceGlobalValues");
501 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!
isFillActive(), std::runtime_error,
502 ": Fill must be active in order to call this method. If you have already "
503 "called fillComplete(), you need to call resumeFill() before you can "
506 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
507 std::runtime_error,
": values.size() must equal indices.size().");
510 XPETRA_ERR_CHECK(mtx_->ReplaceGlobalValues(globalRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
518 const std::string tfecfFuncName(
"replaceLocalValues");
519 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!
isFillActive(), std::runtime_error,
520 ": Fill must be active in order to call this method. If you have already "
521 "called fillComplete(), you need to call resumeFill() before you can "
524 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
525 std::runtime_error,
": values.size() must equal indices.size().");
528 XPETRA_ERR_CHECK(mtx_->ReplaceMyValues(localRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
534 mtx_->PutScalar(alpha);
545 void allocateAllValues(
size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind, ArrayRCP<Scalar> &values) {
556 bool ownMemory =
false;
560 Epetra_IntSerialDenseVector &myColind = mtx_->ExpertExtractIndices();
561 myColind.Resize(numNonZeros);
562 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
566 double *&myValues = mtx_->ExpertExtractValues();
568 myValues =
new double[numNonZeros];
569 values = Teuchos::arcp(myValues, lowerOffset, numNonZeros, ownMemory);
573 void setAllValues(
const ArrayRCP<size_t> &rowptr,
const ArrayRCP<LocalOrdinal> &colind,
const ArrayRCP<Scalar> &values) {
578 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
580 "An exception is thrown to let you know that you mismatched your pointers.");
583 if (values.size() > 0) {
585 "An exception is thrown to let you know that you mismatched your pointers.");
587 "An exception is thrown to let you know that you mismatched your pointers.");
594 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
595 myRowptr.Resize(N + 1);
596 for (
size_t i = 0; i < N + 1; i++)
597 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
601 void getAllValues(ArrayRCP<const size_t> &rowptr, ArrayRCP<const LocalOrdinal> &colind, ArrayRCP<const Scalar> &values)
const {
605 bool ownMemory =
false;
612 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
613 rowptr.resize(n + 1);
614 for (
size_t i = 0; i < n + 1; i++)
615 (*const_cast<size_t *>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
618 colind = Teuchos::arcp(mtx_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
621 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
629 bool ownMemory =
false;
633 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
644 const RCP<ParameterList> & = Teuchos::null) {
648 isFillResumed_ =
false;
651 const Epetra_Import *myimport = 0;
652 const Epetra_Export *myexport = 0;
654 if (!importer.is_null()) {
656 myimport = eImporter.getEpetra_Import().getRawPtr();
658 if (!exporter.is_null()) {
660 myexport = eExporter.getEpetra_Export().getRawPtr();
663 rv = mtx_->ExpertStaticFillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), myimport, myexport);
665 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error,
"Xpetra::EpetraCrsMatrixT::expertStaticFillComplete FAILED!");
673 void resumeFill(
const RCP<ParameterList> & = Teuchos::null) {
677 isFillResumed_ =
true;
685 isFillResumed_ =
false;
687 bool doOptimizeStorage =
true;
688 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
689 mtx_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), doOptimizeStorage);
697 if (isFillResumed_ ==
true) {
698 isFillResumed_ =
false;
702 bool doOptimizeStorage =
true;
703 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
704 mtx_->FillComplete(doOptimizeStorage);
712 const RCP<const Epetra_Import> &myImport = eImporter.getEpetra_Import();
714 if (myImport == Teuchos::null)
715 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), 0);
717 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), &*myImport);
718 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error,
"Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter FAILED!");
733 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getRowMap()
const {
735 return toXpetra<GlobalOrdinal, Node>(mtx_->RowMap());
739 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getColMap()
const {
741 return toXpetra<GlobalOrdinal, Node>(mtx_->ColMap());
745 RCP<const CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
getCrsGraph()
const {
747 return toXpetra<GlobalOrdinal, Node>(mtx_->Graph());
753 return mtx_->NumGlobalRows64();
759 return mtx_->NumGlobalCols64();
765 return mtx_->NumMyRows();
771 return mtx_->NumMyCols();
777 return mtx_->NumGlobalNonzeros64();
783 return mtx_->NumMyNonzeros();
789 return mtx_->NumMyEntries(localRow);
795 return mtx_->NumGlobalEntries(globalRow);
801 return mtx_->GlobalMaxNumEntries();
807 return mtx_->MaxNumEntries();
813 return mtx_->IndicesAreLocal();
819 return mtx_->IndicesAreGlobal();
828 return mtx_->Filled();
840 return mtx_->NormFrobenius();
854 XPETRA_ERR_CHECK(mtx_->ExtractMyRowCopy(LocalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
855 NumEntries = numEntries;
863 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowCopy(GlobalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
864 NumEntries = numEntries;
875 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowView(GlobalRow, numEntries, eValues, eIndices));
876 if (numEntries == 0) {
881 indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
882 values = ArrayView<const double>(eValues, numEntries);
893 XPETRA_ERR_CHECK(mtx_->ExtractMyRowView(LocalRow, numEntries, eValues, eIndices));
894 if (numEntries == 0) {
899 indices = ArrayView<const int>(eIndices, numEntries);
900 values = ArrayView<const double>(eValues, numEntries);
906 XPETRA_ERR_CHECK(mtx_->ExtractDiagonalCopy(toEpetra<GlobalOrdinal, Node>(diag)));
926 mtx_->ReplaceDiagonalValues(toEpetra<GlobalOrdinal, Node>(diag));
942 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 {
950 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");
954 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.");
956 RCP<Epetra_MultiVector> epY = eY.getEpetra_MultiVector();
959 RCP<Epetra_MultiVector> tmp = Teuchos::rcp(
new Epetra_MultiVector(*epY));
961 XPETRA_ERR_CHECK(mtx_->Multiply(eTrans, *eX.getEpetra_MultiVector(), *tmp));
968 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 {
973 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getDomainMap()
const {
975 return toXpetra<GlobalOrdinal, Node>(mtx_->DomainMap());
979 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getRangeMap()
const {
981 return toXpetra<GlobalOrdinal, Node>(mtx_->RangeMap());
994 std::ostringstream oss;
997 oss <<
"{status = fill complete"
1003 oss <<
"{status = fill not complete"
1011 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default)
const {
1017 using Teuchos::VERB_DEFAULT;
1018 using Teuchos::VERB_EXTREME;
1019 using Teuchos::VERB_HIGH;
1020 using Teuchos::VERB_LOW;
1021 using Teuchos::VERB_MEDIUM;
1022 using Teuchos::VERB_NONE;
1023 Teuchos::EVerbosityLevel vl = verbLevel;
1024 if (vl == VERB_DEFAULT) vl = VERB_LOW;
1025 RCP<const Comm<int> > comm = this->
getComm();
1026 const int myImageID = comm->getRank(),
1027 numImages = comm->getSize();
1032 width = std::max<size_t>(width, 11) + 2;
1033 Teuchos::OSTab tab(out);
1041 if (vl != VERB_NONE) {
1042 if (myImageID == 0) out << this->
description() << std::endl;
1048 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
1049 if (myImageID == 0) out <<
"\nRow map: " << std::endl;
1054 if (myImageID == 0) out <<
"\nColumn map is row map.";
1056 if (myImageID == 0) out <<
"\nColumn map: " << std::endl;
1062 if (myImageID == 0) out <<
"\nDomain map is row map.";
1064 if (myImageID == 0) out <<
"\nDomain map is row map.";
1066 if (myImageID == 0) out <<
"\nDomain map: " << std::endl;
1072 if (myImageID == 0) out <<
"\nRange map is domain map." << std::endl;
1074 if (myImageID == 0) out <<
"\nRange map is row map." << std::endl;
1076 if (myImageID == 0) out <<
"\nRange map: " << std::endl;
1080 if (myImageID == 0) out << std::endl;
1083 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
1084 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1085 if (myImageID == imageCtr) {
1086 out <<
"Node ID = " << imageCtr << std::endl;
1108 if (vl == VERB_HIGH || vl == VERB_EXTREME) {
1109 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1110 if (myImageID == imageCtr) {
1111 out << std::setw(width) <<
"Node ID"
1112 << std::setw(width) <<
"Global Row"
1113 << std::setw(width) <<
"Num Entries";
1114 if (vl == VERB_EXTREME) {
1115 out << std::setw(width) <<
"(Index,Value)";
1121 out << std::setw(width) << myImageID
1122 << std::setw(width) << gid
1123 << std::setw(width) << nE;
1124 if (vl == VERB_EXTREME) {
1126 ArrayView<const GlobalOrdinal> rowinds;
1127 ArrayView<const Scalar> rowvals;
1129 for (
size_t j = 0; j < nE; ++j) {
1130 out <<
" (" << rowinds[j]
1131 <<
", " << rowvals[j]
1135 ArrayView<const LocalOrdinal> rowinds;
1136 ArrayView<const Scalar> rowvals;
1138 for (
size_t j = 0; j < nE; ++j) {
1139 out <<
" (" <<
getColMap()->getGlobalElement(rowinds[j])
1140 <<
", " << rowvals[j]
1157 Teuchos::LabeledObject::setObjectLabel(objectLabel);
1158 mtx_->SetLabel(objectLabel.c_str());
1164 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(*(matrix.mtx_))))
1165 , isFillResumed_(false) {}
1171 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getMap()
const {
1173 return toXpetra<GlobalOrdinal, Node>(mtx_->Map());
1184 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
1185 int err = mtx_->Import(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
1186 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
1197 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
1198 int err = mtx_->Export(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
1199 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
1210 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
1211 int err = mtx_->Import(*v, *tExporter.getEpetra_Export(),
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, *tExporter.getEpetra_Export(),
toEpetra(CM));
1225 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Caught nonzero error code " + std::to_string(err) +
" returned by Epetra.");
1230 const Epetra_Map *newMapEpetra = (!newMap.is_null()) ? &toEpetra<GlobalOrdinal, Node>(newMap) : 0;
1231 int err = mtx_->RemoveEmptyProcessesInPlace(newMapEpetra);
1232 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Caught nonzero error code " + std::to_string(err) +
" returned by Epetra.");
1246 , isFillResumed_(false) {}
1254 #ifdef HAVE_XPETRA_TPETRA
1260 "Xpetra::EpetraCrsMatrx only available on host for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
1269 const int numRows = matrix->NumMyRows();
1270 const int numCols = matrix->NumMyCols();
1271 const int nnz = matrix->NumMyNonzeros();
1276 int rv = matrix->ExtractCrsDataPointers(rowptr, colind, vals);
1277 TEUCHOS_TEST_FOR_EXCEPTION(rv, std::runtime_error,
"Xpetra::CrsMatrix<>::getLocalMatrix: failed in ExtractCrsDataPointers");
1280 typename local_matrix_type::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing(
"local row map"), numRows + 1);
1281 for (
size_t i = 0; i < kokkosRowPtr.size(); i++)
1282 kokkosRowPtr(i) = Teuchos::asSafe<typename local_matrix_type::row_map_type::value_type>(rowptr[i]);
1285 typename local_matrix_type::index_type kokkosColind(colind, nnz);
1286 typename local_matrix_type::values_type kokkosVals(vals, nnz);
1294 const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind,
1295 const typename local_matrix_type::values_type &val) {
1298 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
1300 "An exception is thrown to let you know that you mismatched your pointers.");
1303 if (val.size() > 0) {
1304 std::cout << ind.data() <<
" " << mtx_->ExpertExtractIndices().Values() << std::endl;
1306 "An exception is thrown to let you know that you mismatched your pointers.");
1308 "An exception is thrown to let you know that you mismatched your pointers.");
1315 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
1316 myRowptr.Resize(N + 1);
1317 for (
size_t i = 0; i < N + 1; i++)
1318 myRowptr[i] = Teuchos::as<int>(ptr(i));
1326 #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."
1334 Scalar one = Teuchos::ScalarTraits<Scalar>::one(), negone = -one;
1337 R.
update(one, B, negone);
1354 #endif //#ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
1356 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
1359 :
public CrsMatrix<double, int, long long, EpetraNode> {
1366 #ifdef HAVE_XPETRA_TPETRA
1378 , isFillResumed_(false) {}
1382 : isFillResumed_(false) {
1383 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
1384 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
1390 , isFillResumed_(false) {}
1394 : isFillResumed_(false) {
1395 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
1396 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
1402 , isFillResumed_(false) {}
1409 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = Teuchos::null)
1410 : isFillResumed_(false) {
1414 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1415 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1418 bool restrictComm =
false;
1419 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
1420 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), myDomainMap, myRangeMap, restrictComm));
1421 if (restrictComm && mtx_->NumMyRows() == 0)
1422 mtx_ = Teuchos::null;
1430 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = Teuchos::null)
1431 : isFillResumed_(false) {
1435 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1436 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1439 bool restrictComm =
false;
1440 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
1442 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), myDomainMap, myRangeMap, restrictComm));
1450 const Teuchos::RCP<Teuchos::ParameterList> ¶ms)
1451 : isFillResumed_(false) {
1456 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1457 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1460 bool restrictComm =
false;
1461 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
1462 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), tdImporter->getEpetra_Import().get(), myDomainMap, myRangeMap, restrictComm));
1463 if (restrictComm && mtx_->NumMyRows() == 0)
1464 mtx_ = Teuchos::null;
1472 const Teuchos::RCP<Teuchos::ParameterList> ¶ms)
1473 : isFillResumed_(false) {
1478 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1479 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1482 bool restrictComm =
false;
1483 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
1485 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), tdExporter->getEpetra_Export().get(), myDomainMap, myRangeMap, restrictComm));
1488 #ifdef HAVE_XPETRA_TPETRA
1512 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = null)
1513 :
EpetraCrsMatrixT(lclMatrix, rowMap, colMap, Teuchos::null, Teuchos::null, params) {}
1521 const Teuchos::RCP<Teuchos::ParameterList> ¶ms = null) {
1524 typedef typename local_matrix_type::value_type value_type;
1525 typedef typename local_matrix_type::ordinal_type ordinal_type;
1528 ordinal_type lclNumRows = lclMatrix.numRows();
1529 ordinal_type lclNumCols = lclMatrix.numCols();
1533 "Xpetra::EpetraCrsMatrixT: number of rows in local matrix and number of local entries in row map do not match!");
1535 "Xpetra::EpetraCrsMatrixT: number of columns in local matrix and number of local entries in column map do not match!");
1537 Teuchos::ArrayRCP<size_t> NumEntriesPerRowToAlloc(lclNumRows);
1538 for (ordinal_type r = 0; r < lclNumRows; ++r) {
1540 auto rowview = lclMatrix.row(r);
1541 NumEntriesPerRowToAlloc[r] = rowview.length;
1545 isFillResumed_ =
false;
1546 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
1547 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
1550 for (ordinal_type r = 0; r < lclNumRows; ++r) {
1552 auto rowview = lclMatrix.row(r);
1555 Teuchos::ArrayRCP<ordinal_type> indout(rowview.length, Teuchos::ScalarTraits<ordinal_type>::zero());
1556 Teuchos::ArrayRCP<value_type> valout(rowview.length, Teuchos::ScalarTraits<value_type>::zero());
1558 for (ordinal_type c = 0; c < rowview.length; c++) {
1559 value_type value = rowview.value(c);
1560 ordinal_type colidx = rowview.colidx(c);
1562 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!");
1567 insertLocalValues(r, indout.view(0, indout.size()), valout.view(0, valout.size()));
1571 if (!domainMap.is_null() && !rangeMap.is_null())
1589 XPETRA_ERR_CHECK(mtx_->InsertGlobalValues(globalRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
1595 XPETRA_ERR_CHECK(mtx_->InsertMyValues(localRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
1603 const std::string tfecfFuncName(
"replaceGlobalValues");
1604 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!
isFillActive(), std::runtime_error,
1605 ": Fill must be active in order to call this method. If you have already "
1606 "called fillComplete(), you need to call resumeFill() before you can "
1609 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
1610 std::runtime_error,
": values.size() must equal indices.size().");
1613 XPETRA_ERR_CHECK(mtx_->ReplaceGlobalValues(globalRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
1621 const std::string tfecfFuncName(
"replaceLocalValues");
1622 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!
isFillActive(), std::runtime_error,
1623 ": Fill must be active in order to call this method. If you have already "
1624 "called fillComplete(), you need to call resumeFill() before you can "
1627 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
1628 std::runtime_error,
": values.size() must equal indices.size().");
1631 XPETRA_ERR_CHECK(mtx_->ReplaceMyValues(localRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
1637 mtx_->PutScalar(alpha);
1648 void allocateAllValues(
size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind, ArrayRCP<Scalar> &values) {
1658 int lowerOffset = 0;
1659 bool ownMemory =
false;
1663 Epetra_IntSerialDenseVector &myColind = mtx_->ExpertExtractIndices();
1664 myColind.Resize(numNonZeros);
1665 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
1669 double *&myValues = mtx_->ExpertExtractValues();
1671 myValues =
new double[numNonZeros];
1672 values = Teuchos::arcp(myValues, lowerOffset, numNonZeros, ownMemory);
1676 void setAllValues(
const ArrayRCP<size_t> &rowptr,
const ArrayRCP<LocalOrdinal> &colind,
const ArrayRCP<Scalar> &values) {
1681 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
1683 "An exception is thrown to let you know that you mismatched your pointers.");
1686 if (values.size() > 0) {
1688 "An exception is thrown to let you know that you mismatched your pointers.");
1690 "An exception is thrown to let you know that you mismatched your pointers.");
1697 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
1698 myRowptr.Resize(N + 1);
1699 for (
size_t i = 0; i < N + 1; i++)
1700 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
1704 void getAllValues(ArrayRCP<const size_t> &rowptr, ArrayRCP<const LocalOrdinal> &colind, ArrayRCP<const Scalar> &values)
const {
1707 int lowerOffset = 0;
1708 bool ownMemory =
false;
1715 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
1716 rowptr.resize(n + 1);
1717 for (
size_t i = 0; i < n + 1; i++)
1718 (*const_cast<size_t *>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
1721 colind = Teuchos::arcp(mtx_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
1724 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
1731 int lowerOffset = 0;
1732 bool ownMemory =
false;
1736 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
1748 const RCP<ParameterList> & = Teuchos::null) {
1752 isFillResumed_ =
false;
1755 const Epetra_Import *myimport = 0;
1756 const Epetra_Export *myexport = 0;
1758 if (!importer.is_null()) {
1760 myimport = eImporter.getEpetra_Import().getRawPtr();
1762 if (!exporter.is_null()) {
1764 myexport = eExporter.getEpetra_Export().getRawPtr();
1767 rv = mtx_->ExpertStaticFillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), myimport, myexport);
1769 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error,
"Xpetra::EpetraCrsMatrixT::expertStaticFillComplete FAILED!");
1781 isFillResumed_ =
true;
1789 if (isFillResumed_ ==
true) {
1790 isFillResumed_ =
false;
1794 bool doOptimizeStorage =
true;
1795 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
1796 mtx_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), doOptimizeStorage);
1804 if (isFillResumed_ ==
true) {
1805 isFillResumed_ =
false;
1809 bool doOptimizeStorage =
true;
1810 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
1811 mtx_->FillComplete(doOptimizeStorage);
1819 const RCP<const Epetra_Import> &myImport = eImporter.getEpetra_Import();
1821 if (myImport == Teuchos::null)
1822 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), 0);
1824 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), &*myImport);
1825 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error,
"Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter FAILED!");
1840 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getRowMap()
const {
1842 return toXpetra<GlobalOrdinal, Node>(mtx_->RowMap());
1846 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getColMap()
const {
1848 return toXpetra<GlobalOrdinal, Node>(mtx_->ColMap());
1852 RCP<const CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
getCrsGraph()
const {
1854 return toXpetra<GlobalOrdinal, Node>(mtx_->Graph());
1860 return mtx_->NumGlobalRows64();
1866 return mtx_->NumGlobalCols64();
1872 return mtx_->NumMyRows();
1878 return mtx_->NumMyCols();
1884 return mtx_->NumGlobalNonzeros64();
1890 return mtx_->NumMyNonzeros();
1896 return mtx_->NumMyEntries(localRow);
1902 return mtx_->NumGlobalEntries(globalRow);
1908 return mtx_->GlobalMaxNumEntries();
1914 return mtx_->MaxNumEntries();
1920 return mtx_->IndicesAreLocal();
1926 return mtx_->IndicesAreGlobal();
1935 return mtx_->Filled();
1947 return mtx_->NormFrobenius();
1960 int numEntries = -1;
1961 XPETRA_ERR_CHECK(mtx_->ExtractMyRowCopy(LocalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
1962 NumEntries = numEntries;
1969 int numEntries = -1;
1970 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowCopy(GlobalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
1971 NumEntries = numEntries;
1982 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowView(GlobalRow, numEntries, eValues, eIndices));
1983 if (numEntries == 0) {
1988 indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
1989 values = ArrayView<const double>(eValues, numEntries);
2000 XPETRA_ERR_CHECK(mtx_->ExtractMyRowView(LocalRow, numEntries, eValues, eIndices));
2001 if (numEntries == 0) {
2006 indices = ArrayView<const int>(eIndices, numEntries);
2007 values = ArrayView<const double>(eValues, numEntries);
2013 mtx_->ExtractDiagonalCopy(toEpetra<GlobalOrdinal, Node>(diag));
2033 mtx_->ReplaceDiagonalValues(toEpetra<GlobalOrdinal, Node>(diag));
2049 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 {
2057 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");
2061 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.");
2063 RCP<Epetra_MultiVector> epY = eY.getEpetra_MultiVector();
2066 RCP<Epetra_MultiVector> tmp = Teuchos::rcp(
new Epetra_MultiVector(*epY));
2067 tmp->PutScalar(0.0);
2068 XPETRA_ERR_CHECK(mtx_->Multiply(eTrans, *eX.getEpetra_MultiVector(), *tmp));
2074 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 {
2079 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getDomainMap()
const {
2081 return toXpetra<GlobalOrdinal, Node>(mtx_->DomainMap());
2085 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getRangeMap()
const {
2087 return toXpetra<GlobalOrdinal, Node>(mtx_->RangeMap());
2100 std::ostringstream oss;
2103 oss <<
"{status = fill complete"
2109 oss <<
"{status = fill not complete"
2117 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default)
const {
2123 using Teuchos::VERB_DEFAULT;
2124 using Teuchos::VERB_EXTREME;
2125 using Teuchos::VERB_HIGH;
2126 using Teuchos::VERB_LOW;
2127 using Teuchos::VERB_MEDIUM;
2128 using Teuchos::VERB_NONE;
2129 Teuchos::EVerbosityLevel vl = verbLevel;
2130 if (vl == VERB_DEFAULT) vl = VERB_LOW;
2131 RCP<const Comm<int> > comm = this->
getComm();
2132 const int myImageID = comm->getRank(),
2133 numImages = comm->getSize();
2138 width = std::max<size_t>(width, 11) + 2;
2139 Teuchos::OSTab tab(out);
2147 if (vl != VERB_NONE) {
2148 if (myImageID == 0) out << this->
description() << std::endl;
2154 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
2155 if (myImageID == 0) out <<
"\nRow map: " << std::endl;
2160 if (myImageID == 0) out <<
"\nColumn map is row map.";
2162 if (myImageID == 0) out <<
"\nColumn map: " << std::endl;
2168 if (myImageID == 0) out <<
"\nDomain map is row map.";
2170 if (myImageID == 0) out <<
"\nDomain map is row map.";
2172 if (myImageID == 0) out <<
"\nDomain map: " << std::endl;
2178 if (myImageID == 0) out <<
"\nRange map is domain map." << std::endl;
2180 if (myImageID == 0) out <<
"\nRange map is row map." << std::endl;
2182 if (myImageID == 0) out <<
"\nRange map: " << std::endl;
2186 if (myImageID == 0) out << std::endl;
2189 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
2190 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
2191 if (myImageID == imageCtr) {
2192 out <<
"Node ID = " << imageCtr << std::endl;
2214 if (vl == VERB_HIGH || vl == VERB_EXTREME) {
2215 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
2216 if (myImageID == imageCtr) {
2217 out << std::setw(width) <<
"Node ID"
2218 << std::setw(width) <<
"Global Row"
2219 << std::setw(width) <<
"Num Entries";
2220 if (vl == VERB_EXTREME) {
2221 out << std::setw(width) <<
"(Index,Value)";
2227 out << std::setw(width) << myImageID
2228 << std::setw(width) << gid
2229 << std::setw(width) << nE;
2230 if (vl == VERB_EXTREME) {
2232 ArrayView<const GlobalOrdinal> rowinds;
2233 ArrayView<const Scalar> rowvals;
2235 for (
size_t j = 0; j < nE; ++j) {
2236 out <<
" (" << rowinds[j]
2237 <<
", " << rowvals[j]
2241 ArrayView<const LocalOrdinal> rowinds;
2242 ArrayView<const Scalar> rowvals;
2244 for (
size_t j = 0; j < nE; ++j) {
2245 out <<
" (" <<
getColMap()->getGlobalElement(rowinds[j])
2246 <<
", " << rowvals[j]
2263 Teuchos::LabeledObject::setObjectLabel(objectLabel);
2264 mtx_->SetLabel(objectLabel.c_str());
2270 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(*(matrix.mtx_))))
2271 , isFillResumed_(false) {}
2277 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getMap()
const {
2279 return toXpetra<GlobalOrdinal, Node>(mtx_->Map());
2290 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
2291 int err = mtx_->Import(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
2292 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
2303 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
2304 int err = mtx_->Export(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
2305 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
2316 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
2317 int err = mtx_->Import(*v, *tExporter.getEpetra_Export(),
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, *tExporter.getEpetra_Export(),
toEpetra(CM));
2331 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
2336 const Epetra_Map *newMapEpetra = (!newMap.is_null()) ? &toEpetra<GlobalOrdinal, Node>(newMap) : 0;
2337 int err = mtx_->RemoveEmptyProcessesInPlace(newMapEpetra);
2338 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Caught nonzero error code " + std::to_string(err) +
" returned by Epetra.");
2352 , isFillResumed_(false) {}
2360 #ifdef HAVE_XPETRA_TPETRA
2365 const int numRows = matrix->NumMyRows();
2366 const int numCols = matrix->NumMyCols();
2367 const int nnz = matrix->NumMyNonzeros();
2372 int rv = matrix->ExtractCrsDataPointers(rowptr, colind, vals);
2373 TEUCHOS_TEST_FOR_EXCEPTION(rv, std::runtime_error,
"Xpetra::CrsMatrix<>::getLocalMatrix: failed in ExtractCrsDataPointers");
2376 typename local_matrix_type::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing(
"local row map"), numRows + 1);
2377 for (
size_t i = 0; i < kokkosRowPtr.size(); i++)
2378 kokkosRowPtr(i) = Teuchos::asSafe<typename local_matrix_type::row_map_type::value_type>(rowptr[i]);
2381 typename local_matrix_type::index_type kokkosColind(colind, nnz);
2382 typename local_matrix_type::values_type kokkosVals(vals, nnz);
2390 const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind,
2391 const typename local_matrix_type::values_type &val) {
2394 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
2396 "An exception is thrown to let you know that you mismatched your pointers.");
2399 if (val.size() > 0) {
2401 "An exception is thrown to let you know that you mismatched your pointers.");
2403 "An exception is thrown to let you know that you mismatched your pointers.");
2410 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
2411 myRowptr.Resize(N + 1);
2412 for (
size_t i = 0; i < N + 1; i++)
2413 myRowptr[i] = Teuchos::as<int>(ptr(i));
2421 #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."
2430 Scalar one = Teuchos::ScalarTraits<Scalar>::one(), negone = -one;
2432 R.
update(one, B, negone);
2442 #endif // #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
2446 #define XPETRA_EPETRACRSMATRIX_SHORT
2447 #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
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
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
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)