46 #ifndef XPETRA_EPETRACRSMATRIX_HPP
47 #define XPETRA_EPETRACRSMATRIX_HPP
51 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
52 #ifdef HAVE_XPETRA_TPETRA
53 #include <Kokkos_View.hpp>
61 #include <Epetra_CrsMatrix.h>
62 #include <Epetra_Map.h>
69 #include "Xpetra_MapFactory.hpp"
77 template<
class EpetraGlobalOrdinal,
class Node>
79 :
public CrsMatrix<double, int, EpetraGlobalOrdinal, Node>
85 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
86 #ifdef HAVE_XPETRA_TPETRA
95 "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 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
110 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
116 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
118 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
125 const Teuchos::RCP<Teuchos::ParameterList>& params) {
127 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
134 const Teuchos::RCP<Teuchos::ParameterList>& params) {
136 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
138 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
139 #ifdef HAVE_XPETRA_TPETRA
142 const local_matrix_type& lclMatrix,
143 const Teuchos::RCP<Teuchos::ParameterList>& params = null) {
145 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
148 const local_matrix_type& lclMatrix,
149 const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& rowMap,
150 const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& colMap,
151 const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& rangeMap = Teuchos::null,
152 const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& domainMap = Teuchos::null,
153 const Teuchos::RCP<Teuchos::ParameterList>& params = null) {
155 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
167 void allocateAllValues(
size_t numNonZeros,ArrayRCP<size_t> & rowptr, ArrayRCP<LocalOrdinal> & colind, ArrayRCP<Scalar> & values) { }
168 void setAllValues(
const ArrayRCP<size_t> & rowptr,
const ArrayRCP<LocalOrdinal> & colind,
const ArrayRCP<Scalar> & values) { }
169 void getAllValues(ArrayRCP<const size_t>& rowptr, ArrayRCP<const LocalOrdinal>& colind, ArrayRCP<const Scalar>& values)
const { }
175 const RCP<ParameterList> ¶ms=Teuchos::null) { }
181 const RCP< const Comm< int > >
getComm()
const {
return Teuchos::null; }
182 const RCP< const Map<LocalOrdinal, GlobalOrdinal, Node> >
getRowMap()
const {
return Teuchos::null; }
183 const RCP< const Map<LocalOrdinal, GlobalOrdinal, Node> >
getColMap()
const {
return Teuchos::null; }
184 RCP< const CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
getCrsGraph()
const {
return Teuchos::null; }
199 typename ScalarTraits< Scalar >::magnitudeType
getFrobeniusNorm()
const {
return ScalarTraits< Scalar >::magnitude(ScalarTraits< Scalar >::zero()); }
201 void getLocalRowCopy(
LocalOrdinal LocalRow,
const ArrayView< LocalOrdinal > &Indices,
const ArrayView< Scalar > &Values,
size_t &NumEntries)
const { }
212 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 { }
213 const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getDomainMap()
const {
return Teuchos::null; }
214 const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getRangeMap()
const {
return Teuchos::null; }
217 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default)
const { }
222 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
225 Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getMap()
const {
return Teuchos::null; }
235 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
239 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
240 #ifdef HAVE_XPETRA_TPETRA
241 local_matrix_type getLocalMatrix ()
const {
243 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
246 void setAllValues (
const typename local_matrix_type::row_map_type& ptr,
247 const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type& ind,
248 const typename local_matrix_type::values_type& val)
251 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
255 #warning "Xpetra Kokkos interface for CrsMatrix is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
263 Scalar one = Teuchos::ScalarTraits<Scalar>::one(), negone = -one;
270 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
273 :
public CrsMatrix <double, int, int, EpetraNode>
282 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
283 #ifdef HAVE_XPETRA_TPETRA
301 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy,
toEpetra<
GlobalOrdinal,
Node>(rowMap), maxNumEntriesPerRow, true))), isFillResumed_(false)
307 : isFillResumed_(false)
309 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
310 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
322 : isFillResumed_(false)
324 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
325 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), toEpetra<GlobalOrdinal,Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
340 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null):
341 isFillResumed_(false)
346 const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
347 const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
350 bool restrictComm=
false;
351 if(!params.is_null()) restrictComm = params->get(
"Restrict Communicator",restrictComm);
352 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tImporter.getEpetra_Import(),myDomainMap,myRangeMap,restrictComm));
353 if(restrictComm && mtx_->NumMyRows()==0)
364 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) :
365 isFillResumed_(false)
370 const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
371 const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
374 bool restrictComm=
false;
375 if(!params.is_null()) restrictComm = params->get(
"Restrict Communicator",restrictComm);
377 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tExporter.getEpetra_Export(),myDomainMap,myRangeMap,restrictComm));
385 const Teuchos::RCP<Teuchos::ParameterList>& params) :
386 isFillResumed_(false)
392 const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
393 const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
396 bool restrictComm=
false;
397 if(!params.is_null()) restrictComm = params->get(
"Restrict Communicator",restrictComm);
398 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tImporter.getEpetra_Import(),tdImporter->getEpetra_Import().get(),myDomainMap,myRangeMap,restrictComm));
399 if(restrictComm && mtx_->NumMyRows()==0)
408 const Teuchos::RCP<Teuchos::ParameterList>& params) :
409 isFillResumed_(false)
415 const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
416 const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
419 bool restrictComm=
false;
420 if(!params.is_null()) restrictComm = params->get(
"Restrict Communicator",restrictComm);
422 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tExporter.getEpetra_Export(),tdExporter->getEpetra_Export().get(),myDomainMap,myRangeMap,restrictComm));
425 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
426 #ifdef HAVE_XPETRA_TPETRA
452 const local_matrix_type& lclMatrix,
453 const Teuchos::RCP<Teuchos::ParameterList>& params = null) :
454 EpetraCrsMatrixT(lclMatrix, rowMap, colMap, Teuchos::null, Teuchos::null, params)
458 const local_matrix_type& lclMatrix,
459 const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& rowMap,
460 const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& colMap,
461 const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& domainMap = Teuchos::null,
462 const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& rangeMap = Teuchos::null,
463 const Teuchos::RCP<Teuchos::ParameterList>& params = null)
467 typedef typename local_matrix_type::value_type value_type;
468 typedef typename local_matrix_type::ordinal_type ordinal_type;
471 ordinal_type lclNumRows = lclMatrix.numRows ();
472 ordinal_type lclNumCols = lclMatrix.numCols ();
476 "Xpetra::EpetraCrsMatrixT: number of rows in local matrix and number of local entries in row map do not match!");
478 "Xpetra::EpetraCrsMatrixT: number of columns in local matrix and number of local entries in column map do not match!");
480 Teuchos::ArrayRCP< size_t > NumEntriesPerRowToAlloc(lclNumRows);
481 for (ordinal_type r = 0; r < lclNumRows; ++r) {
483 auto rowview = lclMatrix.row (r);
484 NumEntriesPerRowToAlloc[r] = rowview.length;
488 isFillResumed_ =
false;
489 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
490 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), toEpetra<GlobalOrdinal,Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
493 for (ordinal_type r = 0; r < lclNumRows; ++r) {
495 auto rowview = lclMatrix.row (r);
498 Teuchos::ArrayRCP<ordinal_type> indout(rowview.length,Teuchos::ScalarTraits<ordinal_type>::zero());
499 Teuchos::ArrayRCP<value_type> valout(rowview.length,Teuchos::ScalarTraits<value_type>::zero());
501 for(ordinal_type c = 0; c < rowview.length; c++) {
502 value_type value = rowview.value (c);
503 ordinal_type colidx = rowview.colidx (c);
506 "Xpetra::EpetraCrsMatrixT: local matrix contains column elements which are not in the provided column map!");
511 insertLocalValues(r, indout.view(0,indout.size()), valout.view(0,valout.size()));
515 if (!domainMap.is_null() && !rangeMap.is_null())
521 isInitializedLocalMatrix_ =
false;
537 XPETRA_ERR_CHECK(mtx_->InsertGlobalValues(globalRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
544 XPETRA_ERR_CHECK(mtx_->InsertMyValues(localRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
552 const std::string tfecfFuncName(
"replaceGlobalValues");
553 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!
isFillActive(), std::runtime_error,
554 ": Fill must be active in order to call this method. If you have already "
555 "called fillComplete(), you need to call resumeFill() before you can "
558 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
559 std::runtime_error,
": values.size() must equal indices.size().");
562 XPETRA_ERR_CHECK(mtx_->ReplaceGlobalValues(globalRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
571 const std::string tfecfFuncName(
"replaceLocalValues");
572 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!
isFillActive(), std::runtime_error,
573 ": Fill must be active in order to call this method. If you have already "
574 "called fillComplete(), you need to call resumeFill() before you can "
577 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
578 std::runtime_error,
": values.size() must equal indices.size().");
581 XPETRA_ERR_CHECK(mtx_->ReplaceMyValues(localRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
594 void allocateAllValues(
size_t numNonZeros, ArrayRCP<size_t>& rowptr, ArrayRCP<LocalOrdinal>& colind, ArrayRCP<Scalar>& values) {
605 bool ownMemory =
false;
609 Epetra_IntSerialDenseVector& myColind = mtx_->ExpertExtractIndices();
610 myColind.Resize(numNonZeros);
611 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
615 double *& myValues = mtx_->ExpertExtractValues();
617 myValues =
new double[numNonZeros];
618 values = Teuchos::arcp(myValues,lowerOffset,numNonZeros,ownMemory);
622 void setAllValues(
const ArrayRCP<size_t>& rowptr,
const ArrayRCP<LocalOrdinal>& colind,
const ArrayRCP<Scalar>& values) {
627 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
629 "An exception is thrown to let you know that you mismatched your pointers.");
632 if (values.size() > 0) {
634 "An exception is thrown to let you know that you mismatched your pointers.");
636 "An exception is thrown to let you know that you mismatched your pointers.");
643 Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
644 myRowptr.Resize(N+1);
645 for (
size_t i = 0; i < N+1; i++)
646 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
651 void getAllValues(ArrayRCP<const size_t>& rowptr, ArrayRCP<const LocalOrdinal>& colind, ArrayRCP<const Scalar>& values)
const {
655 bool ownMemory =
false;
662 Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
664 for (
size_t i = 0; i < n+1; i++)
665 (*const_cast<size_t*>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
668 colind = Teuchos::arcp(mtx_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
671 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
682 const RCP<ParameterList> & =Teuchos::null) {
686 isFillResumed_ =
false;
689 const Epetra_Import * myimport =0;
690 const Epetra_Export * myexport =0;
692 if(!importer.is_null()) {
694 myimport = eImporter.getEpetra_Import().getRawPtr();
696 if(!exporter.is_null()) {
698 myexport = eExporter.getEpetra_Export().getRawPtr();
701 rv=mtx_->ExpertStaticFillComplete(toEpetra<GlobalOrdinal,Node>(domainMap), toEpetra<GlobalOrdinal,Node>(rangeMap), myimport, myexport);
703 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error,
"Xpetra::EpetraCrsMatrixT::expertStaticFillComplete FAILED!");
711 void resumeFill(
const RCP< ParameterList > &=Teuchos::null) {
715 isFillResumed_ =
true;
723 isFillResumed_ =
false;
725 bool doOptimizeStorage =
true;
726 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
727 mtx_->FillComplete(toEpetra<GlobalOrdinal,Node>(domainMap), toEpetra<GlobalOrdinal,Node>(rangeMap), doOptimizeStorage);
736 if (isFillResumed_ ==
true) { isFillResumed_ =
false;
return; }
738 bool doOptimizeStorage =
true;
739 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
740 mtx_->FillComplete(doOptimizeStorage);
749 const RCP<const Epetra_Import> & myImport = eImporter.getEpetra_Import();
751 if(myImport==Teuchos::null)
752 rv=mtx_->ReplaceDomainMapAndImporter( toEpetra<GlobalOrdinal,Node>(newDomainMap),0);
754 rv=mtx_->ReplaceDomainMapAndImporter( toEpetra<GlobalOrdinal,Node>(newDomainMap),&*myImport);
755 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error,
"Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter FAILED!");
767 const RCP< const Map<LocalOrdinal, GlobalOrdinal, Node> >
getRowMap()
const {
XPETRA_MONITOR(
"EpetraCrsMatrixT::getRowMap");
return toXpetra<GlobalOrdinal,Node>(mtx_->RowMap()); }
770 const RCP< const Map<LocalOrdinal, GlobalOrdinal, Node> >
getColMap()
const {
XPETRA_MONITOR(
"EpetraCrsMatrixT::getColMap");
return toXpetra<GlobalOrdinal,Node>(mtx_->ColMap()); }
773 RCP< const CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
getCrsGraph()
const {
XPETRA_MONITOR(
"EpetraCrsMatrixT::getCrsGraph");
return toXpetra<GlobalOrdinal,Node>(mtx_->Graph()); }
828 XPETRA_ERR_CHECK(mtx_->ExtractMyRowCopy(LocalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
829 NumEntries = numEntries;
837 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowCopy(GlobalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
838 NumEntries = numEntries;
849 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowView(GlobalRow, numEntries, eValues, eIndices));
850 if (numEntries == 0) { eValues = NULL; eIndices = NULL; }
852 indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
853 values = ArrayView<const double>(eValues, numEntries);
864 XPETRA_ERR_CHECK(mtx_->ExtractMyRowView(LocalRow, numEntries, eValues, eIndices));
865 if (numEntries == 0) { eValues = NULL; eIndices = NULL; }
867 indices = ArrayView<const int>(eIndices, numEntries);
868 values = ArrayView<const double>(eValues, numEntries);
874 XPETRA_ERR_CHECK(mtx_->ExtractDiagonalCopy(toEpetra<GlobalOrdinal,Node>(diag)));
889 mtx_->ReplaceDiagonalValues (toEpetra<GlobalOrdinal,Node>(diag));
905 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 {
913 TEUCHOS_TEST_FOR_EXCEPTION((mode != Teuchos::NO_TRANS) && (mode != Teuchos::TRANS),
Xpetra::Exceptions::NotImplemented,
"Xpetra::EpetraCrsMatrixT->apply() only accept mode == NO_TRANS or mode == TRANS");
917 TEUCHOS_TEST_FOR_EXCEPTION(mtx_->UseTranspose(),
Xpetra::Exceptions::NotImplemented,
"An exception is throw to let you know that Xpetra::EpetraCrsMatrixT->apply() do not take into account the UseTranspose() parameter of Epetra_CrsMatrix.");
919 RCP<Epetra_MultiVector> epY = eY.getEpetra_MultiVector();
922 RCP<Epetra_MultiVector> tmp = Teuchos::rcp(
new Epetra_MultiVector(*epY));
924 XPETRA_ERR_CHECK(mtx_->Multiply(eTrans, *eX.getEpetra_MultiVector(), *tmp));
931 const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getDomainMap()
const {
XPETRA_MONITOR(
"EpetraCrsMatrixT::getDomainMap");
return toXpetra<GlobalOrdinal, Node>(mtx_->DomainMap()); }
934 const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getRangeMap()
const {
XPETRA_MONITOR(
"EpetraCrsMatrixT::getRangeMap");
return toXpetra<GlobalOrdinal, Node>(mtx_->RangeMap()); }
946 std::ostringstream oss;
949 oss <<
"{status = fill complete"
956 oss <<
"{status = fill not complete"
966 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default)
const {
972 using Teuchos::VERB_DEFAULT;
973 using Teuchos::VERB_NONE;
974 using Teuchos::VERB_LOW;
975 using Teuchos::VERB_MEDIUM;
976 using Teuchos::VERB_HIGH;
977 using Teuchos::VERB_EXTREME;
978 Teuchos::EVerbosityLevel vl = verbLevel;
979 if (vl == VERB_DEFAULT) vl = VERB_LOW;
980 RCP<const Comm<int> > comm = this->
getComm();
981 const int myImageID = comm->getRank(),
982 numImages = comm->getSize();
987 width = std::max<size_t>(width,11) + 2;
988 Teuchos::OSTab tab(out);
996 if (vl != VERB_NONE) {
997 if (myImageID == 0) out << this->
description() << std::endl;
1003 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
1004 if (myImageID == 0) out <<
"\nRow map: " << std::endl;
1009 if (myImageID == 0) out <<
"\nColumn map is row map.";
1012 if (myImageID == 0) out <<
"\nColumn map: " << std::endl;
1018 if (myImageID == 0) out <<
"\nDomain map is row map.";
1021 if (myImageID == 0) out <<
"\nDomain map is row map.";
1024 if (myImageID == 0) out <<
"\nDomain map: " << std::endl;
1030 if (myImageID == 0) out <<
"\nRange map is domain map." << std::endl;
1033 if (myImageID == 0) out <<
"\nRange map is row map." << std::endl;
1036 if (myImageID == 0) out <<
"\nRange map: " << std::endl;
1040 if (myImageID == 0) out << std::endl;
1043 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
1044 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1045 if (myImageID == imageCtr) {
1046 out <<
"Node ID = " << imageCtr << std::endl;
1068 if (vl == VERB_HIGH || vl == VERB_EXTREME) {
1069 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1070 if (myImageID == imageCtr) {
1071 out << std::setw(width) <<
"Node ID"
1072 << std::setw(width) <<
"Global Row"
1073 << std::setw(width) <<
"Num Entries";
1074 if (vl == VERB_EXTREME) {
1075 out << std::setw(width) <<
"(Index,Value)";
1081 out << std::setw(width) << myImageID
1082 << std::setw(width) << gid
1083 << std::setw(width) << nE;
1084 if (vl == VERB_EXTREME) {
1086 ArrayView<const GlobalOrdinal> rowinds;
1087 ArrayView<const Scalar> rowvals;
1089 for (
size_t j=0; j < nE; ++j) {
1090 out <<
" (" << rowinds[j]
1091 <<
", " << rowvals[j]
1096 ArrayView<const LocalOrdinal> rowinds;
1097 ArrayView<const Scalar> rowvals;
1099 for (
size_t j=0; j < nE; ++j) {
1100 out <<
" (" <<
getColMap()->getGlobalElement(rowinds[j])
1101 <<
", " << rowvals[j]
1119 Teuchos::LabeledObject::setObjectLabel(objectLabel);
1120 mtx_->SetLabel(objectLabel.c_str());
1126 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(*(matrix.mtx_)))), isFillResumed_(false)
1134 Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getMap()
const {
XPETRA_MONITOR(
"EpetraCrsMatrixT::getMap");
return toXpetra<GlobalOrdinal,Node>(mtx_->Map()); }
1144 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
1145 int err = mtx_->Import(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
1146 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
1157 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
1158 int err = mtx_->Export(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
1159 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
1170 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
1171 int err = mtx_->Import(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
1172 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
1184 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
1185 int err = mtx_->Export(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
1186 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Caught nonzero error code " + std::to_string(err) +
" returned by Epetra.");
1200 EpetraCrsMatrixT(
const Teuchos::RCP<Epetra_CrsMatrix > &mtx) : mtx_(mtx), isFillResumed_(false) { }
1208 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1209 #ifdef HAVE_XPETRA_TPETRA
1210 local_matrix_type getLocalMatrix ()
const {
1212 if (isInitializedLocalMatrix_)
1213 return localMatrix_;
1217 const int numRows = matrix->NumMyRows();
1218 const int numCols = matrix->NumMyCols();
1219 const int nnz = matrix->NumMyNonzeros();
1224 int rv = matrix->ExtractCrsDataPointers(rowptr, colind, vals);
1225 TEUCHOS_TEST_FOR_EXCEPTION(rv, std::runtime_error,
"Xpetra::CrsMatrix<>::getLocalMatrix: failed in ExtractCrsDataPointers");
1228 typename local_matrix_type::row_map_type::non_const_type kokkosRowPtr(
"local row map", numRows+1);
1229 for (
size_t i = 0; i < kokkosRowPtr.size(); i++)
1230 kokkosRowPtr(i) = Teuchos::asSafe<typename local_matrix_type::row_map_type::value_type>(rowptr[i]);
1233 typename local_matrix_type::index_type kokkosColind(colind, nnz);
1234 typename local_matrix_type::values_type kokkosVals (vals, nnz);
1236 localMatrix_ = local_matrix_type(
"LocalMatrix", numRows, numCols, nnz, kokkosVals, kokkosRowPtr, kokkosColind);
1237 isInitializedLocalMatrix_ =
true;
1239 return localMatrix_;
1242 void setAllValues (
const typename local_matrix_type::row_map_type& ,
1243 const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type& ,
1244 const typename local_matrix_type::values_type& )
1247 "Xpetra::EpetraCrsMatrix::setAllValues is not implemented");
1253 mutable local_matrix_type localMatrix_;
1254 mutable bool isInitializedLocalMatrix_ =
false;
1257 #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."
1266 Scalar one = Teuchos::ScalarTraits<Scalar>::one(), negone = -one;
1286 #endif //#ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
1288 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
1291 :
public CrsMatrix <double, int, long long, EpetraNode>
1300 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1301 #ifdef HAVE_XPETRA_TPETRA
1314 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy,
toEpetra<
GlobalOrdinal,
Node>(rowMap), maxNumEntriesPerRow, true))), isFillResumed_(false)
1320 : isFillResumed_(false)
1322 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
1323 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
1335 : isFillResumed_(false)
1337 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
1338 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), toEpetra<GlobalOrdinal,Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
1353 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null):
1354 isFillResumed_(false)
1359 const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
1360 const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
1363 bool restrictComm=
false;
1364 if(!params.is_null()) restrictComm = params->get(
"Restrict Communicator",restrictComm);
1365 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tImporter.getEpetra_Import(),myDomainMap,myRangeMap,restrictComm));
1366 if(restrictComm && mtx_->NumMyRows()==0)
1377 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) :
1378 isFillResumed_(false)
1383 const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
1384 const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
1387 bool restrictComm=
false;
1388 if(!params.is_null()) restrictComm = params->get(
"Restrict Communicator",restrictComm);
1390 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tExporter.getEpetra_Export(),myDomainMap,myRangeMap,restrictComm));
1398 const Teuchos::RCP<Teuchos::ParameterList>& params) :
1399 isFillResumed_(false)
1405 const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
1406 const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
1409 bool restrictComm=
false;
1410 if(!params.is_null()) restrictComm = params->get(
"Restrict Communicator",restrictComm);
1411 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tImporter.getEpetra_Import(),tdImporter->getEpetra_Import().get(),myDomainMap,myRangeMap,restrictComm));
1412 if(restrictComm && mtx_->NumMyRows()==0)
1421 const Teuchos::RCP<Teuchos::ParameterList>& params) :
1422 isFillResumed_(false)
1428 const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
1429 const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
1432 bool restrictComm=
false;
1433 if(!params.is_null()) restrictComm = params->get(
"Restrict Communicator",restrictComm);
1435 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tExporter.getEpetra_Export(),tdExporter->getEpetra_Export().get(),myDomainMap,myRangeMap,restrictComm));
1438 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1439 #ifdef HAVE_XPETRA_TPETRA
1462 const local_matrix_type& lclMatrix,
1463 const Teuchos::RCP<Teuchos::ParameterList>& params = null) :
1464 EpetraCrsMatrixT(lclMatrix, rowMap, colMap, Teuchos::null, Teuchos::null, params)
1468 const local_matrix_type& lclMatrix,
1469 const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& rowMap,
1470 const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& colMap,
1471 const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& domainMap = Teuchos::null,
1472 const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& rangeMap = Teuchos::null,
1473 const Teuchos::RCP<Teuchos::ParameterList>& params = null)
1477 typedef typename local_matrix_type::value_type value_type;
1478 typedef typename local_matrix_type::ordinal_type ordinal_type;
1481 ordinal_type lclNumRows = lclMatrix.numRows ();
1482 ordinal_type lclNumCols = lclMatrix.numCols ();
1486 "Xpetra::EpetraCrsMatrixT: number of rows in local matrix and number of local entries in row map do not match!");
1488 "Xpetra::EpetraCrsMatrixT: number of columns in local matrix and number of local entries in column map do not match!");
1490 Teuchos::ArrayRCP< size_t > NumEntriesPerRowToAlloc(lclNumRows);
1491 for (ordinal_type r = 0; r < lclNumRows; ++r) {
1493 auto rowview = lclMatrix.row (r);
1494 NumEntriesPerRowToAlloc[r] = rowview.length;
1498 isFillResumed_ =
false;
1499 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end());
1500 mtx_ = Teuchos::rcp(
new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), toEpetra<GlobalOrdinal,Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(),
true));
1503 for (ordinal_type r = 0; r < lclNumRows; ++r) {
1505 auto rowview = lclMatrix.row (r);
1508 Teuchos::ArrayRCP<ordinal_type> indout(rowview.length,Teuchos::ScalarTraits<ordinal_type>::zero());
1509 Teuchos::ArrayRCP<value_type> valout(rowview.length,Teuchos::ScalarTraits<value_type>::zero());
1511 for(ordinal_type c = 0; c < rowview.length; c++) {
1512 value_type value = rowview.value (c);
1513 ordinal_type colidx = rowview.colidx (c);
1515 TEUCHOS_TEST_FOR_EXCEPTION(colMap->isNodeLocalElement(colidx) ==
false,
Xpetra::Exceptions::RuntimeError,
"Xpetra::EpetraCrsMatrixT: local matrix contains column elements which are not in the provided column map!");
1517 indout [c] = colidx;
1520 insertLocalValues(r, indout.view(0,indout.size()), valout.view(0,valout.size()));
1524 if (!domainMap.is_null() && !rangeMap.is_null())
1530 isInitializedLocalMatrix_ =
false;
1546 XPETRA_ERR_CHECK(mtx_->InsertGlobalValues(globalRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
1553 XPETRA_ERR_CHECK(mtx_->InsertMyValues(localRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
1561 const std::string tfecfFuncName(
"replaceGlobalValues");
1562 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!
isFillActive(), std::runtime_error,
1563 ": Fill must be active in order to call this method. If you have already "
1564 "called fillComplete(), you need to call resumeFill() before you can "
1567 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
1568 std::runtime_error,
": values.size() must equal indices.size().");
1571 XPETRA_ERR_CHECK(mtx_->ReplaceGlobalValues(globalRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
1580 const std::string tfecfFuncName(
"replaceLocalValues");
1581 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!
isFillActive(), std::runtime_error,
1582 ": Fill must be active in order to call this method. If you have already "
1583 "called fillComplete(), you need to call resumeFill() before you can "
1586 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
1587 std::runtime_error,
": values.size() must equal indices.size().");
1590 XPETRA_ERR_CHECK(mtx_->ReplaceMyValues(localRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
1603 void allocateAllValues(
size_t numNonZeros, ArrayRCP<size_t>& rowptr, ArrayRCP<LocalOrdinal>& colind, ArrayRCP<Scalar>& values) {
1613 int lowerOffset = 0;
1614 bool ownMemory =
false;
1618 Epetra_IntSerialDenseVector& myColind = mtx_->ExpertExtractIndices();
1619 myColind.Resize(numNonZeros);
1620 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
1624 double *& myValues = mtx_->ExpertExtractValues();
1626 myValues =
new double[numNonZeros];
1627 values = Teuchos::arcp(myValues,lowerOffset,numNonZeros,ownMemory);
1631 void setAllValues(
const ArrayRCP<size_t>& rowptr,
const ArrayRCP<LocalOrdinal>& colind,
const ArrayRCP<Scalar>& values) {
1636 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
1638 "An exception is thrown to let you know that you mismatched your pointers.");
1641 if (values.size() > 0) {
1643 "An exception is thrown to let you know that you mismatched your pointers.");
1645 "An exception is thrown to let you know that you mismatched your pointers.");
1652 Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
1653 myRowptr.Resize(N+1);
1654 for (
size_t i = 0; i < N+1; i++)
1655 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
1660 void getAllValues(ArrayRCP<const size_t>& rowptr, ArrayRCP<const LocalOrdinal>& colind, ArrayRCP<const Scalar>& values)
const {
1663 int lowerOffset = 0;
1664 bool ownMemory =
false;
1671 Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
1673 for (
size_t i = 0; i < n+1; i++)
1674 (*const_cast<size_t*>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
1677 colind = Teuchos::arcp(mtx_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
1680 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
1692 const RCP<ParameterList> & =Teuchos::null) {
1696 isFillResumed_ =
false;
1699 const Epetra_Import * myimport =0;
1700 const Epetra_Export * myexport =0;
1702 if(!importer.is_null()) {
1704 myimport = eImporter.getEpetra_Import().getRawPtr();
1706 if(!exporter.is_null()) {
1708 myexport = eExporter.getEpetra_Export().getRawPtr();
1711 rv=mtx_->ExpertStaticFillComplete(toEpetra<GlobalOrdinal,Node>(domainMap), toEpetra<GlobalOrdinal,Node>(rangeMap), myimport, myexport);
1713 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error,
"Xpetra::EpetraCrsMatrixT::expertStaticFillComplete FAILED!");
1725 isFillResumed_ =
true;
1733 if (isFillResumed_ ==
true) { isFillResumed_ =
false;
return; }
1735 bool doOptimizeStorage =
true;
1736 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
1737 mtx_->FillComplete(toEpetra<GlobalOrdinal,Node>(domainMap), toEpetra<GlobalOrdinal,Node>(rangeMap), doOptimizeStorage);
1746 if (isFillResumed_ ==
true) { isFillResumed_ =
false;
return; }
1748 bool doOptimizeStorage =
true;
1749 if (params != null && params->get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
1750 mtx_->FillComplete(doOptimizeStorage);
1759 const RCP<const Epetra_Import> & myImport = eImporter.getEpetra_Import();
1761 if(myImport==Teuchos::null)
1762 rv=mtx_->ReplaceDomainMapAndImporter( toEpetra<GlobalOrdinal,Node>(newDomainMap),0);
1764 rv=mtx_->ReplaceDomainMapAndImporter( toEpetra<GlobalOrdinal,Node>(newDomainMap),&*myImport);
1765 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error,
"Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter FAILED!");
1777 const RCP< const Map<LocalOrdinal, GlobalOrdinal, Node> >
getRowMap()
const {
XPETRA_MONITOR(
"EpetraCrsMatrixT::getRowMap");
return toXpetra<GlobalOrdinal,Node>(mtx_->RowMap()); }
1780 const RCP< const Map<LocalOrdinal, GlobalOrdinal, Node> >
getColMap()
const {
XPETRA_MONITOR(
"EpetraCrsMatrixT::getColMap");
return toXpetra<GlobalOrdinal,Node>(mtx_->ColMap()); }
1783 RCP< const CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
getCrsGraph()
const {
XPETRA_MONITOR(
"EpetraCrsMatrixT::getCrsGraph");
return toXpetra<GlobalOrdinal,Node>(mtx_->Graph()); }
1837 int numEntries = -1;
1838 XPETRA_ERR_CHECK(mtx_->ExtractMyRowCopy(LocalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
1839 NumEntries = numEntries;
1846 int numEntries = -1;
1847 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowCopy(GlobalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
1848 NumEntries = numEntries;
1859 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowView(GlobalRow, numEntries, eValues, eIndices));
1860 if (numEntries == 0) { eValues = NULL; eIndices = NULL; }
1862 indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
1863 values = ArrayView<const double>(eValues, numEntries);
1874 XPETRA_ERR_CHECK(mtx_->ExtractMyRowView(LocalRow, numEntries, eValues, eIndices));
1875 if (numEntries == 0) { eValues = NULL; eIndices = NULL; }
1877 indices = ArrayView<const int>(eIndices, numEntries);
1878 values = ArrayView<const double>(eValues, numEntries);
1896 mtx_->ReplaceDiagonalValues (toEpetra<GlobalOrdinal,Node>(diag));
1912 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 {
1920 TEUCHOS_TEST_FOR_EXCEPTION((mode != Teuchos::NO_TRANS) && (mode != Teuchos::TRANS),
Xpetra::Exceptions::NotImplemented,
"Xpetra::EpetraCrsMatrixT->apply() only accept mode == NO_TRANS or mode == TRANS");
1924 TEUCHOS_TEST_FOR_EXCEPTION(mtx_->UseTranspose(),
Xpetra::Exceptions::NotImplemented,
"An exception is throw to let you know that Xpetra::EpetraCrsMatrixT->apply() do not take into account the UseTranspose() parameter of Epetra_CrsMatrix.");
1926 RCP<Epetra_MultiVector> epY = eY.getEpetra_MultiVector();
1929 RCP<Epetra_MultiVector> tmp = Teuchos::rcp(
new Epetra_MultiVector(*epY));
1930 tmp->PutScalar(0.0);
1931 XPETRA_ERR_CHECK(mtx_->Multiply(eTrans, *eX.getEpetra_MultiVector(), *tmp));
1938 const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getDomainMap()
const {
XPETRA_MONITOR(
"EpetraCrsMatrixT::getDomainMap");
return toXpetra<GlobalOrdinal, Node>(mtx_->DomainMap()); }
1941 const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getRangeMap()
const {
XPETRA_MONITOR(
"EpetraCrsMatrixT::getRangeMap");
return toXpetra<GlobalOrdinal, Node>(mtx_->RangeMap()); }
1953 std::ostringstream oss;
1956 oss <<
"{status = fill complete"
1963 oss <<
"{status = fill not complete"
1973 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default)
const {
1979 using Teuchos::VERB_DEFAULT;
1980 using Teuchos::VERB_NONE;
1981 using Teuchos::VERB_LOW;
1982 using Teuchos::VERB_MEDIUM;
1983 using Teuchos::VERB_HIGH;
1984 using Teuchos::VERB_EXTREME;
1985 Teuchos::EVerbosityLevel vl = verbLevel;
1986 if (vl == VERB_DEFAULT) vl = VERB_LOW;
1987 RCP<const Comm<int> > comm = this->
getComm();
1988 const int myImageID = comm->getRank(),
1989 numImages = comm->getSize();
1994 width = std::max<size_t>(width,11) + 2;
1995 Teuchos::OSTab tab(out);
2003 if (vl != VERB_NONE) {
2004 if (myImageID == 0) out << this->
description() << std::endl;
2010 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
2011 if (myImageID == 0) out <<
"\nRow map: " << std::endl;
2016 if (myImageID == 0) out <<
"\nColumn map is row map.";
2019 if (myImageID == 0) out <<
"\nColumn map: " << std::endl;
2025 if (myImageID == 0) out <<
"\nDomain map is row map.";
2028 if (myImageID == 0) out <<
"\nDomain map is row map.";
2031 if (myImageID == 0) out <<
"\nDomain map: " << std::endl;
2037 if (myImageID == 0) out <<
"\nRange map is domain map." << std::endl;
2040 if (myImageID == 0) out <<
"\nRange map is row map." << std::endl;
2043 if (myImageID == 0) out <<
"\nRange map: " << std::endl;
2047 if (myImageID == 0) out << std::endl;
2050 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
2051 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
2052 if (myImageID == imageCtr) {
2053 out <<
"Node ID = " << imageCtr << std::endl;
2075 if (vl == VERB_HIGH || vl == VERB_EXTREME) {
2076 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
2077 if (myImageID == imageCtr) {
2078 out << std::setw(width) <<
"Node ID"
2079 << std::setw(width) <<
"Global Row"
2080 << std::setw(width) <<
"Num Entries";
2081 if (vl == VERB_EXTREME) {
2082 out << std::setw(width) <<
"(Index,Value)";
2088 out << std::setw(width) << myImageID
2089 << std::setw(width) << gid
2090 << std::setw(width) << nE;
2091 if (vl == VERB_EXTREME) {
2093 ArrayView<const GlobalOrdinal> rowinds;
2094 ArrayView<const Scalar> rowvals;
2096 for (
size_t j=0; j < nE; ++j) {
2097 out <<
" (" << rowinds[j]
2098 <<
", " << rowvals[j]
2103 ArrayView<const LocalOrdinal> rowinds;
2104 ArrayView<const Scalar> rowvals;
2106 for (
size_t j=0; j < nE; ++j) {
2107 out <<
" (" <<
getColMap()->getGlobalElement(rowinds[j])
2108 <<
", " << rowvals[j]
2126 Teuchos::LabeledObject::setObjectLabel(objectLabel);
2127 mtx_->SetLabel(objectLabel.c_str());
2133 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(*(matrix.mtx_)))), isFillResumed_(false)
2141 Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getMap()
const {
XPETRA_MONITOR(
"EpetraCrsMatrixT::getMap");
return toXpetra<GlobalOrdinal,Node>(mtx_->Map()); }
2151 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
2152 int err = mtx_->Import(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
2153 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
2164 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
2165 int err = mtx_->Export(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
2166 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
2177 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
2178 int err = mtx_->Import(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
2179 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
2191 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
2192 int err = mtx_->Export(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
2193 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
2207 EpetraCrsMatrixT(
const Teuchos::RCP<Epetra_CrsMatrix > &mtx) : mtx_(mtx), isFillResumed_(false) { }
2215 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
2216 #ifdef HAVE_XPETRA_TPETRA
2217 local_matrix_type getLocalMatrix ()
const {
2219 if (isInitializedLocalMatrix_)
2220 return localMatrix_;
2224 const int numRows = matrix->NumMyRows();
2225 const int numCols = matrix->NumMyCols();
2226 const int nnz = matrix->NumMyNonzeros();
2231 int rv = matrix->ExtractCrsDataPointers(rowptr, colind, vals);
2232 TEUCHOS_TEST_FOR_EXCEPTION(rv, std::runtime_error,
"Xpetra::CrsMatrix<>::getLocalMatrix: failed in ExtractCrsDataPointers");
2235 typename local_matrix_type::row_map_type::non_const_type kokkosRowPtr(
"local row map", numRows+1);
2236 for (
size_t i = 0; i < kokkosRowPtr.size(); i++)
2237 kokkosRowPtr(i) = Teuchos::asSafe<typename local_matrix_type::row_map_type::value_type>(rowptr[i]);
2240 typename local_matrix_type::index_type kokkosColind(colind, nnz);
2241 typename local_matrix_type::values_type kokkosVals (vals, nnz);
2243 localMatrix_ = local_matrix_type(
"LocalMatrix", numRows, numCols, nnz, kokkosVals, kokkosRowPtr, kokkosColind);
2244 isInitializedLocalMatrix_ =
true;
2246 return localMatrix_;
2249 void setAllValues (
const typename local_matrix_type::row_map_type& ,
2250 const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type& ,
2251 const typename local_matrix_type::values_type& )
2254 "Xpetra::EpetraCrsMatrix::setAllValues is not implemented");
2259 mutable local_matrix_type localMatrix_;
2260 mutable bool isInitializedLocalMatrix_ =
false;
2263 #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."
2272 Scalar one = Teuchos::ScalarTraits<Scalar>::one(), negone = -one;
2284 #endif // #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
2288 #define XPETRA_EPETRACRSMATRIX_SHORT
2289 #endif // XPETRA_EPETRACRSMATRIX_HPP
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
void setObjectLabel(const std::string &objectLabel)
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values) const
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &RowExporter, const Teuchos::RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > DomainExporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &RowImporter, const Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > DomainImporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
Get the underlying Epetra matrix.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying row and column Maps and number of entries in each row.
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
virtual ~EpetraCrsMatrixT()
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor for a fused import.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
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.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
EpetraCrsMatrixT(const Teuchos::RCP< Epetra_CrsMatrix > &mtx)
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values) const
Extract a const, non-persisting view of local indices in a specified row of the matrix.
CrsMatrix< double, int, GlobalOrdinal, Node >::local_ordinal_type LocalOrdinal
void allocateAllValues(size_t numNonZeros, ArrayRCP< size_t > &rowptr, ArrayRCP< LocalOrdinal > &colind, ArrayRCP< Scalar > &values)
Allocates and returns ArrayRCPs of the Crs arrays — This is an Xpetra-only routine.
void residual(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R) const
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
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 CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &RowImporter, const Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > DomainImporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying column Map and number of entries in each row.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
Sets the 1D pointer arrays of the graph.
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.
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.
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.
const RCP< const Comm< int > > getComm() const
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
void allocateAllValues(size_t numNonZeros, ArrayRCP< size_t > &rowptr, ArrayRCP< LocalOrdinal > &colind, ArrayRCP< Scalar > &values)
void replaceDiag(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag)
bool hasMatrix() const
Does this have an underlying matrix.
RCP< Epetra_CrsMatrix > mtx_
The underlying actual matrix object.
void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView< LocalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
Extract a list of entries in a specified local row of the matrix. Put into storage allocated by calli...
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
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.
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...
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified (locally owned) global row...
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 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...
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, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying fixed number of entries for each row.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
std::string description() const
A simple one-line description of this object.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Teuchos::ArrayView< const size_t > &) const
Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets...
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.
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.
void resumeFill(const RCP< ParameterList > &=Teuchos::null)
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using global IDs.
void replaceDomainMapAndImporter(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newDomainMap, Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &newImporter)
Replaces the current domainMap and importer with the user-specified objects.
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const
Extract a const, non-persisting view of global indices in a specified row of the matrix.
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
Get the underlying Epetra matrix.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
void setAllToScalar(const Scalar &alpha)
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying (possibly different) number of entries in each row.
bool hasMatrix() const
Does this have an underlying matrix.
void expertStaticFillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &importer=Teuchos::null, const RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > &exporter=Teuchos::null, const RCP< ParameterList > &=Teuchos::null)
Expert static fill complete.
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
Computes the sparse matrix-multivector multiplication.
virtual ~EpetraCrsMatrixT()
Destructor.
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalarThis.
std::string description() const
A simple one-line description of this object.
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
#define XPETRA_ERR_CHECK(arg)
void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView< GlobalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
Extract a list of entries in a specified global row of this matrix. Put into pre-allocated storage...
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.
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.
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.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified (locally owned) global row...
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &) const
Get offsets of the diagonal entries in the matrix.
size_t getNodeNumCols() const
Returns the number of matrix columns owned on the calling node.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
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.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &RowImporter, const Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > DomainImporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
bool isFillActive() const
Returns true if the matrix is in edit mode.
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
Get the underlying Epetra matrix.
EpetraCrsMatrixT(const EpetraCrsMatrixT &matrix)
Deep copy constructor.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &RowExporter, const Teuchos::RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > DomainExporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
void replaceDiag(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag)
Replace the diagonal entries of the matrix.
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.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying (possibly different) number of entries in each row.
void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView< GlobalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
void allocateAllValues(size_t numNonZeros, ArrayRCP< size_t > &rowptr, ArrayRCP< LocalOrdinal > &colind, ArrayRCP< Scalar > &values)
Allocates and returns ArrayRCPs of the Crs arrays — This is an Xpetra-only routine.
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
void getAllValues(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind, ArrayRCP< const Scalar > &values) const
Gets the 1D pointer arrays of the graph.
void residual(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R) const
size_t getNodeNumRows() const
Returns the number of matrix rows owned on the calling node.
void replaceDiag(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag)
Replace the diagonal entries of the matrix.
Exception throws when you call an unimplemented method of Xpetra.
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.
void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView< GlobalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
Extract a list of entries in a specified global row of this matrix. Put into pre-allocated storage...
void expertStaticFillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &importer=Teuchos::null, const RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > &exporter=Teuchos::null, const RCP< ParameterList > ¶ms=Teuchos::null)
EpetraCrsMatrixT(const Teuchos::RCP< Epetra_CrsMatrix > &mtx)
EpetraCrsMatrixT constructor to wrap a Epetra_CrsMatrix object.
void fillComplete(const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete.
#define XPETRA_RCP_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
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 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)
size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
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.
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.
void residual(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R) const
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &)
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
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 CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying a previously constructed graph.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying a previously constructed graph.
bool isFillActive() const
Returns true if the matrix is in edit mode.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
CombineMode
Xpetra::Combine Mode enumerable type.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
#define XPETRA_MONITOR(funcName)
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &) const
Get offsets of the diagonal entries in the matrix.
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
Computes the sparse matrix-multivector multiplication.
RCP< Epetra_CrsMatrix > mtx_
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &)
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap)
Constructor for empty DynamicProfile matrix (no space is preallocated).
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Teuchos::ArrayView< const size_t > &) const
Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets...
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Teuchos::ArrayView< const size_t > &offsets) const
CrsMatrix< double, int, GlobalOrdinal, Node >::local_ordinal_type LocalOrdinal
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...
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries in the specified global row.
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=Teuchos::null)
Signal that data entry is complete, specifying domain and range maps.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying column Map and fixed number of entries for each row.
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=Teuchos::null)
Signal that data entry is complete, specifying domain and range maps.
void getAllValues(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind, ArrayRCP< const Scalar > &values) const
size_t getNodeNumRows() const
Returns the number of matrix rows owned on the calling node.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying column Map and fixed number of entries for each row.
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
bool isFillResumed_
Flag to keep track of fill status.
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
void setObjectLabel(const std::string &objectLabel)
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
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.
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 resumeFill(const RCP< ParameterList > &=Teuchos::null)
void replaceDomainMapAndImporter(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newDomainMap, Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &newImporter)