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."
49template <
class EpetraGlobalOrdinal,
class Node>
51 :
public CrsMatrix<double, int, EpetraGlobalOrdinal, Node> {
56#ifdef HAVE_XPETRA_TPETRA
66#if KOKKOS_VERSION >= 40799
67 using ATS = KokkosKernels::ArithTraits<Scalar>;
69 using ATS = Kokkos::ArithTraits<Scalar>;
76 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
80 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
91 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
99 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
108 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
117 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
119#ifdef HAVE_XPETRA_TPETRA
125 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
135 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
193 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 {}
194 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 {}
204 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
217 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
221#ifdef HAVE_XPETRA_TPETRA
224 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
226#if KOKKOS_VERSION >= 40799
227 typename local_matrix_type::host_mirror_type getLocalMatrixHost()
const {
232 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
237 const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind,
238 const typename local_matrix_type::values_type &val) {
240 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
247#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."
261#ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
264 :
public CrsMatrix<double, int, int, EpetraNode> {
271#ifdef HAVE_XPETRA_TPETRA
288 , isFillResumed_(false) {}
293 , isFillResumed_(false) {}
297 : isFillResumed_(false) {
305 , isFillResumed_(false) {}
309 : isFillResumed_(false) {
317 , isFillResumed_(false) {}
325 : isFillResumed_(false) {
329 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
330 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
333 bool restrictComm =
false;
334 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
335 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), myDomainMap, myRangeMap, restrictComm));
336 if (restrictComm && mtx_->NumMyRows() == 0)
337 mtx_ = Teuchos::null;
346 : isFillResumed_(false) {
350 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
351 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
354 bool restrictComm =
false;
355 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
357 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), myDomainMap, myRangeMap, restrictComm));
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);
377 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), tdImporter->getEpetra_Import().get(), myDomainMap, myRangeMap, restrictComm));
378 if (restrictComm && mtx_->NumMyRows() == 0)
379 mtx_ = Teuchos::null;
388 : isFillResumed_(false) {
393 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
394 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
397 bool restrictComm =
false;
398 if (!params.
is_null()) restrictComm = params->
get(
"Restrict Communicator", restrictComm);
400 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), tdExporter->getEpetra_Export().get(), myDomainMap, myRangeMap, restrictComm));
403#ifdef HAVE_XPETRA_TPETRA
442 typedef typename local_matrix_type::value_type value_type;
443 typedef typename local_matrix_type::ordinal_type ordinal_type;
446 ordinal_type lclNumRows = lclMatrix.numRows();
447 ordinal_type lclNumCols = lclMatrix.numCols();
451 "Xpetra::EpetraCrsMatrixT: number of rows in local matrix and number of local entries in row map do not match!");
453 "Xpetra::EpetraCrsMatrixT: number of columns in local matrix and number of local entries in column map do not match!");
456 for (ordinal_type r = 0; r < lclNumRows; ++r) {
458 auto rowview = lclMatrix.row(r);
459 NumEntriesPerRowToAlloc[r] = rowview.length;
463 isFillResumed_ =
false;
468 for (ordinal_type r = 0; r < lclNumRows; ++r) {
470 auto rowview = lclMatrix.row(r);
476 for (ordinal_type c = 0; c < rowview.length; c++) {
477 value_type value = rowview.value(c);
478 ordinal_type colidx = rowview.colidx(c);
481 "Xpetra::EpetraCrsMatrixT: local matrix contains column elements which are not in the provided column map!");
486 insertLocalValues(r, indout.
view(0, indout.
size()), valout.
view(0, valout.
size()));
490 if (!domainMap.is_null() && !rangeMap.is_null())
491 this->fillComplete(domainMap, rowMap, params);
493 this->fillComplete(rowMap, rowMap, params);
522 const std::string tfecfFuncName(
"replaceGlobalValues");
524 ": Fill must be active in order to call this method. If you have already "
525 "called fillComplete(), you need to call resumeFill() before you can "
529 std::runtime_error,
": values.size() must equal indices.size().");
540 const std::string tfecfFuncName(
"replaceLocalValues");
542 ": Fill must be active in order to call this method. If you have already "
543 "called fillComplete(), you need to call resumeFill() before you can "
547 std::runtime_error,
": values.size() must equal indices.size().");
556 mtx_->PutScalar(alpha);
575 rowptr.
resize(getLocalNumRows() + 1);
578 bool ownMemory =
false;
583 myColind.
Resize(numNonZeros);
584 colind = Teuchos::arcp(myColind.
Values(), lowerOffset, numNonZeros, ownMemory);
588 double *&myValues = mtx_->ExpertExtractValues();
590 myValues =
new double[numNonZeros];
591 values = Teuchos::arcp(myValues, lowerOffset, numNonZeros, ownMemory);
600 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
602 "An exception is thrown to let you know that you mismatched your pointers.");
605 if (values.
size() > 0) {
607 "An exception is thrown to let you know that you mismatched your pointers.");
609 "An exception is thrown to let you know that you mismatched your pointers.");
614 const size_t N = getLocalNumRows();
618 for (
size_t i = 0; i < N + 1; i++)
619 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
627 bool ownMemory =
false;
629 const size_t n = getLocalNumRows();
630 const size_t nnz = getLocalNumEntries();
636 for (
size_t i = 0; i < n + 1; i++)
637 (*
const_cast<size_t *
>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
640 colind = Teuchos::arcp(mtx_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
643 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
651 bool ownMemory =
false;
653 const size_t nnz = getLocalNumEntries();
655 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
670 isFillResumed_ =
false;
676 if (!importer.is_null()) {
678 myimport = eImporter.getEpetra_Import().getRawPtr();
680 if (!exporter.is_null()) {
682 myexport = eExporter.getEpetra_Export().getRawPtr();
685 rv = mtx_->ExpertStaticFillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), myimport, myexport);
699 isFillResumed_ =
true;
707 isFillResumed_ =
false;
709 bool doOptimizeStorage =
true;
710 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
711 mtx_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), doOptimizeStorage);
719 if (isFillResumed_ ==
true) {
720 isFillResumed_ =
false;
724 bool doOptimizeStorage =
true;
725 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
726 mtx_->FillComplete(doOptimizeStorage);
736 if (myImport == Teuchos::null)
737 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), 0);
739 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), &*myImport);
757 return toXpetra<GlobalOrdinal, Node>(mtx_->RowMap());
763 return toXpetra<GlobalOrdinal, Node>(mtx_->ColMap());
769 return toXpetra<GlobalOrdinal, Node>(mtx_->Graph());
775 return mtx_->NumGlobalRows64();
781 return mtx_->NumGlobalCols64();
787 return mtx_->NumMyRows();
793 return mtx_->NumMyCols();
799 return mtx_->NumGlobalNonzeros64();
805 return mtx_->NumMyNonzeros();
811 return mtx_->NumMyEntries(localRow);
817 return mtx_->NumGlobalEntries(globalRow);
823 return mtx_->GlobalMaxNumEntries();
829 return mtx_->MaxNumEntries();
835 return mtx_->IndicesAreLocal();
841 return mtx_->IndicesAreGlobal();
850 return mtx_->Filled();
856 return !isFillComplete();
862 return mtx_->NormFrobenius();
877 NumEntries = numEntries;
886 NumEntries = numEntries;
897 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowView(GlobalRow, numEntries, eValues, eIndices));
898 if (numEntries == 0) {
915 XPETRA_ERR_CHECK(mtx_->ExtractMyRowView(LocalRow, numEntries, eValues, eIndices));
916 if (numEntries == 0) {
928 XPETRA_ERR_CHECK(mtx_->ExtractDiagonalCopy(toEpetra<GlobalOrdinal, Node>(diag)));
948 mtx_->ReplaceDiagonalValues(toEpetra<GlobalOrdinal, Node>(diag));
964 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 {
983 XPETRA_ERR_CHECK(mtx_->Multiply(eTrans, *eX.getEpetra_MultiVector(), *tmp));
990 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 {
997 return toXpetra<GlobalOrdinal, Node>(mtx_->DomainMap());
1003 return toXpetra<GlobalOrdinal, Node>(mtx_->RangeMap());
1016 std::ostringstream oss;
1018 if (isFillComplete()) {
1019 oss <<
"{status = fill complete"
1020 <<
", global rows = " << getGlobalNumRows()
1021 <<
", global cols = " << getGlobalNumCols()
1022 <<
", global num entries = " << getGlobalNumEntries()
1025 oss <<
"{status = fill not complete"
1026 <<
", global rows = " << getGlobalNumRows()
1046 if (vl == VERB_DEFAULT) vl = VERB_LOW;
1048 const int myImageID = comm->getRank(),
1049 numImages = comm->getSize();
1051 for (
size_t dec = 10; dec < getGlobalNumRows(); dec *= 10) {
1054 width = std::max<size_t>(width, 11) + 2;
1063 if (vl != VERB_NONE) {
1064 if (myImageID == 0) out << this->description() << std::endl;
1066 if (isFillComplete() && myImageID == 0) {
1067 out <<
"Global max number of entries = " << getGlobalMaxNumRowEntries() << std::endl;
1070 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
1071 if (myImageID == 0) out <<
"\nRow map: " << std::endl;
1072 getRowMap()->describe(out, vl);
1074 if (getColMap() != null) {
1075 if (getColMap() == getRowMap()) {
1076 if (myImageID == 0) out <<
"\nColumn map is row map.";
1078 if (myImageID == 0) out <<
"\nColumn map: " << std::endl;
1079 getColMap()->describe(out, vl);
1082 if (getDomainMap() != null) {
1083 if (getDomainMap() == getRowMap()) {
1084 if (myImageID == 0) out <<
"\nDomain map is row map.";
1085 }
else if (getDomainMap() == getColMap()) {
1086 if (myImageID == 0) out <<
"\nDomain map is row map.";
1088 if (myImageID == 0) out <<
"\nDomain map: " << std::endl;
1089 getDomainMap()->describe(out, vl);
1092 if (getRangeMap() != null) {
1093 if (getRangeMap() == getDomainMap()) {
1094 if (myImageID == 0) out <<
"\nRange map is domain map." << std::endl;
1095 }
else if (getRangeMap() == getRowMap()) {
1096 if (myImageID == 0) out <<
"\nRange map is row map." << std::endl;
1098 if (myImageID == 0) out <<
"\nRange map: " << std::endl;
1099 getRangeMap()->describe(out, vl);
1102 if (myImageID == 0) out << std::endl;
1105 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
1106 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1107 if (myImageID == imageCtr) {
1108 out <<
"Node ID = " << imageCtr << std::endl;
1121 out <<
"Node number of entries = " << getLocalNumEntries() << std::endl;
1122 out <<
"Node max number of entries = " << getLocalMaxNumRowEntries() << std::endl;
1130 if (vl == VERB_HIGH || vl == VERB_EXTREME) {
1131 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1132 if (myImageID == imageCtr) {
1133 out << std::setw(width) <<
"Node ID"
1134 << std::setw(width) <<
"Global Row"
1135 << std::setw(width) <<
"Num Entries";
1136 if (vl == VERB_EXTREME) {
1137 out << std::setw(width) <<
"(Index,Value)";
1140 for (
size_t r = 0; r < getLocalNumRows(); ++r) {
1141 const size_t nE = getNumEntriesInLocalRow(r);
1143 out << std::setw(width) << myImageID
1144 << std::setw(width) << gid
1145 << std::setw(width) << nE;
1146 if (vl == VERB_EXTREME) {
1147 if (isGloballyIndexed()) {
1150 getGlobalRowView(gid, rowinds, rowvals);
1151 for (
size_t j = 0; j < nE; ++j) {
1152 out <<
" (" << rowinds[j]
1153 <<
", " << rowvals[j]
1156 }
else if (isLocallyIndexed()) {
1159 getLocalRowView(r, rowinds, rowvals);
1160 for (
size_t j = 0; j < nE; ++j) {
1161 out <<
" (" << getColMap()->getGlobalElement(rowinds[j])
1162 <<
", " << rowvals[j]
1180 mtx_->SetLabel(objectLabel.c_str());
1187 , isFillResumed_(false) {}
1195 return toXpetra<GlobalOrdinal, Node>(mtx_->Map());
1207 int err = mtx_->Import(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
1220 int err = mtx_->Export(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
1233 int err = mtx_->Import(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
1246 int err = mtx_->Export(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
1247 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Caught nonzero error code " + std::to_string(err) +
" returned by Epetra.");
1252 const Epetra_Map *newMapEpetra = (!newMap.is_null()) ? &toEpetra<GlobalOrdinal, Node>(newMap) : 0;
1253 int err = mtx_->RemoveEmptyProcessesInPlace(newMapEpetra);
1254 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Caught nonzero error code " + std::to_string(err) +
" returned by Epetra.");
1268 , isFillResumed_(false) {}
1276#ifdef HAVE_XPETRA_TPETRA
1282 "Xpetra::EpetraCrsMatrx only available on host for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
1285 return getLocalMatrixHost();
1288#if KOKKOS_VERSION >= 40799
1289 typename local_matrix_type::host_mirror_type getLocalMatrixHost()
const {
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);
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.");
1339 const size_t N = getLocalNumRows();
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."
1363 R.
update(one, B, negone);
1382#ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
1385 :
public CrsMatrix<double, int, long long, EpetraNode> {
1392#ifdef HAVE_XPETRA_TPETRA
1409 , isFillResumed_(false) {}
1413 : isFillResumed_(false) {
1421 , isFillResumed_(false) {}
1425 : isFillResumed_(false) {
1433 , isFillResumed_(false) {}
1441 : isFillResumed_(false) {
1445 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1446 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1449 bool restrictComm =
false;
1450 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
1451 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), myDomainMap, myRangeMap, restrictComm));
1452 if (restrictComm && mtx_->NumMyRows() == 0)
1453 mtx_ = Teuchos::null;
1462 : isFillResumed_(false) {
1466 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1467 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1470 bool restrictComm =
false;
1471 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
1473 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), myDomainMap, myRangeMap, restrictComm));
1482 : isFillResumed_(false) {
1487 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1488 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1491 bool restrictComm =
false;
1492 if (!params.
is_null()) restrictComm = params->
get(
"Restrict Communicator", restrictComm);
1493 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), tdImporter->getEpetra_Import().get(), myDomainMap, myRangeMap, restrictComm));
1494 if (restrictComm && mtx_->NumMyRows() == 0)
1495 mtx_ = Teuchos::null;
1504 : isFillResumed_(false) {
1509 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1510 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1513 bool restrictComm =
false;
1514 if (!params.
is_null()) restrictComm = params->
get(
"Restrict Communicator", restrictComm);
1516 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), tdExporter->getEpetra_Export().get(), myDomainMap, myRangeMap, restrictComm));
1519#ifdef HAVE_XPETRA_TPETRA
1555 typedef typename local_matrix_type::value_type value_type;
1556 typedef typename local_matrix_type::ordinal_type ordinal_type;
1559 ordinal_type lclNumRows = lclMatrix.numRows();
1560 ordinal_type lclNumCols = lclMatrix.numCols();
1564 "Xpetra::EpetraCrsMatrixT: number of rows in local matrix and number of local entries in row map do not match!");
1566 "Xpetra::EpetraCrsMatrixT: number of columns in local matrix and number of local entries in column map do not match!");
1569 for (ordinal_type r = 0; r < lclNumRows; ++r) {
1571 auto rowview = lclMatrix.row(r);
1572 NumEntriesPerRowToAlloc[r] = rowview.length;
1576 isFillResumed_ =
false;
1581 for (ordinal_type r = 0; r < lclNumRows; ++r) {
1583 auto rowview = lclMatrix.row(r);
1589 for (ordinal_type c = 0; c < rowview.length; c++) {
1590 value_type value = rowview.value(c);
1591 ordinal_type colidx = rowview.colidx(c);
1598 insertLocalValues(r, indout.
view(0, indout.
size()), valout.
view(0, valout.
size()));
1602 if (!domainMap.is_null() && !rangeMap.is_null())
1603 this->fillComplete(domainMap, rowMap, params);
1605 this->fillComplete(rowMap, rowMap, params);
1634 const std::string tfecfFuncName(
"replaceGlobalValues");
1636 ": Fill must be active in order to call this method. If you have already "
1637 "called fillComplete(), you need to call resumeFill() before you can "
1641 std::runtime_error,
": values.size() must equal indices.size().");
1652 const std::string tfecfFuncName(
"replaceLocalValues");
1654 ": Fill must be active in order to call this method. If you have already "
1655 "called fillComplete(), you need to call resumeFill() before you can "
1659 std::runtime_error,
": values.size() must equal indices.size().");
1668 mtx_->PutScalar(alpha);
1687 rowptr.
resize(getLocalNumRows() + 1);
1689 int lowerOffset = 0;
1690 bool ownMemory =
false;
1695 myColind.
Resize(numNonZeros);
1696 colind = Teuchos::arcp(myColind.
Values(), lowerOffset, numNonZeros, ownMemory);
1700 double *&myValues = mtx_->ExpertExtractValues();
1702 myValues =
new double[numNonZeros];
1703 values = Teuchos::arcp(myValues, lowerOffset, numNonZeros, ownMemory);
1712 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
1714 "An exception is thrown to let you know that you mismatched your pointers.");
1717 if (values.
size() > 0) {
1719 "An exception is thrown to let you know that you mismatched your pointers.");
1721 "An exception is thrown to let you know that you mismatched your pointers.");
1726 const size_t N = getLocalNumRows();
1730 for (
size_t i = 0; i < N + 1; i++)
1731 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
1738 int lowerOffset = 0;
1739 bool ownMemory =
false;
1741 const size_t n = getLocalNumRows();
1742 const size_t nnz = getLocalNumEntries();
1748 for (
size_t i = 0; i < n + 1; i++)
1749 (*
const_cast<size_t *
>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
1752 colind = Teuchos::arcp(mtx_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
1755 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
1762 int lowerOffset = 0;
1763 bool ownMemory =
false;
1765 const size_t nnz = getLocalNumEntries();
1767 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
1783 isFillResumed_ =
false;
1789 if (!importer.is_null()) {
1791 myimport = eImporter.getEpetra_Import().getRawPtr();
1793 if (!exporter.is_null()) {
1795 myexport = eExporter.getEpetra_Export().getRawPtr();
1798 rv = mtx_->ExpertStaticFillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), myimport, myexport);
1812 isFillResumed_ =
true;
1820 if (isFillResumed_ ==
true) {
1821 isFillResumed_ =
false;
1825 bool doOptimizeStorage =
true;
1826 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
1827 mtx_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), doOptimizeStorage);
1835 if (isFillResumed_ ==
true) {
1836 isFillResumed_ =
false;
1840 bool doOptimizeStorage =
true;
1841 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
1842 mtx_->FillComplete(doOptimizeStorage);
1852 if (myImport == Teuchos::null)
1853 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), 0);
1855 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), &*myImport);
1873 return toXpetra<GlobalOrdinal, Node>(mtx_->RowMap());
1879 return toXpetra<GlobalOrdinal, Node>(mtx_->ColMap());
1885 return toXpetra<GlobalOrdinal, Node>(mtx_->Graph());
1891 return mtx_->NumGlobalRows64();
1897 return mtx_->NumGlobalCols64();
1903 return mtx_->NumMyRows();
1909 return mtx_->NumMyCols();
1915 return mtx_->NumGlobalNonzeros64();
1921 return mtx_->NumMyNonzeros();
1927 return mtx_->NumMyEntries(localRow);
1933 return mtx_->NumGlobalEntries(globalRow);
1939 return mtx_->GlobalMaxNumEntries();
1945 return mtx_->MaxNumEntries();
1951 return mtx_->IndicesAreLocal();
1957 return mtx_->IndicesAreGlobal();
1966 return mtx_->Filled();
1972 return !isFillComplete();
1978 return mtx_->NormFrobenius();
1991 int numEntries = -1;
1993 NumEntries = numEntries;
2000 int numEntries = -1;
2002 NumEntries = numEntries;
2013 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowView(GlobalRow, numEntries, eValues, eIndices));
2014 if (numEntries == 0) {
2031 XPETRA_ERR_CHECK(mtx_->ExtractMyRowView(LocalRow, numEntries, eValues, eIndices));
2032 if (numEntries == 0) {
2044 mtx_->ExtractDiagonalCopy(toEpetra<GlobalOrdinal, Node>(diag));
2064 mtx_->ReplaceDiagonalValues(toEpetra<GlobalOrdinal, Node>(diag));
2080 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 {
2098 tmp->PutScalar(0.0);
2099 XPETRA_ERR_CHECK(mtx_->Multiply(eTrans, *eX.getEpetra_MultiVector(), *tmp));
2105 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 {
2112 return toXpetra<GlobalOrdinal, Node>(mtx_->DomainMap());
2118 return toXpetra<GlobalOrdinal, Node>(mtx_->RangeMap());
2131 std::ostringstream oss;
2133 if (isFillComplete()) {
2134 oss <<
"{status = fill complete"
2135 <<
", global rows = " << getGlobalNumRows()
2136 <<
", global cols = " << getGlobalNumCols()
2137 <<
", global num entries = " << getGlobalNumEntries()
2140 oss <<
"{status = fill not complete"
2141 <<
", global rows = " << getGlobalNumRows()
2161 if (vl == VERB_DEFAULT) vl = VERB_LOW;
2163 const int myImageID = comm->getRank(),
2164 numImages = comm->getSize();
2166 for (
size_t dec = 10; dec < getGlobalNumRows(); dec *= 10) {
2169 width = std::max<size_t>(width, 11) + 2;
2178 if (vl != VERB_NONE) {
2179 if (myImageID == 0) out << this->description() << std::endl;
2181 if (isFillComplete() && myImageID == 0) {
2182 out <<
"Global max number of entries = " << getGlobalMaxNumRowEntries() << std::endl;
2185 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
2186 if (myImageID == 0) out <<
"\nRow map: " << std::endl;
2187 getRowMap()->describe(out, vl);
2189 if (getColMap() != null) {
2190 if (getColMap() == getRowMap()) {
2191 if (myImageID == 0) out <<
"\nColumn map is row map.";
2193 if (myImageID == 0) out <<
"\nColumn map: " << std::endl;
2194 getColMap()->describe(out, vl);
2197 if (getDomainMap() != null) {
2198 if (getDomainMap() == getRowMap()) {
2199 if (myImageID == 0) out <<
"\nDomain map is row map.";
2200 }
else if (getDomainMap() == getColMap()) {
2201 if (myImageID == 0) out <<
"\nDomain map is row map.";
2203 if (myImageID == 0) out <<
"\nDomain map: " << std::endl;
2204 getDomainMap()->describe(out, vl);
2207 if (getRangeMap() != null) {
2208 if (getRangeMap() == getDomainMap()) {
2209 if (myImageID == 0) out <<
"\nRange map is domain map." << std::endl;
2210 }
else if (getRangeMap() == getRowMap()) {
2211 if (myImageID == 0) out <<
"\nRange map is row map." << std::endl;
2213 if (myImageID == 0) out <<
"\nRange map: " << std::endl;
2214 getRangeMap()->describe(out, vl);
2217 if (myImageID == 0) out << std::endl;
2220 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
2221 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
2222 if (myImageID == imageCtr) {
2223 out <<
"Node ID = " << imageCtr << std::endl;
2236 out <<
"Node number of entries = " << getLocalNumEntries() << std::endl;
2237 out <<
"Node max number of entries = " << getLocalMaxNumRowEntries() << std::endl;
2245 if (vl == VERB_HIGH || vl == VERB_EXTREME) {
2246 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
2247 if (myImageID == imageCtr) {
2248 out << std::setw(width) <<
"Node ID"
2249 << std::setw(width) <<
"Global Row"
2250 << std::setw(width) <<
"Num Entries";
2251 if (vl == VERB_EXTREME) {
2252 out << std::setw(width) <<
"(Index,Value)";
2255 for (
size_t r = 0; r < getLocalNumRows(); ++r) {
2256 const size_t nE = getNumEntriesInLocalRow(r);
2258 out << std::setw(width) << myImageID
2259 << std::setw(width) << gid
2260 << std::setw(width) << nE;
2261 if (vl == VERB_EXTREME) {
2262 if (isGloballyIndexed()) {
2265 getGlobalRowView(gid, rowinds, rowvals);
2266 for (
size_t j = 0; j < nE; ++j) {
2267 out <<
" (" << rowinds[j]
2268 <<
", " << rowvals[j]
2271 }
else if (isLocallyIndexed()) {
2274 getLocalRowView(r, rowinds, rowvals);
2275 for (
size_t j = 0; j < nE; ++j) {
2276 out <<
" (" << getColMap()->getGlobalElement(rowinds[j])
2277 <<
", " << rowvals[j]
2295 mtx_->SetLabel(objectLabel.c_str());
2302 , isFillResumed_(false) {}
2310 return toXpetra<GlobalOrdinal, Node>(mtx_->Map());
2322 int err = mtx_->Import(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
2335 int err = mtx_->Export(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
2348 int err = mtx_->Import(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
2361 int err = mtx_->Export(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
2367 const Epetra_Map *newMapEpetra = (!newMap.is_null()) ? &toEpetra<GlobalOrdinal, Node>(newMap) : 0;
2368 int err = mtx_->RemoveEmptyProcessesInPlace(newMapEpetra);
2369 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Caught nonzero error code " + std::to_string(err) +
" returned by Epetra.");
2383 , isFillResumed_(false) {}
2391#ifdef HAVE_XPETRA_TPETRA
2396 const int numRows = matrix->NumMyRows();
2397 const int numCols = matrix->NumMyCols();
2398 const int nnz = matrix->NumMyNonzeros();
2403 int rv = matrix->ExtractCrsDataPointers(rowptr, colind, vals);
2407 typename local_matrix_type::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing(
"local row map"), numRows + 1);
2408 for (
size_t i = 0; i < kokkosRowPtr.size(); i++)
2409 kokkosRowPtr(i) = Teuchos::asSafe<typename local_matrix_type::row_map_type::value_type>(rowptr[i]);
2412 typename local_matrix_type::index_type kokkosColind(colind, nnz);
2413 typename local_matrix_type::values_type kokkosVals(vals, nnz);
2421 const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind,
2422 const typename local_matrix_type::values_type &val) {
2425 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
2427 "An exception is thrown to let you know that you mismatched your pointers.");
2430 if (val.size() > 0) {
2432 "An exception is thrown to let you know that you mismatched your pointers.");
2434 "An exception is thrown to let you know that you mismatched your pointers.");
2439 const size_t N = getLocalNumRows();
2443 for (
size_t i = 0; i < N + 1; i++)
2444 myRowptr[i] = Teuchos::as<int>(ptr(i));
2452#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."
2463 R.
update(one, B, negone);
2477#define XPETRA_EPETRACRSMATRIX_SHORT
#define XPETRA_MONITOR(funcName)
#define XPETRA_ERR_CHECK(arg)
#define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
#define XPETRA_RCP_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
int Resize(int Length_in)
ArrayView< T > view(size_type lowerOffset, size_type size) const
void resize(const size_type n, const T &val=T())
static const EVerbosityLevel verbLevel_default
virtual void setObjectLabel(const std::string &objectLabel)
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...
KokkosSparse::CrsMatrix< impl_scalar_type, LocalOrdinal, execution_space, void, typename local_graph_type::size_type > local_matrix_device_type
LocalOrdinal local_ordinal_type
typename local_matrix_device_type::HostMirror local_matrix_host_type
CrsMatrix< double, int, GlobalOrdinal, Node >::local_ordinal_type LocalOrdinal
size_t getLocalNumRows() const
Returns the number of matrix rows owned on the calling node.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
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.
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
Sets the 1D pointer arrays of the graph.
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::node_type node_type
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
Get the underlying Epetra matrix.
EpetraCrsMatrixT(const EpetraCrsMatrixT &matrix)
Deep copy constructor.
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)
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
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.
void fillComplete(const RCP< ParameterList > ¶ms=Teuchos::null)
Signal that data entry is complete.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_host_type local_matrix_host_type
size_t getLocalNumCols() const
Returns the number of columns connected to the locally owned rows of this matrix.
bool isFillResumed_
Flag to keep track of fill status.
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 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.
typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_device_type local_matrix_device_type
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
void replaceDiag(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag)
Replace the diagonal entries of the matrix.
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< Epetra_CrsMatrix > &mtx)
EpetraCrsMatrixT constructor to wrap a Epetra_CrsMatrix object.
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 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 isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
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 getLocalNumEntries() const
Returns the local number of entries in this matrix.
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 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...
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_type local_matrix_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.
void residual(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R) const
RCP< Epetra_CrsMatrix > mtx_
The underlying actual matrix object.
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 getAllValues(ArrayRCP< Scalar > &values)
Gets the 1D pointer arrays of the graph.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
void setObjectLabel(const std::string &objectLabel)
void getAllValues(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind, ArrayRCP< const Scalar > &values) const
Gets the 1D pointer arrays of the graph.
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...
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
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.
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
Get the underlying Epetra matrix.
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using local IDs.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
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)
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 setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalarThis.
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....
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 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.
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.
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
local_matrix_type getLocalMatrixDevice() const
Compatibility layer for accessing the matrix data through a Kokkos interface.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap)
Constructor for empty DynamicProfile matrix (no space is preallocated).
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
bool isFillActive() const
Returns true if the matrix is in edit mode.
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using global IDs.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &) const
Get offsets of the diagonal entries in the matrix.
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
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.
std::string description() const
A simple one-line description of this object.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
virtual ~EpetraCrsMatrixT()
Destructor.
void resumeFill(const RCP< ParameterList > &=Teuchos::null)
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
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 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.
local_matrix_type::HostMirror getLocalMatrixHost() const
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 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 doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
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, 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.
size_t getLocalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
bool hasMatrix() const
Does this have an underlying matrix.
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &) const
Get offsets of the diagonal entries in the matrix.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
size_t getLocalNumRows() const
Returns the number of matrix rows owned on the calling node.
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
Get the underlying Epetra matrix.
size_t getLocalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
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.
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalarThis.
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.
bool hasMatrix() const
Does this have an underlying matrix.
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 insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_host_type local_matrix_host_type
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.
size_t getLocalNumEntries() const
Returns the local number of entries in this matrix.
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)
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified (locally owned) global row.
void residual(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R) const
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using local IDs.
void getAllValues(ArrayRCP< Scalar > &values)
Gets the 1D pointer arrays of the graph.
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.
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
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 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
void fillComplete(const RCP< ParameterList > ¶ms=Teuchos::null)
Signal that data entry is complete.
size_t getLocalNumCols() const
Returns the number of columns connected to the locally owned rows of this matrix.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
RCP< Epetra_CrsMatrix > mtx_
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)
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() 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 column Map and number of entries in each row.
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using global IDs.
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_type local_matrix_type
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)
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 resumeFill(const RCP< ParameterList > &=Teuchos::null)
local_matrix_type getLocalMatrix() const
Compatibility layer for accessing the matrix data through a Kokkos interface.
EpetraCrsMatrixT(const Teuchos::RCP< Epetra_CrsMatrix > &mtx)
EpetraCrsMatrixT constructor to wrap a Epetra_CrsMatrix object.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
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.
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_device_type local_matrix_device_type
const RCP< const Comm< int > > getComm() const
Returns the communicator.
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.
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
bool isFillActive() const
Returns true if the matrix is in edit mode.
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::node_type node_type
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 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.
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
EpetraCrsMatrixT(const EpetraCrsMatrixT &matrix)
Deep copy constructor.
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
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....
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...
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
CrsMatrix< double, int, GlobalOrdinal, Node >::local_ordinal_type LocalOrdinal
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 replaceDiag(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag)
Replace the diagonal entries of the matrix.
LocalOrdinal GetStorageBlockSize() const
Returns the block size of the storage mechanism, which is usually 1, except for Tpetra::BlockCrsMatri...
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.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
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 doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
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.
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 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.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying a previously constructed graph.
std::string description() const
A simple one-line description of this object.
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.
virtual ~EpetraCrsMatrixT()
Destructor.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
Sets the 1D pointer arrays of the graph.
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 setObjectLabel(const std::string &objectLabel)
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.
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
size_t getLocalNumCols() const
Returns the number of matrix columns owned on the calling node.
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries in the specified global row.
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)
void fillComplete(const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete.
CrsMatrix< double, int, GlobalOrdinal, Node >::local_ordinal_type LocalOrdinal
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....
void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView< GlobalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
void resumeFill(const RCP< ParameterList > ¶ms=null)
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)
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=null)
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
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 getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
size_t getLocalNumEntries() const
Returns the local number of entries in this matrix.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
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 allocateAllValues(size_t numNonZeros, ArrayRCP< size_t > &rowptr, ArrayRCP< LocalOrdinal > &colind, ArrayRCP< Scalar > &values)
Kokkos::ArithTraits< Scalar > ATS
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
void setAllToScalar(const Scalar &alpha)
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)
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)
LocalOrdinal GetStorageBlockSize() const
Returns the block size of the storage mechanism, which is usually 1, except for Tpetra::BlockCrsMatri...
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
local_matrix_type getLocalMatrixDevice() const
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
const RCP< const Comm< int > > getComm() const
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_type local_matrix_type
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
EpetraGlobalOrdinal GlobalOrdinal
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
virtual ~EpetraCrsMatrixT()
void getAllValues(ArrayRCP< Scalar > &values)
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
size_t getLocalNumRows() const
Returns the number of matrix rows owned on the calling node.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
The Map describing the parallel distribution of this object.
void residual(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R) const
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Kokkos::View< const size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged > &offsets) const
bool isFillActive() const
Returns true if the matrix is in edit mode.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_device_type local_matrix_device_type
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values) const
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 doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
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)
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
size_t getLocalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_host_type local_matrix_host_type
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Teuchos::ArrayView< const size_t > &offsets) const
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
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 describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
local_matrix_type::HostMirror getLocalMatrixHost() const
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
void getAllValues(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind, ArrayRCP< const Scalar > &values) const
typename ATS::val_type impl_scalar_type
bool hasMatrix() const
Does this have an underlying matrix.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
void replaceDiag(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag)
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
EpetraCrsMatrixT(const Teuchos::RCP< Epetra_CrsMatrix > &mtx)
std::string description() const
A simple one-line description of this object.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
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)
void replaceDomainMapAndImporter(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newDomainMap, Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &newImporter)
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::node_type node_type
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)
EpetraCrsMatrixT(const EpetraCrsMatrixT &matrix)
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView< LocalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
Exception throws when you call an unimplemented method of Xpetra.
Exception throws to report errors in the internal logical of the program.
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.
#define TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(throw_exception_test, Exception, msg)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
size_t global_size_t
Global size_t object.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
CombineMode
Xpetra::Combine Mode enumerable type.