46 #ifndef XPETRA_EPETRACRSMATRIX_HPP 47 #define XPETRA_EPETRACRSMATRIX_HPP 51 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 52 #include <Kokkos_View.hpp> 59 #include <Epetra_CrsMatrix.h> 60 #include <Epetra_Map.h> 75 template<
class EpetraGlobalOrdinal,
class Node>
77 :
public CrsMatrix<double, int, EpetraGlobalOrdinal, Node>
83 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 91 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
95 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
97 EpetraCrsMatrixT(
const Teuchos::RCP<
const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap,
const Teuchos::RCP<
const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap,
size_t maxNumEntriesPerRow,
ProfileType pftype=
DynamicProfile,
const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null) {
TEUCHOS_TEST_FOR_EXCEPTION(
true,
Xpetra::Exceptions::RuntimeError,
"Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with Node=Kokkos::Compat::KokkosSerialWrapperNode."); }
98 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,
ProfileType pftype=
DynamicProfile,
const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null) {
TEUCHOS_TEST_FOR_EXCEPTION(
true,
Xpetra::Exceptions::RuntimeError,
"Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with Node=Kokkos::Compat::KokkosSerialWrapperNode."); }
106 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
114 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
116 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 119 const local_matrix_type& lclMatrix,
122 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
175 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 { }
184 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
198 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 199 local_matrix_type getLocalMatrix ()
const {
201 "Xpetra::EpetraCrsMatrix::getLocalMatrix: matrix must be filled and completed before you can access the data through the Kokkos interface!");
206 local_matrix_type localMatrix_;
211 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES 214 :
public CrsMatrix <double, int, int, EpetraNode>
223 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 235 : mtx_(
Teuchos::
rcp(new Epetra_CrsMatrix(
Copy,
toEpetra<GlobalOrdinal,Node>(rowMap), maxNumEntriesPerRow,
toEpetra(pftype)))), isFillResumed_(false)
236 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
237 , isInitializedLocalMatrix_(false)
244 : isFillResumed_(false)
245 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
246 , isInitializedLocalMatrix_(false)
250 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(
Copy, toEpetra<GlobalOrdinal,Node>(rowMap), numEntriesPerRowToAlloc.getRawPtr(),
toEpetra(pftype)));
256 : mtx_(
Teuchos::
rcp(new Epetra_CrsMatrix(
Copy,
toEpetra<GlobalOrdinal,Node>(rowMap),
toEpetra<GlobalOrdinal,Node>(colMap), maxNumEntriesPerRow,
toEpetra(pftype)))), isFillResumed_(false)
257 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
258 , isInitializedLocalMatrix_(false)
265 : isFillResumed_(false)
266 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
267 , isInitializedLocalMatrix_(false)
271 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(
Copy, toEpetra<GlobalOrdinal,Node>(rowMap), toEpetra<GlobalOrdinal,Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
toEpetra(pftype)));
277 : mtx_(
Teuchos::
rcp(new Epetra_CrsMatrix(
Copy,
toEpetra<GlobalOrdinal,Node>(graph)))), isFillResumed_(false)
278 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
279 , isInitializedLocalMatrix_(false)
290 isFillResumed_(false)
291 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
292 , isInitializedLocalMatrix_(false)
298 const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
299 const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
302 bool restrictComm=
false;
303 if(!params.is_null()) restrictComm = params->get(
"Restrict Communicator",restrictComm);
304 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tImporter.getEpetra_Import(),myDomainMap,myRangeMap,restrictComm));
305 if(restrictComm && mtx_->NumMyRows()==0)
317 isFillResumed_(false)
318 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
319 , isInitializedLocalMatrix_(false)
325 const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
326 const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
329 bool restrictComm=
false;
330 if(!params.is_null()) restrictComm = params->get(
"Restrict Communicator",restrictComm);
332 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tExporter.getEpetra_Export(),myDomainMap,myRangeMap,restrictComm));
336 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 359 const local_matrix_type& lclMatrix,
362 typedef typename local_matrix_type::size_type size_type;
363 typedef typename local_matrix_type::value_type value_type;
364 typedef typename local_matrix_type::ordinal_type ordinal_type;
367 ordinal_type lclNumRows = lclMatrix.numRows ();
368 ordinal_type lclNumCols = lclMatrix.numCols ();
374 std::vector<GlobalOrdinal> domainMapGids;
377 for (ordinal_type r = 0; r < lclNumRows; ++r) {
379 Kokkos::SparseRowView<local_matrix_type,size_type> rowview = lclMatrix.template row<size_type>(r);
380 NumEntriesPerRowToAlloc[r] = rowview.length;
384 isFillResumed_ =
false;
386 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(
Copy, toEpetra<GlobalOrdinal,Node>(rowMap), toEpetra<GlobalOrdinal,Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
toEpetra(
DynamicProfile)));
389 for (ordinal_type r = 0; r < lclNumRows; ++r) {
391 Kokkos::SparseRowView<local_matrix_type,size_type> rowview = lclMatrix.template row<size_type>(r);
397 for(ordinal_type c = 0; c < rowview.length; c++) {
398 value_type value = rowview.value (c);
399 ordinal_type colidx = rowview.colidx (c);
407 GlobalOrdinal gcid = colMap->getGlobalElement(c);
408 if(rowMap->isNodeGlobalElement(gcid)) domainMapGids.push_back(gcid);
415 std::sort(domainMapGids.begin(), domainMapGids.end());
416 domainMapGids.erase(std::unique(domainMapGids.begin(), domainMapGids.end()), domainMapGids.end());
425 isInitializedLocalMatrix_ =
false;
456 const std::string tfecfFuncName(
"replaceGlobalValues");
458 ": Fill must be active in order to call this method. If you have already " 459 "called fillComplete(), you need to call resumeFill() before you can " 463 std::runtime_error,
": values.size() must equal indices.size().");
475 const std::string tfecfFuncName(
"replaceLocalValues");
477 ": Fill must be active in order to call this method. If you have already " 478 "called fillComplete(), you need to call resumeFill() before you can " 482 std::runtime_error,
": values.size() must equal indices.size().");
509 bool ownMemory =
false;
513 Epetra_IntSerialDenseVector& myColind = mtx_->ExpertExtractIndices();
514 myColind.Resize(numNonZeros);
515 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
519 double *& myValues = mtx_->ExpertExtractValues();
521 myValues =
new double[numNonZeros];
522 values = Teuchos::arcp(myValues,lowerOffset,numNonZeros,ownMemory);
531 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
533 "An exception is thrown to let you know that you mismatched your pointers.");
536 if (values.
size() > 0) {
538 "An exception is thrown to let you know that you mismatched your pointers.");
540 "An exception is thrown to let you know that you mismatched your pointers.");
547 Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
548 myRowptr.Resize(N+1);
549 for (
size_t i = 0; i < N+1; i++)
550 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
559 bool ownMemory =
false;
566 Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
568 for (
size_t i = 0; i < n+1; i++)
569 (*const_cast<size_t*>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
572 colind = Teuchos::arcp(mtx_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
575 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
587 const Epetra_Import * myimport =0;
588 const Epetra_Export * myexport =0;
590 if(!importer.is_null()) {
592 myimport = eImporter.getEpetra_Import().getRawPtr();
594 if(!exporter.is_null()) {
596 myexport = eExporter.getEpetra_Export().getRawPtr();
599 rv=mtx_->ExpertStaticFillComplete(toEpetra<GlobalOrdinal,Node>(domainMap), toEpetra<GlobalOrdinal,Node>(rangeMap), myimport, myexport);
613 isFillResumed_ =
true;
621 if (isFillResumed_ ==
true) { isFillResumed_ =
false;
return; }
623 bool doOptimizeStorage =
true;
624 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
625 mtx_->FillComplete(toEpetra<GlobalOrdinal,Node>(domainMap), toEpetra<GlobalOrdinal,Node>(rangeMap), doOptimizeStorage);
634 if (isFillResumed_ ==
true) { isFillResumed_ =
false;
return; }
636 bool doOptimizeStorage =
true;
637 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
638 mtx_->FillComplete(doOptimizeStorage);
649 if(myImport==Teuchos::null)
650 rv=mtx_->ReplaceDomainMapAndImporter( toEpetra<GlobalOrdinal,Node>(newDomainMap),0);
652 rv=mtx_->ReplaceDomainMapAndImporter( toEpetra<GlobalOrdinal,Node>(newDomainMap),&*myImport);
730 NumEntries = numEntries;
739 NumEntries = numEntries;
748 GlobalOrdinal * eIndices;
750 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowView(GlobalRow, numEntries, eValues, eIndices));
751 if (numEntries == 0) { eValues = NULL; eIndices = NULL; }
765 XPETRA_ERR_CHECK(mtx_->ExtractMyRowView(LocalRow, numEntries, eValues, eIndices));
766 if (numEntries == 0) { eValues = NULL; eIndices = NULL; }
791 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 {
810 XPETRA_ERR_CHECK(mtx_->Multiply(eTrans, *eX.getEpetra_MultiVector(), *tmp));
832 std::ostringstream oss;
835 oss <<
"{status = fill complete" 842 oss <<
"{status = fill not complete" 867 const int myImageID = comm->getRank(),
868 numImages = comm->getSize();
873 width = std::max<size_t>(width,11) + 2;
883 if (myImageID == 0) out << this->
description() << std::endl;
891 if (myImageID == 0) out <<
"\nRow map: " << std::endl;
896 if (myImageID == 0) out <<
"\nColumn map is row map.";
899 if (myImageID == 0) out <<
"\nColumn map: " << std::endl;
905 if (myImageID == 0) out <<
"\nDomain map is row map.";
908 if (myImageID == 0) out <<
"\nDomain map is row map.";
911 if (myImageID == 0) out <<
"\nDomain map: " << std::endl;
917 if (myImageID == 0) out <<
"\nRange map is domain map." << std::endl;
920 if (myImageID == 0) out <<
"\nRange map is row map." << std::endl;
923 if (myImageID == 0) out <<
"\nRange map: " << std::endl;
927 if (myImageID == 0) out << std::endl;
931 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
932 if (myImageID == imageCtr) {
933 out <<
"Node ID = " << imageCtr << std::endl;
948 out <<
"Node number of diagonals = " <<
getNodeNumDiags() << std::endl;
959 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
960 if (myImageID == imageCtr) {
961 out << std::setw(width) <<
"Node ID" 962 << std::setw(width) <<
"Global Row" 963 << std::setw(width) <<
"Num Entries";
965 out << std::setw(width) <<
"(Index,Value)";
970 GlobalOrdinal gid =
getRowMap()->getGlobalElement(r);
971 out << std::setw(width) << myImageID
972 << std::setw(width) << gid
973 << std::setw(width) << nE;
979 for (
size_t j=0; j < nE; ++j) {
980 out <<
" (" << rowinds[j]
981 <<
", " << rowvals[j]
989 for (
size_t j=0; j < nE; ++j) {
990 out <<
" (" <<
getColMap()->getGlobalElement(rowinds[j])
991 <<
", " << rowvals[j]
1013 : mtx_(
Teuchos::
rcp(new Epetra_CrsMatrix(*(matrix.mtx_)))), isFillResumed_(false)
1014 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1015 , isInitializedLocalMatrix_(false)
1035 int err = mtx_->Import(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
1048 int err = mtx_->Export(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
1061 int err = mtx_->Import(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
1075 int err = mtx_->Export(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
1098 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 1099 local_matrix_type getLocalMatrix ()
const {
1102 "Xpetra::EpetraCrsMatrix::getLocalMatrix: matrix must be filled and completed before you can access the data through the Kokkos interface!");
1103 if (isInitializedLocalMatrix_)
1104 return localMatrix_;
1108 const int numRows = matrix->NumMyRows();
1109 const int numCols = matrix->NumMyCols();
1110 const int nnz = matrix->NumMyNonzeros();
1115 int rv = matrix->ExtractCrsDataPointers(rowptr, colind, vals);
1119 typename local_matrix_type::row_map_type::non_const_type kokkosRowPtr(
"local row map", numRows+1);
1120 for (
size_t i = 0; i < kokkosRowPtr.size(); i++)
1121 kokkosRowPtr(i) = Teuchos::asSafe<typename local_matrix_type::row_map_type::value_type>(rowptr[i]);
1124 typename local_matrix_type::index_type kokkosColind(colind, nnz);
1125 typename local_matrix_type::values_type kokkosVals (vals, nnz);
1127 localMatrix_ = local_matrix_type(
"LocalMatrix", numRows, numCols, nnz, kokkosVals, kokkosRowPtr, kokkosColind);
1128 isInitializedLocalMatrix_ =
true;
1130 return localMatrix_;
1140 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 1142 local_matrix_type localMatrix_;
1144 bool isInitializedLocalMatrix_;
1149 #endif //#ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES 1151 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES 1154 :
public CrsMatrix <double, int, long long, EpetraNode>
1163 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 1175 : mtx_(
Teuchos::
rcp(new Epetra_CrsMatrix(
Copy,
toEpetra<GlobalOrdinal,Node>(rowMap), maxNumEntriesPerRow,
toEpetra(pftype)))), isFillResumed_(false)
1176 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1177 , isInitializedLocalMatrix_(false)
1184 : isFillResumed_(false)
1185 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1186 , isInitializedLocalMatrix_(false)
1190 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(
Copy, toEpetra<GlobalOrdinal,Node>(rowMap), numEntriesPerRowToAlloc.getRawPtr(),
toEpetra(pftype)));
1196 : mtx_(
Teuchos::
rcp(new Epetra_CrsMatrix(
Copy,
toEpetra<GlobalOrdinal,Node>(rowMap),
toEpetra<GlobalOrdinal,Node>(colMap), maxNumEntriesPerRow,
toEpetra(pftype)))), isFillResumed_(false)
1197 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1198 , isInitializedLocalMatrix_(false)
1205 : isFillResumed_(false)
1206 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1207 , isInitializedLocalMatrix_(false)
1211 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(
Copy, toEpetra<GlobalOrdinal,Node>(rowMap), toEpetra<GlobalOrdinal,Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
toEpetra(pftype)));
1217 : mtx_(
Teuchos::
rcp(new Epetra_CrsMatrix(
Copy,
toEpetra<GlobalOrdinal,Node>(graph)))), isFillResumed_(false)
1218 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1219 , isInitializedLocalMatrix_(false)
1230 isFillResumed_(false)
1231 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1232 , isInitializedLocalMatrix_(false)
1238 const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
1239 const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
1242 bool restrictComm=
false;
1243 if(!params.is_null()) restrictComm = params->get(
"Restrict Communicator",restrictComm);
1244 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tImporter.getEpetra_Import(),myDomainMap,myRangeMap,restrictComm));
1245 if(restrictComm && mtx_->NumMyRows()==0)
1257 isFillResumed_(false)
1258 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1259 , isInitializedLocalMatrix_(false)
1265 const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
1266 const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
1269 bool restrictComm=
false;
1270 if(!params.is_null()) restrictComm = params->get(
"Restrict Communicator",restrictComm);
1272 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tExporter.getEpetra_Export(),myDomainMap,myRangeMap,restrictComm));
1276 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 1299 const local_matrix_type& lclMatrix,
1302 typedef typename local_matrix_type::size_type size_type;
1303 typedef typename local_matrix_type::value_type value_type;
1304 typedef typename local_matrix_type::ordinal_type ordinal_type;
1307 ordinal_type lclNumRows = lclMatrix.numRows ();
1308 ordinal_type lclNumCols = lclMatrix.numCols ();
1314 std::vector<GlobalOrdinal> domainMapGids;
1317 for (ordinal_type r = 0; r < lclNumRows; ++r) {
1319 Kokkos::SparseRowView<local_matrix_type,size_type> rowview = lclMatrix.template row<size_type>(r);
1320 NumEntriesPerRowToAlloc[r] = rowview.length;
1324 isFillResumed_ =
false;
1326 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(
Copy, toEpetra<GlobalOrdinal,Node>(rowMap), toEpetra<GlobalOrdinal,Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
toEpetra(
DynamicProfile)));
1329 for (ordinal_type r = 0; r < lclNumRows; ++r) {
1331 Kokkos::SparseRowView<local_matrix_type,size_type> rowview = lclMatrix.template row<size_type>(r);
1337 for(ordinal_type c = 0; c < rowview.length; c++) {
1338 value_type value = rowview.value (c);
1339 ordinal_type colidx = rowview.colidx (c);
1343 indout [c] = colidx;
1347 GlobalOrdinal gcid = colMap->getGlobalElement(c);
1348 if(rowMap->isNodeGlobalElement(gcid)) domainMapGids.push_back(gcid);
1355 std::sort(domainMapGids.begin(), domainMapGids.end());
1356 domainMapGids.erase(std::unique(domainMapGids.begin(), domainMapGids.end()), domainMapGids.end());
1365 isInitializedLocalMatrix_ =
false;
1396 const std::string tfecfFuncName(
"replaceGlobalValues");
1398 ": Fill must be active in order to call this method. If you have already " 1399 "called fillComplete(), you need to call resumeFill() before you can " 1403 std::runtime_error,
": values.size() must equal indices.size().");
1415 const std::string tfecfFuncName(
"replaceLocalValues");
1417 ": Fill must be active in order to call this method. If you have already " 1418 "called fillComplete(), you need to call resumeFill() before you can " 1422 std::runtime_error,
": values.size() must equal indices.size().");
1448 int lowerOffset = 0;
1449 bool ownMemory =
false;
1453 Epetra_IntSerialDenseVector& myColind = mtx_->ExpertExtractIndices();
1454 myColind.Resize(numNonZeros);
1455 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
1459 double *& myValues = mtx_->ExpertExtractValues();
1461 myValues =
new double[numNonZeros];
1462 values = Teuchos::arcp(myValues,lowerOffset,numNonZeros,ownMemory);
1471 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
1473 "An exception is thrown to let you know that you mismatched your pointers.");
1476 if (values.
size() > 0) {
1478 "An exception is thrown to let you know that you mismatched your pointers.");
1480 "An exception is thrown to let you know that you mismatched your pointers.");
1487 Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
1488 myRowptr.Resize(N+1);
1489 for (
size_t i = 0; i < N+1; i++)
1490 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
1498 int lowerOffset = 0;
1499 bool ownMemory =
false;
1506 Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
1508 for (
size_t i = 0; i < n+1; i++)
1509 (*const_cast<size_t*>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
1512 colind = Teuchos::arcp(mtx_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
1515 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
1527 const Epetra_Import * myimport =0;
1528 const Epetra_Export * myexport =0;
1530 if(!importer.is_null()) {
1532 myimport = eImporter.getEpetra_Import().getRawPtr();
1534 if(!exporter.is_null()) {
1536 myexport = eExporter.getEpetra_Export().getRawPtr();
1539 rv=mtx_->ExpertStaticFillComplete(toEpetra<GlobalOrdinal,Node>(domainMap), toEpetra<GlobalOrdinal,Node>(rangeMap), myimport, myexport);
1553 isFillResumed_ =
true;
1561 if (isFillResumed_ ==
true) { isFillResumed_ =
false;
return; }
1563 bool doOptimizeStorage =
true;
1564 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
1565 mtx_->FillComplete(toEpetra<GlobalOrdinal,Node>(domainMap), toEpetra<GlobalOrdinal,Node>(rangeMap), doOptimizeStorage);
1574 if (isFillResumed_ ==
true) { isFillResumed_ =
false;
return; }
1576 bool doOptimizeStorage =
true;
1577 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
1578 mtx_->FillComplete(doOptimizeStorage);
1589 if(myImport==Teuchos::null)
1590 rv=mtx_->ReplaceDomainMapAndImporter( toEpetra<GlobalOrdinal,Node>(newDomainMap),0);
1592 rv=mtx_->ReplaceDomainMapAndImporter( toEpetra<GlobalOrdinal,Node>(newDomainMap),&*myImport);
1668 int numEntries = -1;
1670 NumEntries = numEntries;
1677 int numEntries = -1;
1679 NumEntries = numEntries;
1688 GlobalOrdinal * eIndices;
1690 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowView(GlobalRow, numEntries, eValues, eIndices));
1691 if (numEntries == 0) { eValues = NULL; eIndices = NULL; }
1705 XPETRA_ERR_CHECK(mtx_->ExtractMyRowView(LocalRow, numEntries, eValues, eIndices));
1706 if (numEntries == 0) { eValues = NULL; eIndices = NULL; }
1731 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 {
1749 tmp->PutScalar(0.0);
1750 XPETRA_ERR_CHECK(mtx_->Multiply(eTrans, *eX.getEpetra_MultiVector(), *tmp));
1772 std::ostringstream oss;
1775 oss <<
"{status = fill complete" 1782 oss <<
"{status = fill not complete" 1807 const int myImageID = comm->getRank(),
1808 numImages = comm->getSize();
1813 width = std::max<size_t>(width,11) + 2;
1823 if (myImageID == 0) out << this->
description() << std::endl;
1831 if (myImageID == 0) out <<
"\nRow map: " << std::endl;
1836 if (myImageID == 0) out <<
"\nColumn map is row map.";
1839 if (myImageID == 0) out <<
"\nColumn map: " << std::endl;
1845 if (myImageID == 0) out <<
"\nDomain map is row map.";
1848 if (myImageID == 0) out <<
"\nDomain map is row map.";
1851 if (myImageID == 0) out <<
"\nDomain map: " << std::endl;
1857 if (myImageID == 0) out <<
"\nRange map is domain map." << std::endl;
1860 if (myImageID == 0) out <<
"\nRange map is row map." << std::endl;
1863 if (myImageID == 0) out <<
"\nRange map: " << std::endl;
1867 if (myImageID == 0) out << std::endl;
1871 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1872 if (myImageID == imageCtr) {
1873 out <<
"Node ID = " << imageCtr << std::endl;
1888 out <<
"Node number of diagonals = " <<
getNodeNumDiags() << std::endl;
1899 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1900 if (myImageID == imageCtr) {
1901 out << std::setw(width) <<
"Node ID" 1902 << std::setw(width) <<
"Global Row" 1903 << std::setw(width) <<
"Num Entries";
1905 out << std::setw(width) <<
"(Index,Value)";
1910 GlobalOrdinal gid =
getRowMap()->getGlobalElement(r);
1911 out << std::setw(width) << myImageID
1912 << std::setw(width) << gid
1913 << std::setw(width) << nE;
1919 for (
size_t j=0; j < nE; ++j) {
1920 out <<
" (" << rowinds[j]
1921 <<
", " << rowvals[j]
1929 for (
size_t j=0; j < nE; ++j) {
1930 out <<
" (" <<
getColMap()->getGlobalElement(rowinds[j])
1931 <<
", " << rowvals[j]
1953 : mtx_(
Teuchos::
rcp(new Epetra_CrsMatrix(*(matrix.mtx_)))), isFillResumed_(false)
1954 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1955 , isInitializedLocalMatrix_(false)
1975 int err = mtx_->Import(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
1988 int err = mtx_->Export(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
2001 int err = mtx_->Import(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
2015 int err = mtx_->Export(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
2038 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 2039 local_matrix_type getLocalMatrix ()
const {
2042 "Xpetra::EpetraCrsMatrix::getLocalMatrix: matrix must be filled and completed before you can access the data through the Kokkos interface!");
2043 if (isInitializedLocalMatrix_)
2044 return localMatrix_;
2048 const int numRows = matrix->NumMyRows();
2049 const int numCols = matrix->NumMyCols();
2050 const int nnz = matrix->NumMyNonzeros();
2055 int rv = matrix->ExtractCrsDataPointers(rowptr, colind, vals);
2059 typename local_matrix_type::row_map_type::non_const_type kokkosRowPtr(
"local row map", numRows+1);
2060 for (
size_t i = 0; i < kokkosRowPtr.size(); i++)
2061 kokkosRowPtr(i) = Teuchos::asSafe<typename local_matrix_type::row_map_type::value_type>(rowptr[i]);
2064 typename local_matrix_type::index_type kokkosColind(colind, nnz);
2065 typename local_matrix_type::values_type kokkosVals (vals, nnz);
2067 localMatrix_ = local_matrix_type(
"LocalMatrix", numRows, numCols, nnz, kokkosVals, kokkosRowPtr, kokkosColind);
2068 isInitializedLocalMatrix_ =
true;
2070 return localMatrix_;
2080 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 2082 local_matrix_type localMatrix_;
2084 bool isInitializedLocalMatrix_;
2089 #endif // #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES 2093 #define XPETRA_EPETRACRSMATRIX_SHORT 2094 #endif // XPETRA_EPETRACRSMATRIX_HPP size_t getNodeNumDiags() const
Returns the number of local diagonal entries, based on global row/column index comparisons.
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
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 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...
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
Get the underlying Epetra matrix.
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
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 getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Teuchos::ArrayView< const size_t > &offsets) const
Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets...
size_t getNodeNumEntries() const
Returns the local number of entries in this 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.
size_t getNodeNumDiags() const
Returns the number of local diagonal entries, based on global row/column index comparisons.
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=Xpetra::GloballyDistributed, const Teuchos::RCP< Node > &node=defaultArgNode())
Map constructor with Xpetra-defined contiguous uniform distribution.
EpetraCrsMatrixT(const Teuchos::RCP< Epetra_CrsMatrix > &mtx)
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
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.
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
CrsMatrix< double, int, GlobalOrdinal, Node >::local_ordinal_type LocalOrdinal
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 Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map and number of entries in each row.
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
Sets the 1D pointer arrays of the graph.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
size_t getNodeNumDiags() const
Returns the number of local diagonal entries, based on global row/column index comparisons.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
void resumeFill(const RCP< ParameterList > ¶ms=null)
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...
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
const RCP< const Comm< int > > getComm() const
void resumeFill(const RCP< ParameterList > ¶ms=Teuchos::null)
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)
bool hasMatrix() const
Does this have an underlying matrix.
RCP< Epetra_CrsMatrix > mtx_
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...
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
void fillComplete(const RCP< ParameterList > ¶ms=Teuchos::null)
Signal that data entry is complete.
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
#define TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(throw_exception_test, Exception, msg)
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.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
std::string description() const
A simple one-line description of this 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 resumeFill(const RCP< ParameterList > ¶ms=Teuchos::null)
size_t getNodeNumEntries() const
Returns the local number of entries 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.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
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 getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
EpetraCrsMatrixT(const EpetraCrsMatrixT &matrix)
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...
virtual ~EpetraCrsMatrixT()
Destructor.
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
size_t getNodeNumCols() const
Returns the number of columns connected to the locally owned rows of this matrix. ...
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.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
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, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
std::string description() const
A simple one-line description of this object.
size_t getNodeNumRows() 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 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.
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
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 resize(const size_type n, const T &val=T())
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 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 CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying a previously constructed graph.
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)
bool hasMatrix() const
Does this have an underlying 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.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying fixed number of entries for each row.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Teuchos::ArrayView< const size_t > &offsets) const
Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets...
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.
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
#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...
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with 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.
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 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 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)
Expert static fill complete.
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
size_t getNodeNumCols() const
Returns the number of matrix columns owned on the calling node.
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.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
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 EpetraCrsMatrixT &matrix)
Deep copy constructor.
global_size_t getGlobalNumDiags() const
Returns the number of global diagonal entries, based on global row/column index comparisons.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
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
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
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.
void getAllValues(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind, ArrayRCP< const Scalar > &values) const
Gets the 1D pointer arrays of the graph.
size_t getNodeNumRows() const
Returns the number of matrix rows owned on the calling node.
Exception throws when you call an unimplemented method of Xpetra.
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
const RCP< const Comm< int > > getComm() const
Returns the communicator.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
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.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
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.
global_size_t getGlobalNumDiags() const
Returns the number of global diagonal entries, based on global row/column index comparisons.
static const EVerbosityLevel verbLevel_default
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...
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying (possibly different) number of entries in 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 > ¶ms=Teuchos::null)
EpetraCrsMatrixT(const Teuchos::RCP< Epetra_CrsMatrix > &mtx)
EpetraCrsMatrixT constructor to wrap a Epetra_CrsMatrix object.
static magnitudeType magnitude(T a)
void fillComplete(const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete.
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
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 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)
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying (possibly different) number of entries in each row.
size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying a previously constructed graph.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using global IDs.
const RCP< const Comm< int > > getComm() const
Returns the communicator.
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)
Expert static fill complete.
size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
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.
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)
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, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map and number of entries in each row.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
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)
size_t getNodeMaxNumRowEntries() 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.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map and fixed number of entries for each row.
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).
#define XPETRA_MONITOR(funcName)
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map and 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.
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) 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_
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
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
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 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 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
size_t getNodeNumRows() const
Returns the number of matrix rows owned on the calling node.
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
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
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying fixed number of entries for each row.
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in 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.
size_t getNodeNumCols() const
Returns the number of columns connected to the locally owned rows of this matrix. ...
EpetraGlobalOrdinal GlobalOrdinal
global_size_t getGlobalNumDiags() const
Returns the number of global diagonal entries, based on global row/column index comparisons.
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
The Map describing the parallel distribution of this object.
ArrayView< T > view(size_type lowerOffset, size_type size) const
void replaceDomainMapAndImporter(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newDomainMap, Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &newImporter)